Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

promises error test #1830

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
{
"steps": [
{
"step": "setState",
"accounts": {
"address:a_user": {
"nonce": "0",
"balance": "2000"
},
"sc:promises": {
"nonce": "0",
"balance": "0",
"esdt": {
"str:FWD-TOKEN": "1000",
"str:NFT-123456": {
"instances": [
{
"nonce": "1",
"balance": "1"
}
]
},
"str:SFT-456789": {
"instances": [
{
"nonce": "3",
"balance": "10"
}
]
}
},
"code": "mxsc:../promises-features/output/promises-features.mxsc.json"
},
"sc:vault": {
"nonce": "0",
"balance": "0",
"code": "mxsc:../vault/output/vault.mxsc.json"
}
}
},
{
"step": "scCall",
"id": "multi-transfer-through-promises",
"tx": {
"from": "address:a_user",
"to": "sc:promises",
"function": "promise_raw_multi_transfer",
"arguments": [
"sc:vault",
"str:explicit_panic",
"5,000",
"str:FWD-TOKEN",
"0",
"500",
"str:NFT-123456",
"1",
"1",
"str:SFT-456789",
"3",
"6"
],
"gasLimit": "100,000,000",
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "0",
"message": "",
"logs": [
{
"address": "sc:promises",
"endpoint": "str:MultiESDTNFTTransfer",
"topics": [
"str:FWD-TOKEN",
"0",
"500",
"str:NFT-123456",
"1",
"1",
"str:SFT-456789",
"3",
"6",
"sc:vault"
],
"data": [
"str:AsyncCall",
"str:MultiESDTNFTTransfer",
"sc:vault",
"3",
"str:FWD-TOKEN",
"0",
"500",
"str:NFT-123456",
"1",
"1",
"str:SFT-456789",
"3",
"6",
"str:explicit_panic"
]
},
{
"address": "sc:vault",
"endpoint": "str:transferValueOnly",
"topics": [
"",
"sc:promises"
],
"data": [
"str:AsyncCallback",
"str:the_one_callback",
"0x04",
"str:explicit panic"
]
},
{
"address": "sc:promises",
"endpoint": "str:the_one_callback",
"topics": [
"str:async_call_event_callback",
"2001",
"2002"
],
"data": [
[
"nested:0x04",
"nested:str:explicit panic"
]
]
},
{
"address": "address:a_user",
"endpoint": "str:internalVMErrors",
"topics": [
"sc:promises",
"str:promise_raw_multi_transfer"
],
"data": [
"*"
]
}
]
}
},
{
"step": "checkState",
"accounts": {
"address:a_user": {
"nonce": "*",
"balance": "2000"
},
"sc:promises": {
"nonce": "0",
"balance": "0",
"esdt": {
"str:FWD-TOKEN": "1000",
"str:NFT-123456": {
"instances": [
{
"nonce": "1",
"balance": "1"
}
]
},
"str:SFT-456789": {
"instances": [
{
"nonce": "3",
"balance": "10"
}
]
}
},
"code": "mxsc:../promises-features/output/promises-features.mxsc.json"
},
"sc:vault": {
"nonce": "0",
"balance": "0",
"code": "mxsc:../vault/output/vault.mxsc.json"
}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,11 @@ fn promises_multi_transfer_go() {
world().run("scenarios/promises_multi_transfer.scen.json");
}

#[test]
fn promises_multi_transfer_err_go() {
world().run("scenarios/promises_multi_transfer_err.scen.json");
}

#[test]
fn promises_single_transfer_go() {
world().run("scenarios/promises_single_transfer.scen.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,12 @@ fn promises_multi_transfer_rs() {
world().run("scenarios/promises_multi_transfer.scen.json");
}

#[test]
#[ignore = "TODO - some log is missing"]
fn promises_multi_transfer_err_rs() {
world().run("scenarios/promises_multi_transfer_err.scen.json");
}

#[test]
#[ignore = "gas"]
fn promises_single_transfer_rs() {
Expand Down
6 changes: 6 additions & 0 deletions contracts/feature-tests/composability/vault/src/vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ pub trait Vault {
self.tx().to(ToCaller).payment(new_tokens).transfer();
}

#[endpoint]
#[payable("*")]
fn explicit_panic(&self) {
sc_panic!("explicit panic");
}

#[event("accept_funds")]
fn accept_funds_event(
&self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
////////////////////////////////////////////////////

// Init: 1
// Endpoints: 16
// Endpoints: 17
// Async Callback (empty): 1
// Total number of exported functions: 18
// Total number of exported functions: 19

#![no_std]

Expand All @@ -29,6 +29,7 @@ multiversx_sc_wasm_adapter::endpoints! {
retrieve_funds => retrieve_funds
retrieve_multi_funds_async => retrieve_multi_funds_async
burn_and_create_retrieve_async => burn_and_create_retrieve_async
explicit_panic => explicit_panic
get_owner_address => get_owner_address
call_counts => call_counts
num_called_retrieve_funds_promises => num_called_retrieve_funds_promises
Expand Down
5 changes: 3 additions & 2 deletions contracts/feature-tests/composability/vault/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

// Init: 1
// Upgrade: 1
// Endpoints: 15
// Endpoints: 16
// Async Callback (empty): 1
// Total number of exported functions: 18
// Total number of exported functions: 19

#![no_std]

Expand All @@ -31,6 +31,7 @@ multiversx_sc_wasm_adapter::endpoints! {
retrieve_funds => retrieve_funds
retrieve_multi_funds_async => retrieve_multi_funds_async
burn_and_create_retrieve_async => burn_and_create_retrieve_async
explicit_panic => explicit_panic
get_owner_address => get_owner_address
call_counts => call_counts
num_called_retrieve_funds_promises => num_called_retrieve_funds_promises
Expand Down
Loading