Skip to content

Commit 3fda3bb

Browse files
features test - send tx with message
1 parent 2d68bc3 commit 3fda3bb

File tree

2 files changed

+57
-5
lines changed

2 files changed

+57
-5
lines changed

contracts/feature-tests/basic-features/mandos/send_tx.scen.json

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"step": "setState",
66
"accounts": {
77
"address:features_contract": {
8-
"nonce": "0",
9-
"balance": "100",
8+
"nonce": "1000",
9+
"balance": "200",
1010
"storage": {},
1111
"code": "file:../output/basic-features.wasm"
1212
},
@@ -20,7 +20,7 @@
2020
},
2121
{
2222
"step": "scCall",
23-
"txId": "1",
23+
"txId": "not-enough",
2424
"tx": {
2525
"from": "address:an_account",
2626
"to": "address:features_contract",
@@ -39,6 +39,49 @@
3939
"message": "str:failed transfer (insufficient funds)",
4040
"logs": []
4141
}
42+
},
43+
{
44+
"step": "scCall",
45+
"txId": "without-message",
46+
"tx": {
47+
"from": "address:an_account",
48+
"to": "address:features_contract",
49+
"value": "0",
50+
"function": "send_tx_endpoint",
51+
"arguments": [
52+
"address:an_account",
53+
"100"
54+
],
55+
"gasLimit": "0x100000",
56+
"gasPrice": "0"
57+
},
58+
"expect": {
59+
"out": [],
60+
"status": "",
61+
"logs": []
62+
}
63+
},
64+
{
65+
"step": "scCall",
66+
"txId": "with-message",
67+
"tx": {
68+
"from": "address:an_account",
69+
"to": "address:features_contract",
70+
"value": "0",
71+
"function": "send_tx_endpoint",
72+
"arguments": [
73+
"address:an_account",
74+
"100",
75+
"str:send tx message here"
76+
],
77+
"gasLimit": "0x100000",
78+
"gasPrice": "0"
79+
},
80+
"expect": {
81+
"out": [],
82+
"status": "",
83+
"logs": []
84+
}
4285
}
4386
]
4487
}

contracts/feature-tests/basic-features/src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,17 @@ pub trait BasicFeatures {
407407
// SEND TX
408408

409409
#[endpoint]
410-
fn send_tx_endpoint(&self, to: &Address, amount: &BigUint) {
411-
self.send_tx(to, amount, &[]);
410+
fn send_tx_endpoint(
411+
&self,
412+
to: &Address,
413+
amount: &BigUint,
414+
#[var_args] opt_data: OptionalArg<BoxedBytes>,
415+
) {
416+
let data = match &opt_data {
417+
OptionalArg::Some(data) => data.as_slice(),
418+
OptionalArg::None => &[],
419+
};
420+
self.send_tx(to, amount, data);
412421
}
413422

414423
// BLOCK INFO

0 commit comments

Comments
 (0)