diff --git a/cmd/fixtures_test/executions/hlg_coin_program_with_input.json b/cmd/fixtures_test/executions/hlg_coin_program_with_input.json new file mode 100644 index 0000000000..292dabfbe1 --- /dev/null +++ b/cmd/fixtures_test/executions/hlg_coin_program_with_input.json @@ -0,0 +1,5 @@ +{ + "RecipeName":"Helicopter's Hlg Coin Generation From Input Recipe", + "Sender":"michael", + "ItemNames":["Helicopter's Knife lv3"] +} \ No newline at end of file diff --git a/cmd/fixtures_test/items/heli_knife_lv3.json b/cmd/fixtures_test/items/heli_knife_lv3.json new file mode 100644 index 0000000000..9f47bd0979 --- /dev/null +++ b/cmd/fixtures_test/items/heli_knife_lv3.json @@ -0,0 +1,7 @@ +{ + "Doubles": [{ "Key": "attack", "Value": "3" }], + "Longs": [{ "Key": "level", "Value": "3" }], + "Strings": [{ "Key": "Name", "Value": "Helicopter's Knife lv3" }], + "CookbookName": "helicopter", + "Sender": "michael" +} \ No newline at end of file diff --git a/cmd/fixtures_test/recipes/hlg_coin_program_with_input.json b/cmd/fixtures_test/recipes/hlg_coin_program_with_input.json new file mode 100644 index 0000000000..f75c425599 --- /dev/null +++ b/cmd/fixtures_test/recipes/hlg_coin_program_with_input.json @@ -0,0 +1,23 @@ +{ + "RType": "0", + "CoinInputs":[], + "ItemInputRefs": [ + "./recipes/item_input/heli_knife_lv3.json" + ], + "Entries":{ + "CoinOutputs":[ + { + "Coin": "hlgcoin", + "Program": "int(attack * double(5))", + "Weight": 1 + } + ], + "ItemOutputs":[] + }, + "ExtraInfo":"", + "Sender":"eugen", + "Name": "Helicopter's Hlg Coin Generation From Input Recipe", + "CookbookName": "helicopter", + "Description": "this has to meet character limits lol", + "BlockInterval":"0" +} \ No newline at end of file diff --git a/cmd/fixtures_test/recipes/item_input/heli_knife_lv3.json b/cmd/fixtures_test/recipes/item_input/heli_knife_lv3.json new file mode 100644 index 0000000000..fef5292b46 --- /dev/null +++ b/cmd/fixtures_test/recipes/item_input/heli_knife_lv3.json @@ -0,0 +1,5 @@ +{ + "Doubles": [{"Key": "attack", "MinValue": "3", "MaxValue": "3"}], + "Longs": [{"Key": "level", "MinValue": "3", "MaxValue": "3"}], + "Strings": [{"Key": "Name", "Value": "Helicopter's Knife lv3"}] +} \ No newline at end of file diff --git a/cmd/fixtures_test/scenarios/helicopter.json b/cmd/fixtures_test/scenarios/helicopter.json index fb0d17a36e..a46e0437a1 100644 --- a/cmd/fixtures_test/scenarios/helicopter.json +++ b/cmd/fixtures_test/scenarios/helicopter.json @@ -67,6 +67,30 @@ ] } }, + { + "ID": "CREATE_HELI_KNIFE_LV3", + "runAfter": { + "precondition": ["CREATE_HELICOPTER_COOKBOOK"], + "blockWait": 0 + }, + "action": "fiat_item", + "paramsRef": "./items/heli_knife_lv3.json", + "output": { + "txResult": { + "status": "Success" + }, + "property": [ + { + "owner": "michael", + "items": [ + { + "stringValues": { "Name": "Helicopter's Knife lv3" } + } + ] + } + ] + } + }, { "ID": "CREATE_HELI_SHIELD_LV1", "runAfter": { @@ -299,6 +323,26 @@ ] } }, + { + "ID": "CREATE_HLG_COIN_PROGRAM_WITH_INPUT_RECIPE", + "runAfter": { + "precondition": ["CREATE_HELICOPTER_COOKBOOK"], + "blockWait": 0 + }, + "action": "create_recipe", + "paramsRef": "./recipes/hlg_coin_program_with_input.json", + "output": { + "txResult": { + "status": "Success" + }, + "property": [ + { + "owner": "eugen", + "recipes": ["Helicopter's Hlg Coin Generation From Input Recipe"] + } + ] + } + }, { "ID": "EXECUTE_HELI_STRAIGHT_ATTACK_KNIFE_RECIPE", "runAfter": { @@ -527,5 +571,34 @@ }, "property": [] } + }, + { + "ID": "EXECUTE_HLG_COIN_PROGRAM_WITH_INPUT_RECIPE", + "runAfter": { + "precondition": [ + "CREATE_HELI_KNIFE_LV3", + "CREATE_HLG_COIN_PROGRAM_WITH_INPUT_RECIPE" + ], + "blockWait": 0 + }, + "action": "execute_recipe", + "paramsRef": "./executions/hlg_coin_program_with_input.json", + "output": { + "txResult": { + "status": "Success", + "message": "successfully executed the recipe" + }, + "property": [ + { + "owner": "michael", + "coins": [ + { + "denom": "hlgcoin", + "amount": 15 + } + ] + } + ] + } } ] \ No newline at end of file diff --git a/x/pylons/types/program_test.go b/x/pylons/types/program_test.go index fa49aae8a1..83d77895ce 100644 --- a/x/pylons/types/program_test.go +++ b/x/pylons/types/program_test.go @@ -131,6 +131,13 @@ func TestProgramWorkAsExpected(t *testing.T) { require.True(t, out.Value().(string) == "2.5") require.True(t, err == nil) + // randi, double, multiply and int merge test + out, err = CheckAndExecuteProgram(env, variables, funcs, `int(5.0 * double(randi(2)+4) )`) + t.Log(`int(5.0 * double(randi(2)+4) )`, out, err) + val64 = out.Value().(int64) + require.True(t, val64 == 20 || val64 == 25 || val64 == 30) + require.True(t, err == nil) + // failing test out, err = CheckAndExecuteProgram(env, variables, funcs, `level + attack`) t.Log(`level + attack`, out, err)