From 817a81306e66b70a7cf40779010e05afe8593cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Fri, 11 Oct 2024 16:24:39 +0300 Subject: [PATCH 1/4] bridge-proxy: Add unit tests --- .../tests/bridge_proxy_blackbox_test.rs | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs index 9da10410..0d40509d 100644 --- a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs +++ b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs @@ -503,6 +503,52 @@ fn bridge_proxy_wrong_formatting_sc_call_test() { test.deploy_crowdfunding(); test.config_bridge(); + // let eth_tx = EthTransaction { + // from: EthAddress { + // raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"), + // }, + // to: ManagedAddress::from(NO_INIT_SC_ADDRESS.eval_to_array()), + // token_id: BRIDGE_TOKEN_ID.into(), + // amount: BigUint::from(500u64), + // tx_nonce: 1u64, + // call_data: ManagedOption::none(), + // }; + + // // Destination is not an initialized contract + // test.world + // .tx() + // .from(MULTI_TRANSFER_ADDRESS) + // .to(BRIDGE_PROXY_ADDRESS) + // .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) + // .deposit(ð_tx) + // .egld_or_single_esdt( + // &EgldOrEsdtTokenIdentifier::esdt(BRIDGE_TOKEN_ID), + // 0, + // &BigUint::from(500u64), + // ) + // .run(); + + // test.world + // .query() + // .to(BRIDGE_PROXY_ADDRESS) + // .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) + // .get_pending_transaction_by_id(1u32) + // .returns(ExpectValue(eth_tx)) + // .run(); + + // test.world + // .tx() + // .from(OWNER_ADDRESS) + // .to(BRIDGE_PROXY_ADDRESS) + // .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) + // .execute(1u32) + // .run(); + + // // Refund: Funds are transfered to BridgedTokensWrapper + // test.world + // .check_account(BRIDGED_TOKENS_WRAPPER_ADDRESS) + // .esdt_balance(BRIDGE_TOKEN_ID, BigUint::from(500u64)); + let mut args = ManagedVec::new(); let call_data: CallData = CallData { @@ -514,6 +560,7 @@ fn bridge_proxy_wrong_formatting_sc_call_test() { let call_data: ManagedBuffer = ManagedSerializer::new().top_encode_to_managed_buffer(&call_data); + // No endpoint let eth_tx = EthTransaction { from: EthAddress { raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"), @@ -522,7 +569,7 @@ fn bridge_proxy_wrong_formatting_sc_call_test() { token_id: BRIDGE_TOKEN_ID.into(), amount: BigUint::from(500u64), tx_nonce: 1u64, - call_data: ManagedOption::none(), + call_data: ManagedOption::some(call_data), }; test.world From 04ad36c1f13b7ea11055aeecc61f90f20988b839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Costin=20Caraba=C8=99?= Date: Mon, 14 Oct 2024 21:45:15 +0300 Subject: [PATCH 2/4] Add blackbox tests for multisig and bridge-proxy --- .../tests/bridge_proxy_blackbox_test.rs | 224 ++++++++++++++---- multisig/tests/multisig_blackbox_test.rs | 165 ++++++++++++- 2 files changed, 339 insertions(+), 50 deletions(-) diff --git a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs index 0d40509d..1d9780f4 100644 --- a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs +++ b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs @@ -44,6 +44,8 @@ const BRIDGE_TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("BRIDGE-12 const WBRIDGE_TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("WBRIDGE-123456"); const GAS_LIMIT: u64 = 10_000_000; +const TOO_SMALL_GAS_LIMIT: u64 = 1_000_000; + const CF_DEADLINE: u64 = 7 * 24 * 60 * 60; // 1 week in seconds const OWNER_ADDRESS: TestAddress = TestAddress::new("owner"); @@ -503,56 +505,115 @@ fn bridge_proxy_wrong_formatting_sc_call_test() { test.deploy_crowdfunding(); test.config_bridge(); - // let eth_tx = EthTransaction { - // from: EthAddress { - // raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"), - // }, - // to: ManagedAddress::from(NO_INIT_SC_ADDRESS.eval_to_array()), - // token_id: BRIDGE_TOKEN_ID.into(), - // amount: BigUint::from(500u64), - // tx_nonce: 1u64, - // call_data: ManagedOption::none(), - // }; - - // // Destination is not an initialized contract - // test.world - // .tx() - // .from(MULTI_TRANSFER_ADDRESS) - // .to(BRIDGE_PROXY_ADDRESS) - // .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) - // .deposit(ð_tx) - // .egld_or_single_esdt( - // &EgldOrEsdtTokenIdentifier::esdt(BRIDGE_TOKEN_ID), - // 0, - // &BigUint::from(500u64), - // ) - // .run(); + let eth_tx = EthTransaction { + from: EthAddress { + raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"), + }, + to: ManagedAddress::from(NO_INIT_SC_ADDRESS.eval_to_array()), + token_id: BRIDGE_TOKEN_ID.into(), + amount: BigUint::from(500u64), + tx_nonce: 1u64, + call_data: ManagedOption::none(), + }; - // test.world - // .query() - // .to(BRIDGE_PROXY_ADDRESS) - // .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) - // .get_pending_transaction_by_id(1u32) - // .returns(ExpectValue(eth_tx)) - // .run(); + let amount = BigUint::from(500u64); + // Destination is not an initialized contract + test.world + .tx() + .from(MULTI_TRANSFER_ADDRESS) + .to(BRIDGE_PROXY_ADDRESS) + .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) + .deposit(ð_tx) + .egld_or_single_esdt( + &EgldOrEsdtTokenIdentifier::esdt(BRIDGE_TOKEN_ID), + 0, + &amount, + ) + .run(); - // test.world - // .tx() - // .from(OWNER_ADDRESS) - // .to(BRIDGE_PROXY_ADDRESS) - // .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) - // .execute(1u32) - // .run(); - - // // Refund: Funds are transfered to BridgedTokensWrapper - // test.world - // .check_account(BRIDGED_TOKENS_WRAPPER_ADDRESS) - // .esdt_balance(BRIDGE_TOKEN_ID, BigUint::from(500u64)); + test.world + .query() + .to(BRIDGE_PROXY_ADDRESS) + .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) + .get_pending_transaction_by_id(1u32) + .returns(ExpectValue(eth_tx)) + .run(); + + test.world + .tx() + .from(OWNER_ADDRESS) + .to(BRIDGE_PROXY_ADDRESS) + .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) + .execute(1u32) + .run(); + // Refund: Funds are transfered to BridgedTokensWrapper + test.world + .check_account(BRIDGED_TOKENS_WRAPPER_ADDRESS) + .esdt_balance(BRIDGE_TOKEN_ID, amount.clone()); + + // Wrong endpoint for callData let mut args = ManagedVec::new(); + let call_data: CallData = CallData { + endpoint: ManagedBuffer::from(b"nofunc"), + gas_limit: GAS_LIMIT, + args: ManagedOption::some(args), + }; + + let call_data: ManagedBuffer = + ManagedSerializer::new().top_encode_to_managed_buffer(&call_data); + + let eth_tx = EthTransaction { + from: EthAddress { + raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"), + }, + to: ManagedAddress::from(CROWDFUNDING_ADDRESS.eval_to_array()), + token_id: BRIDGE_TOKEN_ID.into(), + amount: amount.clone(), + tx_nonce: 2u64, + call_data: ManagedOption::some(call_data), + }; + + test.world + .tx() + .from(MULTI_TRANSFER_ADDRESS) + .to(BRIDGE_PROXY_ADDRESS) + .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) + .deposit(ð_tx) + .egld_or_single_esdt( + &EgldOrEsdtTokenIdentifier::esdt(BRIDGE_TOKEN_ID), + 0, + &amount, + ) + .run(); + + test.world + .query() + .to(BRIDGE_PROXY_ADDRESS) + .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) + .get_pending_transaction_by_id(2u32) + .returns(ExpectValue(eth_tx)) + .run(); + + test.world + .tx() + .from(OWNER_ADDRESS) + .to(BRIDGE_PROXY_ADDRESS) + .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) + .execute(2u32) + .run(); + + // Refund: Funds are transfered to BridgedTokensWrapper + test.world + .check_account(BRIDGED_TOKENS_WRAPPER_ADDRESS) + .esdt_balance(BRIDGE_TOKEN_ID, amount.clone() * 2u64); + + // Wrong args + let mut args = ManagedVec::new(); + args.push(ManagedBuffer::from(b"wrongargs")); let call_data: CallData = CallData { - endpoint: ManagedBuffer::from("fund"), + endpoint: ManagedBuffer::from(b"fund"), gas_limit: GAS_LIMIT, args: ManagedOption::some(args), }; @@ -560,18 +621,85 @@ fn bridge_proxy_wrong_formatting_sc_call_test() { let call_data: ManagedBuffer = ManagedSerializer::new().top_encode_to_managed_buffer(&call_data); - // No endpoint let eth_tx = EthTransaction { from: EthAddress { raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"), }, - to: ManagedAddress::from(NO_INIT_SC_ADDRESS.eval_to_array()), + to: ManagedAddress::from(CROWDFUNDING_ADDRESS.eval_to_array()), + token_id: BRIDGE_TOKEN_ID.into(), + amount: amount.clone(), + tx_nonce: 3u64, + call_data: ManagedOption::some(call_data), + }; + + test.world + .tx() + .from(MULTI_TRANSFER_ADDRESS) + .to(BRIDGE_PROXY_ADDRESS) + .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) + .deposit(ð_tx) + .egld_or_single_esdt( + &EgldOrEsdtTokenIdentifier::esdt(BRIDGE_TOKEN_ID), + 0, + &amount, + ) + .run(); + + test.world + .query() + .to(BRIDGE_PROXY_ADDRESS) + .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) + .get_pending_transaction_by_id(3u32) + .returns(ExpectValue(eth_tx)) + .run(); + + test.world + .tx() + .from(OWNER_ADDRESS) + .to(BRIDGE_PROXY_ADDRESS) + .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) + .execute(3u32) + .run(); + + // Refund: Funds are transfered to BridgedTokensWrapper + test.world + .check_account(BRIDGED_TOKENS_WRAPPER_ADDRESS) + .esdt_balance(BRIDGE_TOKEN_ID, amount * 3u64); +} + +#[test] +fn bridge_proxy_too_small_gas_sc_call_test() { + let mut test = BridgeProxyTestState::new(); + + test.world.start_trace(); + + test.deploy_bridge_proxy(); + test.deploy_crowdfunding(); + test.config_bridge(); + + let mut args = ManagedVec::new(); + let call_data: CallData = CallData { + endpoint: ManagedBuffer::from(b"fund"), + gas_limit: TOO_SMALL_GAS_LIMIT, + args: ManagedOption::some(args), + }; + + let call_data: ManagedBuffer = + ManagedSerializer::new().top_encode_to_managed_buffer(&call_data); + + let eth_tx = EthTransaction { + from: EthAddress { + raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"), + }, + to: ManagedAddress::from(CROWDFUNDING_ADDRESS.eval_to_array()), token_id: BRIDGE_TOKEN_ID.into(), amount: BigUint::from(500u64), tx_nonce: 1u64, call_data: ManagedOption::some(call_data), }; + let amount = BigUint::from(500u64); + // Destination is not an initialized contract test.world .tx() .from(MULTI_TRANSFER_ADDRESS) @@ -581,7 +709,7 @@ fn bridge_proxy_wrong_formatting_sc_call_test() { .egld_or_single_esdt( &EgldOrEsdtTokenIdentifier::esdt(BRIDGE_TOKEN_ID), 0, - &BigUint::from(500u64), + &amount, ) .run(); @@ -604,5 +732,5 @@ fn bridge_proxy_wrong_formatting_sc_call_test() { // Refund: Funds are transfered to BridgedTokensWrapper test.world .check_account(BRIDGED_TOKENS_WRAPPER_ADDRESS) - .esdt_balance(BRIDGE_TOKEN_ID, BigUint::from(500u64)); + .esdt_balance(BRIDGE_TOKEN_ID, amount.clone()); } diff --git a/multisig/tests/multisig_blackbox_test.rs b/multisig/tests/multisig_blackbox_test.rs index e31d8adb..3be4aaf4 100644 --- a/multisig/tests/multisig_blackbox_test.rs +++ b/multisig/tests/multisig_blackbox_test.rs @@ -36,7 +36,10 @@ use sc_proxies::{ multi_transfer_proxy, multisig_proxy, }; use token_module::ProxyTrait as _; -use transaction::{CallData, EthTransaction, EthTxAsMultiValue, TxBatchSplitInFields}; +use transaction::{ + transaction_status::TransactionStatus, CallData, EthTransaction, EthTxAsMultiValue, + TxBatchSplitInFields, +}; const WEGLD_TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("WEGLD-123456"); const ETH_TOKEN_ID: TestTokenIdentifier = TestTokenIdentifier::new("ETH-123456"); @@ -67,6 +70,7 @@ const ORACLE_ADDRESS: TestAddress = TestAddress::new("oracle"); const OWNER_ADDRESS: TestAddress = TestAddress::new("owner"); const USER1_ADDRESS: TestAddress = TestAddress::new("user1"); const USER2_ADDRESS: TestAddress = TestAddress::new("user2"); +const NON_BOARD_MEMEBER_ADDRESS: TestAddress = TestAddress::new("non-board-member"); const RELAYER1_ADDRESS: TestAddress = TestAddress::new("relayer1"); const RELAYER2_ADDRESS: TestAddress = TestAddress::new("relayer2"); @@ -119,7 +123,9 @@ impl MultiTransferTestState { .balance(1_000u64) .account(RELAYER2_ADDRESS) .nonce(1) - .balance(1_000u64); + .balance(1_000u64) + .account(NON_BOARD_MEMEBER_ADDRESS) + .nonce(1); let roles = vec![ "ESDTRoleLocalMint".to_string(), @@ -907,3 +913,158 @@ fn ethereum_to_multiversx_tx_batch_rejected_test() { .move_refund_batch_to_safe_from_child_contract() .run(); } + +#[test] +fn multisig_non_board_member_interaction_test() { + let mut state = MultiTransferTestState::new(); + let token_amount = BigUint::from(76_000_000_000u64); + + state.multisig_deploy(); + state.safe_deploy(Address::zero()); + state.multi_transfer_deploy(); + state.bridge_proxy_deploy(); + state.bridged_tokens_wrapper_deploy(); + state.config_multisig(); + + let eth_tx = EthTxAsMultiValue::::from(( + EthAddress { + raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"), + }, + ManagedAddress::from(USER1_ADDRESS.eval_to_array()), + TokenIdentifier::from(WEGLD_TOKEN_ID), + token_amount.clone(), + 1u64, + ManagedOption::none(), + )); + + let mut transfers: MultiValueEncoded> = + MultiValueEncoded::new(); + transfers.push(eth_tx); + + state + .world + .tx() + .from(NON_BOARD_MEMEBER_ADDRESS) + .to(MULTISIG_ADDRESS) + .typed(multisig_proxy::MultisigProxy) + .propose_multi_transfer_esdt_batch(1u32, transfers.clone()) + .returns(ExpectError(4, "only board members can propose")) + .run(); + + let mut tx_batch_status: MultiValueEncoded = + MultiValueEncoded::::new(); + tx_batch_status.push(TransactionStatus::InProgress); + + state + .world + .tx() + .from(RELAYER1_ADDRESS) + .to(MULTISIG_ADDRESS) + .typed(multisig_proxy::MultisigProxy) + .propose_multi_transfer_esdt_batch(1u32, transfers) + .run(); +} + +#[test] +fn multisig_insuficient_signatures_test() { + let mut state = MultiTransferTestState::new(); + let token_amount = BigUint::from(76_000_000_000u64); + + state.multisig_deploy(); + state.safe_deploy(Address::zero()); + state.multi_transfer_deploy(); + state.bridge_proxy_deploy(); + state.bridged_tokens_wrapper_deploy(); + state.config_multisig(); + + let eth_tx = EthTxAsMultiValue::::from(( + EthAddress { + raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"), + }, + ManagedAddress::from(USER1_ADDRESS.eval_to_array()), + TokenIdentifier::from(WEGLD_TOKEN_ID), + token_amount.clone(), + 1u64, + ManagedOption::none(), + )); + + let mut transfers: MultiValueEncoded> = + MultiValueEncoded::new(); + transfers.push(eth_tx); + + state + .world + .tx() + .from(RELAYER1_ADDRESS) + .to(MULTISIG_ADDRESS) + .typed(multisig_proxy::MultisigProxy) + .propose_multi_transfer_esdt_batch(1u32, transfers) + .run(); + + state + .world + .tx() + .from(RELAYER1_ADDRESS) + .to(MULTISIG_ADDRESS) + .typed(multisig_proxy::MultisigProxy) + .perform_action_endpoint(1usize) + .returns(ExpectError(4, "quorum has not been reached")) + .run(); +} + +#[test] +fn multisig_non_board_member_sign_test() { + let mut state = MultiTransferTestState::new(); + let token_amount = BigUint::from(76_000_000_000u64); + + state.multisig_deploy(); + state.safe_deploy(Address::zero()); + state.multi_transfer_deploy(); + state.bridge_proxy_deploy(); + state.bridged_tokens_wrapper_deploy(); + state.config_multisig(); + + let eth_tx = EthTxAsMultiValue::::from(( + EthAddress { + raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"), + }, + ManagedAddress::from(USER1_ADDRESS.eval_to_array()), + TokenIdentifier::from(WEGLD_TOKEN_ID), + token_amount.clone(), + 1u64, + ManagedOption::none(), + )); + + let mut transfers: MultiValueEncoded> = + MultiValueEncoded::new(); + transfers.push(eth_tx); + + state + .world + .tx() + .from(RELAYER1_ADDRESS) + .to(MULTISIG_ADDRESS) + .typed(multisig_proxy::MultisigProxy) + .propose_multi_transfer_esdt_batch(1u32, transfers) + .run(); + + state + .world + .tx() + .from(NON_BOARD_MEMEBER_ADDRESS) + .to(MULTISIG_ADDRESS) + .typed(multisig_proxy::MultisigProxy) + .sign(1usize) + .returns(ExpectError(4, "only board members can sign")) + .run(); + + state + .world + .tx() + .from(RELAYER1_ADDRESS) + .to(MULTISIG_ADDRESS) + .typed(multisig_proxy::MultisigProxy) + .perform_action_endpoint(1usize) + .returns(ExpectError(4, "quorum has not been reached")) + .run(); +} From 4f8db64d44a7683540e117c0a779e66dea22fd98 Mon Sep 17 00:00:00 2001 From: Eveline Molnar Date: Mon, 4 Nov 2024 23:39:47 +0200 Subject: [PATCH 3/4] fix after merge --- Cargo.lock | 3 ++- .../tests/bridge_proxy_blackbox_test.rs | 13 ++++++----- .../mock-contracts/mock-esdt-safe/Cargo.toml | 11 ++++++---- .../mock-esdt-safe/src/mock_esdt_safe.rs | 22 +++++++++++++++++-- multisig/tests/multisig_blackbox_test.rs | 6 ++--- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a604f13b..868a8f8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -608,9 +608,10 @@ dependencies = [ name = "mock-esdt-safe" version = "0.0.0" dependencies = [ + "eth-address", "multiversx-sc", + "multiversx-sc-modules", "multiversx-sc-scenario", - "num-bigint", ] [[package]] diff --git a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs index 86577192..7fd7dd43 100644 --- a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs +++ b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs @@ -620,7 +620,7 @@ fn bridge_proxy_wrong_formatting_sc_call_test() { .from(MULTI_TRANSFER_ADDRESS) .to(BRIDGE_PROXY_ADDRESS) .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) - .deposit(ð_tx) + .deposit(ð_tx, 1u64) .egld_or_single_esdt( &EgldOrEsdtTokenIdentifier::esdt(BRIDGE_TOKEN_ID), 0, @@ -678,7 +678,7 @@ fn bridge_proxy_wrong_formatting_sc_call_test() { .from(MULTI_TRANSFER_ADDRESS) .to(BRIDGE_PROXY_ADDRESS) .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) - .deposit(ð_tx) + .deposit(ð_tx, 1u64) .egld_or_single_esdt( &EgldOrEsdtTokenIdentifier::esdt(BRIDGE_TOKEN_ID), 0, @@ -714,6 +714,7 @@ fn bridge_proxy_too_small_gas_sc_call_test() { test.world.start_trace(); + test.multisig_deploy(); test.deploy_bridge_proxy(); test.deploy_crowdfunding(); test.config_bridge(); @@ -746,7 +747,7 @@ fn bridge_proxy_too_small_gas_sc_call_test() { .from(MULTI_TRANSFER_ADDRESS) .to(BRIDGE_PROXY_ADDRESS) .typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy) - .deposit(ð_tx) + .deposit(ð_tx, 1u64) .egld_or_single_esdt( &EgldOrEsdtTokenIdentifier::esdt(BRIDGE_TOKEN_ID), 0, @@ -771,7 +772,7 @@ fn bridge_proxy_too_small_gas_sc_call_test() { .run(); // Refund: Funds are transfered to BridgedTokensWrapper - test.world - .check_account(BRIDGED_TOKENS_WRAPPER_ADDRESS) - .esdt_balance(BRIDGE_TOKEN_ID, amount.clone()); + // test.world + // .check_account(BRIDGED_TOKENS_WRAPPER_ADDRESS) + // .esdt_balance(BRIDGE_TOKEN_ID, amount.clone()); } diff --git a/common/mock-contracts/mock-esdt-safe/Cargo.toml b/common/mock-contracts/mock-esdt-safe/Cargo.toml index 68932d4a..b08e4109 100644 --- a/common/mock-contracts/mock-esdt-safe/Cargo.toml +++ b/common/mock-contracts/mock-esdt-safe/Cargo.toml @@ -9,10 +9,13 @@ authors = ["you"] path = "src/mock_esdt_safe.rs" [dependencies.multiversx-sc] -version = "0.53.2" +version = "=0.53.2" -[dev-dependencies] -num-bigint = "0.4" +[dependencies.multiversx-sc-modules] +version = "=0.53.2" [dev-dependencies.multiversx-sc-scenario] -version = "0.53.2" \ No newline at end of file +version = "=0.53.2" + +[dependencies.eth-address] +path = "../../eth-address" \ No newline at end of file diff --git a/common/mock-contracts/mock-esdt-safe/src/mock_esdt_safe.rs b/common/mock-contracts/mock-esdt-safe/src/mock_esdt_safe.rs index 51a6bbe1..991fc205 100644 --- a/common/mock-contracts/mock-esdt-safe/src/mock_esdt_safe.rs +++ b/common/mock-contracts/mock-esdt-safe/src/mock_esdt_safe.rs @@ -1,7 +1,16 @@ #![no_std] +multiversx_sc::imports!(); +multiversx_sc::derive_imports!(); -#[allow(unused_imports)] -use multiversx_sc::imports::*; +use eth_address::EthAddress; + +#[type_abi] +#[derive(TopEncode, TopDecode, NestedEncode, NestedDecode, Clone, ManagedVecItem, PartialEq)] +pub struct RefundInfo { + pub address: ManagedAddress, + pub initial_batch_id: u64, + pub initial_nonce: u64, +} /// An empty contract. To be used as a template when starting a new contract from scratch. #[multiversx_sc::contract] @@ -17,4 +26,13 @@ pub trait MockEsdtSafe { #[upgrade] fn upgrade(&self) {} + + #[payable("*")] + #[endpoint(createTransaction)] + fn create_transaction( + &self, + _to: EthAddress, + _opt_refund_info: OptionalValue>, + ) { + } } diff --git a/multisig/tests/multisig_blackbox_test.rs b/multisig/tests/multisig_blackbox_test.rs index f776cbc5..b297eaf1 100644 --- a/multisig/tests/multisig_blackbox_test.rs +++ b/multisig/tests/multisig_blackbox_test.rs @@ -902,7 +902,7 @@ fn multisig_non_board_member_interaction_test() { let token_amount = BigUint::from(76_000_000_000u64); state.multisig_deploy(); - state.safe_deploy(Address::zero()); + state.safe_deploy(); state.multi_transfer_deploy(); state.bridge_proxy_deploy(); state.bridged_tokens_wrapper_deploy(); @@ -953,7 +953,7 @@ fn multisig_insuficient_signatures_test() { let token_amount = BigUint::from(76_000_000_000u64); state.multisig_deploy(); - state.safe_deploy(Address::zero()); + state.safe_deploy(); state.multi_transfer_deploy(); state.bridge_proxy_deploy(); state.bridged_tokens_wrapper_deploy(); @@ -1000,7 +1000,7 @@ fn multisig_non_board_member_sign_test() { let token_amount = BigUint::from(76_000_000_000u64); state.multisig_deploy(); - state.safe_deploy(Address::zero()); + state.safe_deploy(); state.multi_transfer_deploy(); state.bridge_proxy_deploy(); state.bridged_tokens_wrapper_deploy(); From cb4c3a7875b1b710083442f7638dbeb9402b4514 Mon Sep 17 00:00:00 2001 From: Eveline Molnar Date: Thu, 7 Nov 2024 15:22:29 +0200 Subject: [PATCH 4/4] fix check account --- bridge-proxy/tests/bridge_proxy_blackbox_test.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs index 7fd7dd43..20e287fc 100644 --- a/bridge-proxy/tests/bridge_proxy_blackbox_test.rs +++ b/bridge-proxy/tests/bridge_proxy_blackbox_test.rs @@ -771,8 +771,8 @@ fn bridge_proxy_too_small_gas_sc_call_test() { .execute(1u32) .run(); - // Refund: Funds are transfered to BridgedTokensWrapper - // test.world - // .check_account(BRIDGED_TOKENS_WRAPPER_ADDRESS) - // .esdt_balance(BRIDGE_TOKEN_ID, amount.clone()); + // Refund: Funds are transfered to EsdtSafe + test.world + .check_account(ESDT_SAFE_ADDRESS) + .esdt_balance(BRIDGE_TOKEN_ID, amount.clone()); }