Skip to content

Commit 897cd2d

Browse files
Merge pull request #1946 from multiversx/send-to-non-existent-address
Sync with scenario v1.5.0
2 parents 251ed83 + 80750a9 commit 897cd2d

16 files changed

+311
-22
lines changed

.github/workflows/actions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
with:
1919
rust-toolchain: 1.85
2020
path-to-sc-meta: framework/meta
21-
mx-scenario-go-version: v3.0.0
21+
mx-scenario-go-version: v4.0.0
2222
enable-interactor-tests: true
2323
coverage-args: --ignore-filename-regex='meta/src' --ignore-filename-regex='wasm-adapter' --ignore-filename-regex='benchmarks/' --ignore-filename-regex='tests/' --output ./coverage.md
2424
secrets:

.github/workflows/template-test-current.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
run: |
2929
cargo install wasm-opt
3030
cargo install --path framework/meta
31-
sc-meta install mx-scenario-go --tag v3.0.0
31+
sc-meta install mx-scenario-go --tag v4.0.0
3232
3333
which wasm-opt
3434
which mx-scenario-go

.github/workflows/template-test-released.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
run: |
2929
cargo install wasm-opt
3030
cargo install --path framework/meta
31-
sc-meta install mx-scenario-go --tag v3.0.0
31+
sc-meta install mx-scenario-go --tag v4.0.0
3232
3333
which wasm-opt
3434
which mx-scenario-go

contracts/feature-tests/basic-features/interact/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ path = "src/bf_interact.rs"
1616
clap = { version = "4.4.7", features = ["derive"] }
1717
serde = { version = "1.0", features = ["derive"] }
1818
tokio = { version = "1.24" }
19-
toml = "0.8.6"
2019
serial_test = { version = "3.2.0" }
20+
toml = "0.8.6"
2121
system-sc-interact = { path = "../../../../tools/interactor-system-func-calls" }
2222

2323
[dependencies.basic-features]

