diff --git a/contracts/feature-tests/composability/scenarios/forwarder_call_async_multi_transfer_egld.scen.json b/contracts/feature-tests/composability/scenarios/forwarder_call_async_multi_transfer_egld.scen.json new file mode 100644 index 0000000000..7dc86ee64f --- /dev/null +++ b/contracts/feature-tests/composability/scenarios/forwarder_call_async_multi_transfer_egld.scen.json @@ -0,0 +1,206 @@ +{ + "gasSchedule": "v3", + "steps": [ + { + "step": "setState", + "accounts": { + "address:a_user": { + "nonce": "0", + "balance": "0" + }, + "sc:forwarder": { + "nonce": "0", + "balance": "4000", + "esdt": { + "str:FWD-TOKEN": "1000", + "str:NFT-123456": { + "instances": [ + { + "nonce": "1", + "balance": "1" + } + ] + }, + "str:SFT-456789": { + "instances": [ + { + "nonce": "3", + "balance": "10" + } + ] + } + }, + "code": "mxsc:../forwarder/output/forwarder.mxsc.json" + }, + "sc:vault": { + "nonce": "0", + "balance": "0", + "code": "mxsc:../vault/output/vault.mxsc.json" + } + } + }, + { + "step": "scCall", + "id": "1", + "comment": "send fungible twice", + "tx": { + "from": "address:a_user", + "to": "sc:forwarder", + "function": "send_async_accept_multi_transfer", + "arguments": [ + "sc:vault", + "str:FWD-TOKEN", + "0", + "100", + "str:FWD-TOKEN", + "0", + "200" + ], + "gasLimit": "80,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "checkState", + "accounts": { + "address:a_user": { + "nonce": "*", + "balance": "0", + "storage": {}, + "code": "" + }, + "sc:vault": { + "nonce": "0", + "balance": "0", + "esdt": { + "str:FWD-TOKEN": "300" + }, + "storage": { + "str:call_counts|nested:str:accept_funds": "1" + }, + "code": "mxsc:../vault/output/vault.mxsc.json" + }, + "sc:forwarder": { + "nonce": "0", + "balance": "4000", + "esdt": { + "str:FWD-TOKEN": "700", + "str:NFT-123456": { + "instances": [ + { + "nonce": "1", + "balance": "1" + } + ] + }, + "str:SFT-456789": { + "instances": [ + { + "nonce": "3", + "balance": "10" + } + ] + } + }, + "storage": {}, + "code": "mxsc:../forwarder/output/forwarder.mxsc.json" + } + } + }, + { + "step": "scCall", + "id": "2", + "comment": "send all types", + "tx": { + "from": "address:a_user", + "to": "sc:forwarder", + "function": "send_async_accept_multi_transfer", + "arguments": [ + "sc:vault", + "str:FWD-TOKEN", + "0", + "500", + "str:NFT-123456", + "1", + "1", + "str:EGLD-000000", + "0", + "100", + "str:SFT-456789", + "3", + "6" + ], + "gasLimit": "80,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "0", + "message": "", + "gas": "*", + "refund": "*" + } + }, + { + "step": "checkState", + "accounts": { + "address:a_user": { + "nonce": "*", + "balance": "0", + "storage": {}, + "code": "" + }, + "sc:vault": { + "nonce": "0", + "balance": "100", + "esdt": { + "str:FWD-TOKEN": "800", + "str:NFT-123456": { + "instances": [ + { + "nonce": "1", + "balance": "1" + } + ] + }, + "str:SFT-456789": { + "instances": [ + { + "nonce": "3", + "balance": "6" + } + ] + } + }, + "storage": { + "str:call_counts|nested:str:accept_funds": "2" + }, + "code": "mxsc:../vault/output/vault.mxsc.json" + }, + "sc:forwarder": { + "nonce": "0", + "balance": "3900", + "esdt": { + "str:FWD-TOKEN": "200", + "str:SFT-456789": { + "instances": [ + { + "nonce": "3", + "balance": "4" + } + ] + } + }, + "code": "mxsc:../forwarder/output/forwarder.mxsc.json" + } + } + } + ] +} \ No newline at end of file diff --git a/contracts/feature-tests/payable-features/scenarios/call-value-check-multi-egld.scen.json b/contracts/feature-tests/payable-features/scenarios/call-value-check-multi-egld.scen.json new file mode 100644 index 0000000000..8490c055fe --- /dev/null +++ b/contracts/feature-tests/payable-features/scenarios/call-value-check-multi-egld.scen.json @@ -0,0 +1,128 @@ +{ + "steps": [ + { + "step": "setState", + "accounts": { + "sc:payable-features": { + "nonce": "0", + "balance": "0", + "code": "mxsc:../output/payable-features.mxsc.json" + }, + "address:an-account": { + "nonce": "0", + "balance": "10000", + "esdt": { + "str:TOK-123456": "1000", + "str:OTHERTOK-123456": "500", + "str:SFT-123": { + "instances": [ + { + "nonce": "5", + "balance": "20" + } + ] + } + } + } + } + }, + { + "step": "scCall", + "id": "call-value-egld", + "tx": { + "from": "address:an-account", + "to": "sc:payable-features", + "egldValue": "100", + "function": "echo_call_value", + "arguments": [], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [ + "100", + "" + ], + "status": "", + "logs": "*", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "id": "call-value-single-esdt", + "tx": { + "from": "address:an-account", + "to": "sc:payable-features", + "esdtValue": [ + { + "tokenIdentifier": "str:TOK-123456", + "value": "100" + } + ], + "function": "echo_call_value", + "arguments": [], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [ + "0", + [ + "nested:str:TOK-123456|u64:0|biguint:100" + ] + ], + "status": "", + "logs": "*", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "id": "call-value-multi-esdt", + "tx": { + "from": "address:an-account", + "to": "sc:payable-features", + "esdtValue": [ + { + "tokenIdentifier": "str:EGLD-000000", + "value": "15" + }, + { + "tokenIdentifier": "str:TOK-123456", + "value": "100" + }, + { + "tokenIdentifier": "str:OTHERTOK-123456", + "value": "400" + }, + { + "tokenIdentifier": "str:SFT-123", + "nonce": "5", + "value": "10" + } + ], + "function": "echo_call_value", + "arguments": [], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [ + "15", + [ + "nested:str:TOK-123456|u64:0|biguint:100", + "nested:str:OTHERTOK-123456|u64:0|biguint:400", + "nested:str:SFT-123|u64:5|biguint:10" + ] + ], + "status": "", + "logs": "*", + "gas": "*", + "refund": "*" + } + } + ] +} \ No newline at end of file diff --git a/contracts/feature-tests/payable-features/scenarios/payable_multi_array_egld.scen.json b/contracts/feature-tests/payable-features/scenarios/payable_multi_array_egld.scen.json new file mode 100644 index 0000000000..16fa1cea20 --- /dev/null +++ b/contracts/feature-tests/payable-features/scenarios/payable_multi_array_egld.scen.json @@ -0,0 +1,146 @@ +{ + "name": "payable", + "gasSchedule": "v3", + "steps": [ + { + "step": "setState", + "accounts": { + "sc:payable-features": { + "nonce": "0", + "balance": "0", + "code": "mxsc:../output/payable-features.mxsc.json" + }, + "address:an-account": { + "nonce": "0", + "balance": "10000", + "esdt": { + "str:TOK-000001": "1000", + "str:TOK-000002": "500", + "str:TOK-000003": "500", + "str:SFT-123": { + "instances": [ + { + "nonce": "5", + "balance": "20" + } + ] + } + } + } + } + }, + { + "step": "scCall", + "id": "payment-array-too-many", + "tx": { + "from": "address:an-account", + "to": "sc:payable-features", + "esdtValue": [ + { + "tokenIdentifier": "str:TOK-000001", + "value": "100" + }, + { + "tokenIdentifier": "str:TOK-000002", + "value": "400" + }, + { + "tokenIdentifier": "str:TOK-000003", + "value": "400" + }, + { + "tokenIdentifier": "str:SFT-123", + "nonce": "5", + "value": "10" + }, + { + "tokenIdentifier": "str:EGLD-000000", + "nonce": "0", + "value": "103" + } + ], + "function": "payment_array_3", + "arguments": [], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "4", + "message": "str:incorrect number of ESDT transfers", + "logs": "*", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "id": "payment-array-too-few", + "tx": { + "from": "address:an-account", + "to": "sc:payable-features", + "esdtValue": [ + { + "tokenIdentifier": "str:TOK-000001", + "value": "100" + }, + { + "tokenIdentifier": "str:SFT-123", + "nonce": "5", + "value": "10" + } + ], + "function": "payment_array_3", + "arguments": [], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [], + "status": "4", + "message": "str:incorrect number of ESDT transfers", + "logs": "*", + "gas": "*", + "refund": "*" + } + }, + { + "step": "scCall", + "id": "payment-array-ok", + "tx": { + "from": "address:an-account", + "to": "sc:payable-features", + "esdtValue": [ + { + "tokenIdentifier": "str:TOK-000001", + "value": "100" + }, + { + "tokenIdentifier": "str:EGLD-000000", + "value": "400" + }, + { + "tokenIdentifier": "str:SFT-123", + "nonce": "5", + "value": "10" + } + ], + "function": "payment_array_3", + "arguments": [], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [ + "nested:str:TOK-000001|u64:0|biguint:100", + "nested:str:EGLD-000000|u64:0|biguint:400", + "nested:str:SFT-123|u64:5|biguint:10" + ], + "status": "", + "logs": "*", + "gas": "*", + "refund": "*" + } + } + ] +} \ No newline at end of file diff --git a/contracts/feature-tests/payable-features/scenarios/payable_multiple_egld.scen.json b/contracts/feature-tests/payable-features/scenarios/payable_multiple_egld.scen.json new file mode 100644 index 0000000000..28e667b322 --- /dev/null +++ b/contracts/feature-tests/payable-features/scenarios/payable_multiple_egld.scen.json @@ -0,0 +1,78 @@ +{ + "name": "payable", + "gasSchedule": "v3", + "steps": [ + { + "step": "setState", + "accounts": { + "sc:payable-features": { + "nonce": "0", + "balance": "0", + "code": "mxsc:../output/payable-features.mxsc.json" + }, + "address:an-account": { + "nonce": "0", + "balance": "10000", + "esdt": { + "str:TOK-123456": "1000", + "str:OTHERTOK-123456": "500", + "str:SFT-123": { + "instances": [ + { + "nonce": "5", + "balance": "20" + } + ] + } + } + } + } + }, + { + "step": "scCall", + "id": "payment-multiple", + "tx": { + "from": "address:an-account", + "to": "sc:payable-features", + "esdtValue": [ + { + "tokenIdentifier": "str:TOK-123456", + "value": "100" + }, + { + "tokenIdentifier": "str:OTHERTOK-123456", + "value": "400" + }, + { + "tokenIdentifier": "str:SFT-123", + "nonce": "5", + "value": "10" + }, + { + "tokenIdentifier": "str:EGLD-000000", + "nonce": "0", + "value": "120" + } + ], + "function": "payment_multiple", + "arguments": [], + "gasLimit": "50,000,000", + "gasPrice": "0" + }, + "expect": { + "out": [ + [ + "nested:str:TOK-123456|u64:0|biguint:100|", + "nested:str:OTHERTOK-123456|u64:0|biguint:400", + "nested:str:SFT-123|u64:5|biguint:10", + "nested:str:EGLD-000000|u64:0|biguint:120" + ] + ], + "status": "", + "logs": "*", + "gas": "*", + "refund": "*" + } + } + ] +} \ No newline at end of file diff --git a/framework/scenario/tests/multi_transfer_with_egld.rs b/framework/scenario/tests/multi_transfer_with_egld.rs new file mode 100644 index 0000000000..fdc5d0ffa4 --- /dev/null +++ b/framework/scenario/tests/multi_transfer_with_egld.rs @@ -0,0 +1,10 @@ +use multiversx_sc_scenario::*; + +fn world() -> ScenarioWorld { + ScenarioWorld::vm_go() +} + +#[test] +fn multi_transfer_with_egld_test() { + world().run("tests/scenarios-self/multi_transfer_with_egld.scen.json"); +} diff --git a/framework/scenario/tests/scenarios-self/multi-transfer-egld.scen.json b/framework/scenario/tests/scenarios-self/multi-transfer-egld.scen.json new file mode 100644 index 0000000000..32b5ee3aa1 --- /dev/null +++ b/framework/scenario/tests/scenarios-self/multi-transfer-egld.scen.json @@ -0,0 +1,100 @@ +{ + "comment": "ESDT multi-transfer with EGLD, no SC", + "steps": [ + { + "step": "setState", + "accounts": { + "address:A": { + "nonce": "0", + "balance": "1000000000", + "esdt": { + "str:TOK-123456": "150", + "str:OTHERTOK-123456": "500", + "str:NFT-123456": { + "instances": [ + { + "nonce": "5", + "balance": "20" + } + ] + } + } + }, + "address:B": { + "nonce": "0", + "balance": "0" + } + } + }, + { + "step": "transfer", + "id": "multi-transfer", + "tx": { + "from": "address:A", + "to": "address:B", + "esdtValue": [ + { + "tokenIdentifier": "str:TOK-123456", + "value": "100" + }, + { + "tokenIdentifier": "str:OTHERTOK-123456", + "value": "400" + }, + { + "tokenIdentifier": "str:EGLD-000000", + "value": "500" + }, + { + "tokenIdentifier": "str:NFT-123456", + "nonce": "5", + "value": "10" + } + ], + "gasLimit": "0x100000000" + } + }, + { + "step": "checkState", + "comment": "check after tx 1", + "accounts": { + "address:A": { + "nonce": "1", + "balance": "999999500", + "esdt": { + "str:TOK-123456": "50", + "str:OTHERTOK-123456": "100", + "str:NFT-123456": { + "instances": [ + { + "nonce": "5", + "balance": "10" + } + ] + } + }, + "storage": {}, + "code": "" + }, + "address:B": { + "nonce": "0", + "balance": "500", + "esdt": { + "str:TOK-123456": "100", + "str:OTHERTOK-123456": "400", + "str:NFT-123456": { + "instances": [ + { + "nonce": "5", + "balance": "10" + } + ] + } + }, + "storage": {}, + "code": "" + } + } + } + ] +} \ No newline at end of file diff --git a/framework/scenario/tests/scenarios-self/multi-transfer-esdt.scen.json b/framework/scenario/tests/scenarios-self/multi-transfer-esdt.scen.json index 3b1095be7a..09ebf399dd 100644 --- a/framework/scenario/tests/scenarios-self/multi-transfer-esdt.scen.json +++ b/framework/scenario/tests/scenarios-self/multi-transfer-esdt.scen.json @@ -6,7 +6,7 @@ "accounts": { "address:A": { "nonce": "0", - "balance": "0x1000000000", + "balance": "1000000000", "esdt": { "str:TOK-123456": "150", "str:OTHERTOK-123456": "500", @@ -47,8 +47,7 @@ "value": "10" } ], - "gasLimit": "0x100000000", - "gasPrice": "0x01" + "gasLimit": "0x100000000" } }, { @@ -57,7 +56,7 @@ "accounts": { "address:A": { "nonce": "1", - "balance": "0xf00000000", + "balance": "1000000000", "esdt": { "str:TOK-123456": "50", "str:OTHERTOK-123456": "100", diff --git a/framework/scenario/tests/scenarios-self/multi_transfer_with_egld.scen.json b/framework/scenario/tests/scenarios-self/multi_transfer_with_egld.scen.json new file mode 100644 index 0000000000..0dcd2bfc6d --- /dev/null +++ b/framework/scenario/tests/scenarios-self/multi_transfer_with_egld.scen.json @@ -0,0 +1,72 @@ +{ + "steps": [ + { + "step": "setState", + "accounts": { + "bech32:erd1y3z4vsn2m026glevhsqpwrc5w4v0xzr2qmukc5qde39jnzze324qf4e2r4": { + "nonce": "0", + "balance": "10", + "esdt": { + "str:TEST-6bb410": { + "instances": [ + { + "nonce": "0", + "balance": "100", + "royalties": "0", + "attributes": "0x" + } + ] + } + }, + "developerRewards": "0" + }, + "bech32:erd1uv40ahysflse896x4ktnh6ecx43u7cmy9wnxnvcyp7deg299a4sq6vaywa": { + "nonce": "0", + "balance": "0", + "esdt": {}, + "developerRewards": "0" + } + } + }, + { + "step": "transfer", + "id": "", + "tx": { + "from": "bech32:erd1y3z4vsn2m026glevhsqpwrc5w4v0xzr2qmukc5qde39jnzze324qf4e2r4", + "to": "bech32:erd1uv40ahysflse896x4ktnh6ecx43u7cmy9wnxnvcyp7deg299a4sq6vaywa", + "esdtValue": [ + { + "tokenIdentifier": "0x45474c442d303030303030", + "value": "4" + }, + { + "tokenIdentifier": "0x544553542d366262343130", + "value": "10" + } + ], + "gasLimit": "5,000,000" + } + }, + { + "step": "checkState", + "accounts": { + "bech32:erd1y3z4vsn2m026glevhsqpwrc5w4v0xzr2qmukc5qde39jnzze324qf4e2r4": { + "nonce": "*", + "balance": "6", + "esdt": { + "str:TEST-6bb410": "90" + }, + "storage": {} + }, + "bech32:erd1uv40ahysflse896x4ktnh6ecx43u7cmy9wnxnvcyp7deg299a4sq6vaywa": { + "nonce": "*", + "balance": "4", + "esdt": { + "str:TEST-6bb410": "10" + }, + "storage": {} + } + } + } + ] +} \ No newline at end of file diff --git a/framework/scenario/tests/scenarios_self_test.rs b/framework/scenario/tests/scenarios_self_test.rs index b6bf9c1883..94f63a0539 100644 --- a/framework/scenario/tests/scenarios_self_test.rs +++ b/framework/scenario/tests/scenarios_self_test.rs @@ -160,6 +160,12 @@ fn esdt_zero_balance_check_err_rs() { world().run("tests/scenarios-self/esdt-zero-balance-check-err.scen.json"); } +#[test] +#[ignore = "TODO: not yet implemented in Rust VM"] +fn multi_transfer_egld_rs() { + world().run("tests/scenarios-self/multi-transfer-esdt.scen.json"); +} + #[test] fn multi_transfer_esdt_rs() { world().run("tests/scenarios-self/multi-transfer-esdt.scen.json");