From 10f2939d7405c038c03d90b5793f483ff0451dfc Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Fri, 29 Nov 2024 14:47:16 +0200 Subject: [PATCH 1/5] test - multi transfer with egld --- .../interact/src/bf_interact.rs | 52 +++++++++++++++ .../interact/tests/bf_interact_cs_test.rs | 1 + .../multi_transfer_with_egld.scen.json | 66 +++++++++++++++++++ .../tests/basic_features_scenario_go_test.rs | 5 ++ .../tests/basic_features_scenario_rs_test.rs | 6 ++ 5 files changed, 130 insertions(+) create mode 100644 contracts/feature-tests/basic-features/scenarios/multi_transfer_with_egld.scen.json diff --git a/contracts/feature-tests/basic-features/interact/src/bf_interact.rs b/contracts/feature-tests/basic-features/interact/src/bf_interact.rs index 665fa24fc8..85c0cf8abd 100644 --- a/contracts/feature-tests/basic-features/interact/src/bf_interact.rs +++ b/contracts/feature-tests/basic-features/interact/src/bf_interact.rs @@ -306,4 +306,56 @@ impl BasicFeaturesInteract { }, } } + + pub async fn multi_transfer_with_egld(&mut self) { + let alice = self.interactor.register_wallet(test_wallets::alice()).await; + + let mut payments = ManagedVec::from(( + TokenIdentifier::from_esdt_bytes(b"EGLD-000000").clone(), + 0, + BigUint::from(50000000000000000u64), + )); + + let token = self + .interactor + .tx() + .from(&self.wallet_address) + .to(ESDTSystemSCAddress) + .gas(100_000_000u64) + .typed(ESDTSystemSCProxy) + .issue_fungible( + BigUint::from(50000000000000000u64), + "test", + "TEST", + BigUint::from(100usize), + FungibleTokenProperties { + num_decimals: 0usize, + can_freeze: true, + can_wipe: true, + can_pause: true, + can_mint: true, + can_burn: true, + can_change_owner: true, + can_upgrade: true, + can_add_special_roles: true, + }, + ) + .returns(ReturnsNewTokenIdentifier) + .run() + .await; + + payments.push(EsdtTokenPayment::new( + TokenIdentifier::from_esdt_bytes(token).clone(), + 0, + BigUint::from(10u32), + )); + + self.interactor + .tx() + .from(&self.wallet_address) + .to(alice) + .payment(payments) + .run() + .await; + } } diff --git a/contracts/feature-tests/basic-features/interact/tests/bf_interact_cs_test.rs b/contracts/feature-tests/basic-features/interact/tests/bf_interact_cs_test.rs index 57702b5160..e9b3d70b74 100644 --- a/contracts/feature-tests/basic-features/interact/tests/bf_interact_cs_test.rs +++ b/contracts/feature-tests/basic-features/interact/tests/bf_interact_cs_test.rs @@ -16,6 +16,7 @@ async fn simulator_basic_features_test() { assert_eq!(bf_interact.large_storage_payload, data); bf_interact.deploy().await; + bf_interact.multi_transfer_with_egld().await; let expected_return_egld_decimal = ManagedDecimal::>::const_decimals_from_raw(BigUint::from( diff --git a/contracts/feature-tests/basic-features/scenarios/multi_transfer_with_egld.scen.json b/contracts/feature-tests/basic-features/scenarios/multi_transfer_with_egld.scen.json new file mode 100644 index 0000000000..92205812ee --- /dev/null +++ b/contracts/feature-tests/basic-features/scenarios/multi_transfer_with_egld.scen.json @@ -0,0 +1,66 @@ +{ + "steps": [ + { + "step": "setState", + "newTokenIdentifiers": [ + "TEST-6bb410" + ] + }, + { + "step": "scCall", + "id": "", + "tx": { + "from": "bech32:erd1y3z4vsn2m026glevhsqpwrc5w4v0xzr2qmukc5qde39jnzze324qf4e2r4", + "to": "bech32:erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u", + "egldValue": "50000000000000000", + "function": "issue", + "arguments": [ + "0x74657374", + "0x54455354", + "0x64", + "0x", + "0x63616e467265657a65", + "0x74727565", + "0x63616e57697065", + "0x74727565", + "0x63616e5061757365", + "0x74727565", + "0x63616e4d696e74", + "0x74727565", + "0x63616e4275726e", + "0x74727565", + "0x63616e4368616e67654f776e6572", + "0x74727565", + "0x63616e55706772616465", + "0x74727565", + "0x63616e4164645370656369616c526f6c6573", + "0x74727565" + ], + "gasLimit": "100000000" + }, + "expect": { + "out": [], + "status": "0" + } + }, + { + "step": "transfer", + "id": "", + "tx": { + "from": "bech32:erd1y3z4vsn2m026glevhsqpwrc5w4v0xzr2qmukc5qde39jnzze324qf4e2r4", + "to": "bech32:erd1uv40ahysflse896x4ktnh6ecx43u7cmy9wnxnvcyp7deg299a4sq6vaywa", + "esdtValue": [ + { + "tokenIdentifier": "0x45474c442d303030303030", + "value": "50000000000000000" + }, + { + "tokenIdentifier": "0x544553542d366262343130", + "value": "10" + } + ], + "gasLimit": "5,000,000" + } + } + ] +} diff --git a/contracts/feature-tests/basic-features/tests/basic_features_scenario_go_test.rs b/contracts/feature-tests/basic-features/tests/basic_features_scenario_go_test.rs index 02032a2126..b1717b0efc 100644 --- a/contracts/feature-tests/basic-features/tests/basic_features_scenario_go_test.rs +++ b/contracts/feature-tests/basic-features/tests/basic_features_scenario_go_test.rs @@ -187,6 +187,11 @@ fn echo_u_64_go() { world().run("scenarios/echo_u64.scen.json"); } +#[test] +fn multi_transfer_with_egld_go() { + world().run("scenarios/multi_transfer_with_egld.scen.json"); +} + #[test] fn echo_usize_go() { world().run("scenarios/echo_usize.scen.json"); diff --git a/contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs b/contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs index a4efa924ab..3268f63771 100644 --- a/contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs +++ b/contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs @@ -207,6 +207,12 @@ fn echo_u_64_rs() { world().run("scenarios/echo_u64.scen.json"); } +#[test] +#[ignore = "not supported yet"] +fn multi_transfer_with_egld_go() { + world().run("scenarios/multi_transfer_with_egld.scen.json"); +} + #[test] fn echo_usize_rs() { world().run("scenarios/echo_usize.scen.json"); From 5bfad3b2a14298c74d0489cbf2b8bb4d95527e54 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Fri, 29 Nov 2024 15:27:06 +0200 Subject: [PATCH 2/5] fix .scen.json test --- .../multi_transfer_with_egld.scen.json | 88 ++++++++++--------- .../tests/basic_features_scenario_rs_test.rs | 2 +- 2 files changed, 48 insertions(+), 42 deletions(-) diff --git a/contracts/feature-tests/basic-features/scenarios/multi_transfer_with_egld.scen.json b/contracts/feature-tests/basic-features/scenarios/multi_transfer_with_egld.scen.json index 92205812ee..0dcd2bfc6d 100644 --- a/contracts/feature-tests/basic-features/scenarios/multi_transfer_with_egld.scen.json +++ b/contracts/feature-tests/basic-features/scenarios/multi_transfer_with_egld.scen.json @@ -2,45 +2,30 @@ "steps": [ { "step": "setState", - "newTokenIdentifiers": [ - "TEST-6bb410" - ] - }, - { - "step": "scCall", - "id": "", - "tx": { - "from": "bech32:erd1y3z4vsn2m026glevhsqpwrc5w4v0xzr2qmukc5qde39jnzze324qf4e2r4", - "to": "bech32:erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u", - "egldValue": "50000000000000000", - "function": "issue", - "arguments": [ - "0x74657374", - "0x54455354", - "0x64", - "0x", - "0x63616e467265657a65", - "0x74727565", - "0x63616e57697065", - "0x74727565", - "0x63616e5061757365", - "0x74727565", - "0x63616e4d696e74", - "0x74727565", - "0x63616e4275726e", - "0x74727565", - "0x63616e4368616e67654f776e6572", - "0x74727565", - "0x63616e55706772616465", - "0x74727565", - "0x63616e4164645370656369616c526f6c6573", - "0x74727565" - ], - "gasLimit": "100000000" - }, - "expect": { - "out": [], - "status": "0" + "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" + } } }, { @@ -52,7 +37,7 @@ "esdtValue": [ { "tokenIdentifier": "0x45474c442d303030303030", - "value": "50000000000000000" + "value": "4" }, { "tokenIdentifier": "0x544553542d366262343130", @@ -61,6 +46,27 @@ ], "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/contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs b/contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs index 3268f63771..0ab2459561 100644 --- a/contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs +++ b/contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs @@ -209,7 +209,7 @@ fn echo_u_64_rs() { #[test] #[ignore = "not supported yet"] -fn multi_transfer_with_egld_go() { +fn multi_transfer_with_egld_rs() { world().run("scenarios/multi_transfer_with_egld.scen.json"); } From 259a4fbd05d612f3019ca8a2e3bc05a844acbc54 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Sat, 30 Nov 2024 14:17:43 +0200 Subject: [PATCH 3/5] test - update multi payments w egld --- .../interact/src/bf_interact.rs | 52 ------------------- .../interact/tests/bf_interact_cs_test.rs | 1 - .../tests/basic_features_scenario_go_test.rs | 5 -- .../tests/basic_features_scenario_rs_test.rs | 6 --- .../scenarios/call-value-check.scen.json | 8 ++- .../scenarios/payable_multi_array.scen.json | 11 ++-- .../scenarios/payable_multiple.scen.json | 10 +++- .../tests/multi_transfer_with_egld.rs | 10 ++++ .../multi_transfer_with_egld.scen.json | 0 9 files changed, 32 insertions(+), 71 deletions(-) create mode 100644 framework/scenario/tests/multi_transfer_with_egld.rs rename {contracts/feature-tests/basic-features/scenarios => framework/scenario/tests/scenarios-self}/multi_transfer_with_egld.scen.json (100%) diff --git a/contracts/feature-tests/basic-features/interact/src/bf_interact.rs b/contracts/feature-tests/basic-features/interact/src/bf_interact.rs index 85c0cf8abd..665fa24fc8 100644 --- a/contracts/feature-tests/basic-features/interact/src/bf_interact.rs +++ b/contracts/feature-tests/basic-features/interact/src/bf_interact.rs @@ -306,56 +306,4 @@ impl BasicFeaturesInteract { }, } } - - pub async fn multi_transfer_with_egld(&mut self) { - let alice = self.interactor.register_wallet(test_wallets::alice()).await; - - let mut payments = ManagedVec::from(( - TokenIdentifier::from_esdt_bytes(b"EGLD-000000").clone(), - 0, - BigUint::from(50000000000000000u64), - )); - - let token = self - .interactor - .tx() - .from(&self.wallet_address) - .to(ESDTSystemSCAddress) - .gas(100_000_000u64) - .typed(ESDTSystemSCProxy) - .issue_fungible( - BigUint::from(50000000000000000u64), - "test", - "TEST", - BigUint::from(100usize), - FungibleTokenProperties { - num_decimals: 0usize, - can_freeze: true, - can_wipe: true, - can_pause: true, - can_mint: true, - can_burn: true, - can_change_owner: true, - can_upgrade: true, - can_add_special_roles: true, - }, - ) - .returns(ReturnsNewTokenIdentifier) - .run() - .await; - - payments.push(EsdtTokenPayment::new( - TokenIdentifier::from_esdt_bytes(token).clone(), - 0, - BigUint::from(10u32), - )); - - self.interactor - .tx() - .from(&self.wallet_address) - .to(alice) - .payment(payments) - .run() - .await; - } } diff --git a/contracts/feature-tests/basic-features/interact/tests/bf_interact_cs_test.rs b/contracts/feature-tests/basic-features/interact/tests/bf_interact_cs_test.rs index e9b3d70b74..57702b5160 100644 --- a/contracts/feature-tests/basic-features/interact/tests/bf_interact_cs_test.rs +++ b/contracts/feature-tests/basic-features/interact/tests/bf_interact_cs_test.rs @@ -16,7 +16,6 @@ async fn simulator_basic_features_test() { assert_eq!(bf_interact.large_storage_payload, data); bf_interact.deploy().await; - bf_interact.multi_transfer_with_egld().await; let expected_return_egld_decimal = ManagedDecimal::>::const_decimals_from_raw(BigUint::from( diff --git a/contracts/feature-tests/basic-features/tests/basic_features_scenario_go_test.rs b/contracts/feature-tests/basic-features/tests/basic_features_scenario_go_test.rs index b1717b0efc..02032a2126 100644 --- a/contracts/feature-tests/basic-features/tests/basic_features_scenario_go_test.rs +++ b/contracts/feature-tests/basic-features/tests/basic_features_scenario_go_test.rs @@ -187,11 +187,6 @@ fn echo_u_64_go() { world().run("scenarios/echo_u64.scen.json"); } -#[test] -fn multi_transfer_with_egld_go() { - world().run("scenarios/multi_transfer_with_egld.scen.json"); -} - #[test] fn echo_usize_go() { world().run("scenarios/echo_usize.scen.json"); diff --git a/contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs b/contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs index 0ab2459561..a4efa924ab 100644 --- a/contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs +++ b/contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs @@ -207,12 +207,6 @@ fn echo_u_64_rs() { world().run("scenarios/echo_u64.scen.json"); } -#[test] -#[ignore = "not supported yet"] -fn multi_transfer_with_egld_rs() { - world().run("scenarios/multi_transfer_with_egld.scen.json"); -} - #[test] fn echo_usize_rs() { world().run("scenarios/echo_usize.scen.json"); diff --git a/contracts/feature-tests/payable-features/scenarios/call-value-check.scen.json b/contracts/feature-tests/payable-features/scenarios/call-value-check.scen.json index 23da3773d6..8490c055fe 100644 --- a/contracts/feature-tests/payable-features/scenarios/call-value-check.scen.json +++ b/contracts/feature-tests/payable-features/scenarios/call-value-check.scen.json @@ -86,6 +86,10 @@ "from": "address:an-account", "to": "sc:payable-features", "esdtValue": [ + { + "tokenIdentifier": "str:EGLD-000000", + "value": "15" + }, { "tokenIdentifier": "str:TOK-123456", "value": "100" @@ -107,7 +111,7 @@ }, "expect": { "out": [ - "0", + "15", [ "nested:str:TOK-123456|u64:0|biguint:100", "nested:str:OTHERTOK-123456|u64:0|biguint:400", @@ -121,4 +125,4 @@ } } ] -} +} \ No newline at end of file diff --git a/contracts/feature-tests/payable-features/scenarios/payable_multi_array.scen.json b/contracts/feature-tests/payable-features/scenarios/payable_multi_array.scen.json index b05028dfae..16fa1cea20 100644 --- a/contracts/feature-tests/payable-features/scenarios/payable_multi_array.scen.json +++ b/contracts/feature-tests/payable-features/scenarios/payable_multi_array.scen.json @@ -52,6 +52,11 @@ "tokenIdentifier": "str:SFT-123", "nonce": "5", "value": "10" + }, + { + "tokenIdentifier": "str:EGLD-000000", + "nonce": "0", + "value": "103" } ], "function": "payment_array_3", @@ -111,7 +116,7 @@ "value": "100" }, { - "tokenIdentifier": "str:TOK-000002", + "tokenIdentifier": "str:EGLD-000000", "value": "400" }, { @@ -128,7 +133,7 @@ "expect": { "out": [ "nested:str:TOK-000001|u64:0|biguint:100", - "nested:str:TOK-000002|u64:0|biguint:400", + "nested:str:EGLD-000000|u64:0|biguint:400", "nested:str:SFT-123|u64:5|biguint:10" ], "status": "", @@ -138,4 +143,4 @@ } } ] -} +} \ No newline at end of file diff --git a/contracts/feature-tests/payable-features/scenarios/payable_multiple.scen.json b/contracts/feature-tests/payable-features/scenarios/payable_multiple.scen.json index 45d92e9fa7..28e667b322 100644 --- a/contracts/feature-tests/payable-features/scenarios/payable_multiple.scen.json +++ b/contracts/feature-tests/payable-features/scenarios/payable_multiple.scen.json @@ -47,6 +47,11 @@ "tokenIdentifier": "str:SFT-123", "nonce": "5", "value": "10" + }, + { + "tokenIdentifier": "str:EGLD-000000", + "nonce": "0", + "value": "120" } ], "function": "payment_multiple", @@ -59,7 +64,8 @@ [ "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:SFT-123|u64:5|biguint:10", + "nested:str:EGLD-000000|u64:0|biguint:120" ] ], "status": "", @@ -69,4 +75,4 @@ } } ] -} +} \ 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/contracts/feature-tests/basic-features/scenarios/multi_transfer_with_egld.scen.json b/framework/scenario/tests/scenarios-self/multi_transfer_with_egld.scen.json similarity index 100% rename from contracts/feature-tests/basic-features/scenarios/multi_transfer_with_egld.scen.json rename to framework/scenario/tests/scenarios-self/multi_transfer_with_egld.scen.json From 1b32b5357f2fb6633a30f432e9d449a3ee882e51 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Mon, 2 Dec 2024 12:39:11 +0200 Subject: [PATCH 4/5] test - forwarder multi transfer, multi transfer --- ...warder_call_async_multi_transfer.scen.json | 13 +- .../src/api/managed_types/const_handles.rs | 4 +- .../multi-transfer-esdt.scen.json | 14 +- .../scenario/tests/scenarios_self_go_test.rs | 181 ++++++++++++++++++ ...self_test.rs => scenarios_self_rs_test.rs} | 0 5 files changed, 200 insertions(+), 12 deletions(-) create mode 100644 framework/scenario/tests/scenarios_self_go_test.rs rename framework/scenario/tests/{scenarios_self_test.rs => scenarios_self_rs_test.rs} (100%) diff --git a/contracts/feature-tests/composability/scenarios/forwarder_call_async_multi_transfer.scen.json b/contracts/feature-tests/composability/scenarios/forwarder_call_async_multi_transfer.scen.json index 81b18ee338..7dc86ee64f 100644 --- a/contracts/feature-tests/composability/scenarios/forwarder_call_async_multi_transfer.scen.json +++ b/contracts/feature-tests/composability/scenarios/forwarder_call_async_multi_transfer.scen.json @@ -10,7 +10,7 @@ }, "sc:forwarder": { "nonce": "0", - "balance": "0", + "balance": "4000", "esdt": { "str:FWD-TOKEN": "1000", "str:NFT-123456": { @@ -89,7 +89,7 @@ }, "sc:forwarder": { "nonce": "0", - "balance": "0", + "balance": "4000", "esdt": { "str:FWD-TOKEN": "700", "str:NFT-123456": { @@ -130,6 +130,9 @@ "str:NFT-123456", "1", "1", + "str:EGLD-000000", + "0", + "100", "str:SFT-456789", "3", "6" @@ -156,7 +159,7 @@ }, "sc:vault": { "nonce": "0", - "balance": "0", + "balance": "100", "esdt": { "str:FWD-TOKEN": "800", "str:NFT-123456": { @@ -183,7 +186,7 @@ }, "sc:forwarder": { "nonce": "0", - "balance": "0", + "balance": "3900", "esdt": { "str:FWD-TOKEN": "200", "str:SFT-456789": { @@ -200,4 +203,4 @@ } } ] -} +} \ No newline at end of file diff --git a/framework/base/src/api/managed_types/const_handles.rs b/framework/base/src/api/managed_types/const_handles.rs index 283d9c55c6..50b418ec93 100644 --- a/framework/base/src/api/managed_types/const_handles.rs +++ b/framework/base/src/api/managed_types/const_handles.rs @@ -8,7 +8,7 @@ pub const UNINITIALIZED_HANDLE: RawHandle = i32::MAX; /// WARNING! With the current VM this still needs to be initialized before use. pub const BIG_INT_CONST_ZERO: RawHandle = -10; -pub const CALL_VALUE_EGLD: RawHandle = -11; +pub const CALL_VALUE_EGLD: RawHandle = -11; // useful pub const CALL_VALUE_SINGLE_ESDT: RawHandle = -13; pub const BIG_INT_TEMPORARY_1: RawHandle = -14; @@ -17,7 +17,7 @@ pub const BIG_FLOAT_TEMPORARY: RawHandle = -16; /// WARNING! With the current VM this still needs to be initialized before use. pub const MBUF_CONST_EMPTY: RawHandle = -20; -pub const CALL_VALUE_MULTI_ESDT: RawHandle = -21; +pub const CALL_VALUE_MULTI_ESDT: RawHandle = -21; // useful pub const CALL_VALUE_SINGLE_ESDT_TOKEN_NAME: RawHandle = -22; pub const CALLBACK_CLOSURE_ARGS_BUFFER: RawHandle = -23; pub const MBUF_TEMPORARY_1: RawHandle = -25; 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..9aad78288d 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", @@ -41,14 +41,17 @@ "tokenIdentifier": "str:OTHERTOK-123456", "value": "400" }, + { + "tokenIdentifier": "str:EGLD-000000", + "value": "500" + }, { "tokenIdentifier": "str:NFT-123456", "nonce": "5", "value": "10" } ], - "gasLimit": "0x100000000", - "gasPrice": "0x01" + "gasLimit": "0x100000000" } }, { @@ -57,7 +60,7 @@ "accounts": { "address:A": { "nonce": "1", - "balance": "0xf00000000", + "balance": "999999500", "esdt": { "str:TOK-123456": "50", "str:OTHERTOK-123456": "100", @@ -75,6 +78,7 @@ }, "address:B": { "nonce": "0", + "balance": "500", "esdt": { "str:TOK-123456": "100", "str:OTHERTOK-123456": "400", @@ -93,4 +97,4 @@ } } ] -} +} \ No newline at end of file diff --git a/framework/scenario/tests/scenarios_self_go_test.rs b/framework/scenario/tests/scenarios_self_go_test.rs new file mode 100644 index 0000000000..87bb7ae7c5 --- /dev/null +++ b/framework/scenario/tests/scenarios_self_go_test.rs @@ -0,0 +1,181 @@ +use multiversx_sc_scenario::*; + +// These tests don't really test any contract, but the testing framework itself. + +fn world() -> ScenarioWorld { + ScenarioWorld::vm_go() +} + +/// Checks that externalSteps work fine. +#[test] +fn external_steps_go() { + world().run("tests/scenarios-self/external_steps/external_steps.scen.json"); +} + +#[test] +#[should_panic] +fn set_account_addr_len_err1_go() { + world().run("tests/scenarios-self/set-check/set-account-addr-len.err1.json"); +} + +#[test] +#[should_panic] +fn set_account_addr_len_err2_go() { + world().run("tests/scenarios-self/set-check/set-account-addr-len.err2.json"); +} + +#[test] +#[should_panic] +fn set_account_sc_addr_err1_go() { + world().run("tests/scenarios-self/set-check/set-account-sc-addr.err1.json"); +} + +#[test] +#[should_panic] +fn set_account_sc_addr_err2_go() { + world().run("tests/scenarios-self/set-check/set-account-sc-addr.err2.json"); +} + +#[test] +#[should_panic] +fn set_account_sc_addr_err3_go() { + world().run("tests/scenarios-self/set-check/set-account-sc-addr.err3.json"); +} + +#[test] +#[should_panic] +fn set_check_balance_err_go() { + world().run("tests/scenarios-self/set-check/set-check-balance.err.json"); +} + +#[test] +fn set_check_balance_go() { + world().run("tests/scenarios-self/set-check/set-check-balance.scen.json"); +} + +#[test] +#[should_panic] +fn set_check_code_err_go() { + world().run("tests/scenarios-self/set-check/set-check-code.err.json"); +} + +#[test] +fn set_check_code() { + world().run("tests/scenarios-self/set-check/set-check-code.scen.json"); +} + +#[test] +#[should_panic] +fn set_check_codemetadata_err_go() { + world().run("tests/scenarios-self/set-check/set-check-codemetadata.err.json"); +} + +#[test] +fn set_check_codemetadata() { + world().run("tests/scenarios-self/set-check/set-check-codemetadata.scen.json"); +} + +#[test] +#[should_panic] +fn set_check_esdt_err_go() { + world().run("tests/scenarios-self/set-check/set-check-esdt.err1.json"); +} + +#[test] +fn set_check_esdt_go() { + world().run("tests/scenarios-self/set-check/set-check-esdt.scen.json"); +} + +#[test] +#[should_panic] +fn set_check_nonce_err_go() { + world().run("tests/scenarios-self/set-check/set-check-nonce.err.json"); +} + +#[test] +fn set_check_nonce_go() { + world().run("tests/scenarios-self/set-check/set-check-nonce.scen.json"); +} + +#[test] +#[should_panic] +fn set_check_storage_err1_go() { + world().run("tests/scenarios-self/set-check/set-check-storage.err1.json"); +} + +#[test] +#[should_panic] +fn set_check_storage_err2_go() { + world().run("tests/scenarios-self/set-check/set-check-storage.err2.json"); +} + +#[test] +#[should_panic] +fn set_check_storage_err3_go() { + world().run("tests/scenarios-self/set-check/set-check-storage.err3.json"); +} + +#[test] +#[should_panic] +fn set_check_storage_err4_go() { + world().run("tests/scenarios-self/set-check/set-check-storage.err4.json"); +} + +#[test] +#[should_panic] +fn set_check_storage_err5_go() { + world().run("tests/scenarios-self/set-check/set-check-storage.err5.json"); +} + +#[test] +fn set_check_storage_go() { + world().run("tests/scenarios-self/set-check/set-check-storage.scen.json"); +} + +#[test] +#[should_panic] +fn set_check_username_err_go() { + world().run("tests/scenarios-self/set-check/set-check-username.err.json"); +} + +#[test] +fn set_check_username_go() { + world().run("tests/scenarios-self/set-check/set-check-username.scen.json"); +} + +#[test] +fn builtin_func_esdt_transfer() { + world().run("tests/scenarios-self/builtin-func-esdt-transfer.scen.json"); +} + +#[test] +#[should_panic] +fn esdt_non_zero_balance_check_err_go() { + world().run("tests/scenarios-self/esdt-non-zero-balance-check-err.scen.json"); +} + +#[test] +#[should_panic] +fn esdt_zero_balance_check_err_go() { + world().run("tests/scenarios-self/esdt-zero-balance-check-err.scen.json"); +} + +#[test] +fn multi_transfer_esdt_go() { + world().run("tests/scenarios-self/multi-transfer-esdt.scen.json"); +} + +#[test] +fn transfer_egld_go() { + world().run("tests/scenarios-self/transfer-egld.scen.json"); +} + +#[test] +fn transfer_esdt_go() { + world().run("tests/scenarios-self/transfer-esdt.scen.json"); +} + +#[test] +fn validator_reward_go() { + world().run("tests/scenarios-self/validatorReward.scen.json"); +} diff --git a/framework/scenario/tests/scenarios_self_test.rs b/framework/scenario/tests/scenarios_self_rs_test.rs similarity index 100% rename from framework/scenario/tests/scenarios_self_test.rs rename to framework/scenario/tests/scenarios_self_rs_test.rs From e8660384d9c5d80cecb74974ec8ac532eb611556 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Mon, 2 Dec 2024 12:41:24 +0200 Subject: [PATCH 5/5] cleanup --- framework/base/src/api/managed_types/const_handles.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/base/src/api/managed_types/const_handles.rs b/framework/base/src/api/managed_types/const_handles.rs index 50b418ec93..283d9c55c6 100644 --- a/framework/base/src/api/managed_types/const_handles.rs +++ b/framework/base/src/api/managed_types/const_handles.rs @@ -8,7 +8,7 @@ pub const UNINITIALIZED_HANDLE: RawHandle = i32::MAX; /// WARNING! With the current VM this still needs to be initialized before use. pub const BIG_INT_CONST_ZERO: RawHandle = -10; -pub const CALL_VALUE_EGLD: RawHandle = -11; // useful +pub const CALL_VALUE_EGLD: RawHandle = -11; pub const CALL_VALUE_SINGLE_ESDT: RawHandle = -13; pub const BIG_INT_TEMPORARY_1: RawHandle = -14; @@ -17,7 +17,7 @@ pub const BIG_FLOAT_TEMPORARY: RawHandle = -16; /// WARNING! With the current VM this still needs to be initialized before use. pub const MBUF_CONST_EMPTY: RawHandle = -20; -pub const CALL_VALUE_MULTI_ESDT: RawHandle = -21; // useful +pub const CALL_VALUE_MULTI_ESDT: RawHandle = -21; pub const CALL_VALUE_SINGLE_ESDT_TOKEN_NAME: RawHandle = -22; pub const CALLBACK_CLOSURE_ARGS_BUFFER: RawHandle = -23; pub const MBUF_TEMPORARY_1: RawHandle = -25;