contracts/feature-tests/basic-features/interact/tests/bf_interact_cs_test.rs

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
use basic_features_interact::{BasicFeaturesInteract, Config};
2-
use multiversx_sc_snippets::imports::{
3-
BigUint, EgldDecimals, EsdtLocalRole, EsdtTokenType, ManagedBuffer, ManagedDecimal,
4-
ManagedOption, ManagedVec, RustBigUint, StaticApi,
2+
use multiversx_sc_snippets::{
3+
imports::{
4+
BigUint, ESDTSystemSCAddress, ESDTSystemSCProxy, EgldDecimals, EsdtLocalRole,
5+
EsdtTokenPayment, EsdtTokenType, FungibleTokenProperties, ManagedBuffer, ManagedDecimal,
6+
ManagedOption, ManagedVec, ReturnsNewTokenIdentifier, RustBigUint, StaticApi,
7+
TokenIdentifier,
8+
},
9+
test_wallets, InteractorRunAsync,
510
};
611
use serial_test::serial;
712
use system_sc_interact::SysFuncCallsInteract;
@@ -35,6 +40,60 @@ async fn simulator_basic_features_test() {
3540
}
3641

3742
#[tokio::test]
43+
#[serial]
44+
#[cfg_attr(not(feature = "chain-simulator-tests"), ignore)]
45+
async fn send_esdt_to_non_existent_address_test() {
46+
let registered_wallet_address = test_wallets::mike().to_address();
47+
let not_registered_wallet_address = test_wallets::alice().to_address();
48+
49+
let mut chain_simulator_interact =
50+
BasicFeaturesInteract::init(Config::chain_simulator_config()).await;
51+
52+
let token = chain_simulator_interact
53+
.interactor
54+
.tx()
55+
.from(&registered_wallet_address)
56+
.to(ESDTSystemSCAddress)
57+
.gas(100_000_000u64)
58+
.typed(ESDTSystemSCProxy)
59+
.issue_fungible(
60+
BigUint::from(50000000000000000u64),
61+
"test",
62+
"TEST",
63+
100u16,
64+
FungibleTokenProperties {
65+
num_decimals: 0usize,
66+
can_freeze: true,
67+
can_wipe: true,
68+
can_pause: true,
69+
can_mint: true,
70+
can_burn: true,
71+
can_change_owner: true,
72+
can_upgrade: true,
73+
can_add_special_roles: true,
74+
},
75+
)
76+
.returns(ReturnsNewTokenIdentifier)
77+
.run()
78+
.await;
79+
80+
// send to not registered address
81+
chain_simulator_interact
82+
.interactor
83+
.tx()
84+
.from(&registered_wallet_address)
85+
.to(&not_registered_wallet_address)
86+
.esdt(EsdtTokenPayment::new(
87+
TokenIdentifier::from_esdt_bytes(token.clone()),
88+
1,
89+
BigUint::from(10u16),
90+
))
91+
.run()
92+
.await;
93+
}
94+
95+
#[tokio::test]
96+
#[serial]
3897
#[ignore = "signature verification is currently unavailable"]
3998
async fn simulator_crypto_test() {
4099
let mut bf_interact = BasicFeaturesInteract::init(Config::chain_simulator_config()).await;
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"comment": "simple ESDT transfer to nonexistent account, no SC",
3+
"steps": [
4+
{
5+
"step": "setState",
6+
"accounts": {
7+
"address:A": {
8+
"nonce": "0",
9+
"balance": "0x1000000000",
10+
"esdt": {
11+
"str:TOK-123456": "150"
12+
}
13+
}
14+
}
15+
},
16+
{
17+
"step": "transfer",
18+
"id": "1",
19+
"tx": {
20+
"from": "address:A",
21+
"to": "address:B",
22+
"esdtValue": [
23+
{
24+
"tokenIdentifier": "str:TOK-123456",
25+
"value": "100"
26+
}
27+
],
28+
"gasLimit": "0x100000000",
29+
"gasPrice": "0x01"
30+
}
31+
},
32+
{
33+
"step": "checkState",
34+
"id": "check-1",
35+
"comment": "check after tx 1",
36+
"accounts": {
37+
"address:A": {
38+
"nonce": "1",
39+
"balance": "0xf00000000",
40+
"esdt": {
41+
"str:TOK-123456": "50"
42+
},
43+
"storage": {},
44+
"code": ""
45+
},
46+
"address:B": {
47+
"nonce": "0",
48+
"esdt": {
49+
"str:TOK-123456": "100"
50+
},
51+
"storage": {},
52+
"code": ""
53+
}
54+
}
55+
},
56+
{
57+
"step": "transfer",
58+
"id": "2",
59+
"tx": {
60+
"from": "address:A",
61+
"to": "address:B",
62+
"esdtValue": [
63+
{
64+
"tokenIdentifier": "str:TOK-123456",
65+
"value": "50"
66+
}
67+
],
68+
"gasLimit": "0x100000000",
69+
"gasPrice": "0x01"
70+
}
71+
},
72+
{
73+
"step": "checkState",
74+
"id": "check-2",
75+
"comment": "check after tx 2",
76+
"accounts": {
77+
"address:A": {
78+
"nonce": "2",
79+
"balance": "0xe00000000",
80+
"esdt": {
81+
"str:TOK-123456": "0"
82+
},
83+
"storage": {},
84+
"code": ""
85+
},
86+
"address:B": {
87+
"nonce": "0",
88+
"esdt": {
89+
"str:TOK-123456": "150"
90+
},
91+
"storage": {},
92+
"code": ""
93+
}
94+
}
95+
}
96+
]
97+
}

contracts/feature-tests/basic-features/tests/basic_features_scenario_go_test.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,11 @@ fn small_num_overflow_go() {
338338
world().run("scenarios/small_num_overflow.scen.json");
339339
}
340340

341+
#[test]
342+
fn send_esdt_to_nonexisting_account_go() {
343+
world().run("scenarios/send_esdt_to_nonexisting_account.scen.json");
344+
}
345+
341346
#[test]
342347
fn storage_big_int_go() {
343348
world().run("scenarios/storage_big_int.scen.json");

contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ fn small_num_overflow_rs() {
360360
world().run("scenarios/small_num_overflow.scen.json");
361361
}
362362

363+
#[test]
364+
#[ignore = "unsupported"]
365+
fn send_esdt_to_nonexisting_account_rs() {
366+
world().run("scenarios/send_esdt_to_nonexisting_account.scen.json");
367+
}
368+
363369
#[test]
364370
fn storage_big_int_rs() {
365371
world().run("scenarios/storage_big_int.scen.json");

contracts/feature-tests/payable-features/interactor/src/payable_interactor.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ pub async fn adder_cli() {
2626
Some(payable_interactor_cli::InteractCliCommand::AllTransfers) => {
2727
basic_interact.check_all_transfers().await;
2828
},
29+
Some(payable_interactor_cli::InteractCliCommand::MultiTransferWithOneEGLD) => {
30+
basic_interact
31+
.check_multi_transfer_only_egld_transfer()
32+
.await;
33+
},
2934
None => {},
3035
}
3136
}
@@ -70,7 +75,27 @@ impl PayableInteract {
7075
.await;
7176

7277
println!("new address: {new_address}");
73-
self.state.set_adder_address(new_address);
78+
self.state.set_payable_features_address(new_address);
79+
}
80+
81+
pub async fn check_multi_transfer_only_egld_transfer(&mut self) {
82+
let mut payment = MultiEgldOrEsdtPayment::new();
83+
payment.push(EgldOrEsdtTokenPayment::egld_payment(1_0000u64.into()));
84+
85+
let result = self
86+
.interactor
87+
.tx()
88+
.from(&self.wallet_address)
89+
.to(self.state.current_payable_features_address())
90+
.gas(6_000_000u64)
91+
.typed(payable_features_proxy::PayableFeaturesProxy)
92+
.payable_all_transfers()
93+
.payment(payment)
94+
.returns(ReturnsResult)
95+
.run()
96+
.await;
97+
98+
println!("Result: {result:?}");
7499
}
75100

76101
pub async fn check_all_transfers(&mut self) {
@@ -82,7 +107,7 @@ impl PayableInteract {
82107
.interactor
83108
.tx()
84109
.from(&self.wallet_address)
85-
.to(self.state.current_adder_address())
110+
.to(self.state.current_payable_features_address())
86111
.gas(6_000_000u64)
87112
.typed(payable_features_proxy::PayableFeaturesProxy)
88113
.payable_all_transfers()

contracts/feature-tests/payable-features/interactor/src/payable_interactor_cli.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ pub enum InteractCliCommand {
1616
Deploy,
1717
#[command(name = "at", about = "Check all transfers")]
1818
AllTransfers,
19+
#[command(name = "mt", about = "Check multi transfer with one EGLD")]
20+
MultiTransferWithOneEGLD,
1921
}

0 commit comments

Comments
 (0)