diff --git a/multisig/scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json b/multisig/scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json index 96da5fc0..dcbba67f 100644 --- a/multisig/scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json +++ b/multisig/scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json @@ -88,13 +88,13 @@ "str:WEGLD-123456", "76,000,000,000", "u64:1", - "0x01|u8:4|str:data|u32:20000000|u8:0", + "0x01|u8:4|str:data|u32:5,000,000|u8:0", "0x0102030405060708091011121314151617181920", "sc:egld_esdt_swap", "str:ETH-123456", "76,000,000,000", "u64:2", - "0x01|u8:4|str:data|u32:20000000|u8:0" + "0x01|u8:4|str:data|u32:5,000,000|u8:0" ], "gasLimit": "50,000,000", "gasPrice": "0" @@ -127,7 +127,7 @@ "3-token_id": "nested:str:WEGLD-123456", "4-amount": "biguint:76,000,000,000", "5-tx_id": "u64:1", - "6-call_data": "0x01|u8:4|str:data|u32:20000000|u8:0" + "6-call_data": "0x01|u8:4|str:data|u32:5,000,000|u8:0" }, { "1-from": "0x0102030405060708091011121314151617181920", @@ -135,7 +135,7 @@ "3-token_id": "nested:str:ETH-123456", "4-amount": "biguint:76,000,000,000", "5-tx_id": "u64:2", - "6-call_data": "0x01|u8:4|str:data|u32:20000000|u8:0" + "6-call_data": "0x01|u8:4|str:data|u32:5,000,000|u8:0" } ] }, diff --git a/multisig/src/lib.rs b/multisig/src/lib.rs index d7229b74..d309b413 100644 --- a/multisig/src/lib.rs +++ b/multisig/src/lib.rs @@ -1,13 +1,13 @@ #![no_std] #![allow(clippy::too_many_arguments)] -mod action; -mod multisig_general; -mod queries; -mod setup; -mod storage; -mod user_role; -mod util; +pub mod action; +pub mod multisig_general; +pub mod queries; +pub mod setup; +pub mod storage; +pub mod user_role; +pub mod util; use action::Action; use token_module::{AddressPercentagePair, INVALID_PERCENTAGE_SUM_OVER_ERR_MSG, PERCENTAGE_TOTAL}; diff --git a/multisig/tests/multisig_rust_test.rs b/multisig/tests/multisig_rust_test.rs index 81aca5cf..cc183d7c 100644 --- a/multisig/tests/multisig_rust_test.rs +++ b/multisig/tests/multisig_rust_test.rs @@ -1,7 +1,15 @@ #![allow(deprecated)] pub mod multisig_setup; +use eth_address::EthAddress; +use multisig::multisig_general::MultisigGeneralModule; +use multisig::Multisig; use multisig_setup::*; +use multiversx_sc::types::{ManagedByteArray, ManagedVec, MultiValueEncoded}; +use multiversx_sc_scenario::{ + managed_address, managed_biguint, managed_buffer, managed_token_id, rust_biguint, +}; +use transaction::call_data::CallData; #[test] fn setup_test() { @@ -12,3 +20,95 @@ fn setup_test() { multisig::contract_obj, ); } + +#[test] +fn eth_to_mx_transfer_both_rejected_test() { + let mut setup = MultisigSetup::new( + multiversx_price_aggregator_sc::contract_obj, + esdt_safe::contract_obj, + multi_transfer_esdt::contract_obj, + multisig::contract_obj, + ); + + let dest_sc = setup.b_mock.create_sc_account( + &rust_biguint!(0), + Some(&setup.owner_addr), + esdt_safe::contract_obj, + "other esdt safe wasm path", + ); + + setup + .b_mock + .execute_tx( + &setup.relayer_1, + &setup.multisig_wrapper, + &rust_biguint!(0), + |sc| { + let mut transfers = MultiValueEncoded::new(); + let user_eth_addr = EthAddress { + raw_addr: ManagedByteArray::new_from_bytes(&[ + 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, + ]), + }; + transfers.push( + ( + user_eth_addr.clone(), + managed_address!(dest_sc.address_ref()), + managed_token_id!(WEGLD_TOKEN_ID), + managed_biguint!(76_000_000_000), + 1, + Some(CallData { + endpoint: managed_buffer!(b"data"), + gas_limit: 5_000_000, + args: ManagedVec::new(), + }), + ) + .into(), + ); + transfers.push( + ( + user_eth_addr, + managed_address!(dest_sc.address_ref()), + managed_token_id!(ETH_TOKEN_ID), + managed_biguint!(76_000_000_000), + 2, + Some(CallData { + endpoint: managed_buffer!(b"data"), + gas_limit: 5_000_000, + args: ManagedVec::new(), + }), + ) + .into(), + ); + + let action_id = sc.propose_multi_transfer_esdt_batch(1, transfers); + assert_eq!(action_id, 1); + }, + ) + .assert_ok(); + + setup + .b_mock + .execute_tx( + &setup.relayer_2, + &setup.multisig_wrapper, + &rust_biguint!(0), + |sc| { + sc.sign(1); + }, + ) + .assert_ok(); + + setup + .b_mock + .execute_tx( + &setup.relayer_1, + &setup.multisig_wrapper, + &rust_biguint!(0), + |sc| { + sc.perform_action_endpoint(1); + }, + ) + .assert_ok(); +} diff --git a/multisig/tests/multisig_scenario_rs_test.rs b/multisig/tests/multisig_scenario_rs_test.rs index 3eabc0d4..41227f9d 100644 --- a/multisig/tests/multisig_scenario_rs_test.rs +++ b/multisig/tests/multisig_scenario_rs_test.rs @@ -36,10 +36,10 @@ fn ethereum_to_multiversx_tx_batch_ok_rs() { world().run("scenarios/ethereum_to_multiversx_tx_batch_ok.scen.json"); } -// #[test] -// fn ethereum_to_multiversx_tx_batch_rejected_rs() { -// world().run("scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json"); -// } +#[test] +fn ethereum_to_multiversx_tx_batch_rejected_rs() { + world().run("scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json"); +} #[test] fn ethereum_to_multiversx_tx_batch_without_data_rs() { diff --git a/multisig/tests/multisig_setup/mod.rs b/multisig/tests/multisig_setup/mod.rs index 00a85718..b00ba92d 100644 --- a/multisig/tests/multisig_setup/mod.rs +++ b/multisig/tests/multisig_setup/mod.rs @@ -46,6 +46,9 @@ pub struct MultisigSetup< pub multi_transfer_wrapper: ContractObjWrapper, MultiTransferBuilder>, pub multisig_wrapper: ContractObjWrapper, MultisigBuilder>, + pub relayer_1: Address, + pub relayer_2: Address, + pub user: Address, } impl @@ -324,6 +327,9 @@ where esdt_safe_wrapper, multi_transfer_wrapper, multisig_wrapper, + relayer_1, + relayer_2, + user, } } } diff --git a/multisig/tests/scenario_go_test.rs b/multisig/tests/scenario_go_test.rs index 30009c70..aed76ed9 100644 --- a/multisig/tests/scenario_go_test.rs +++ b/multisig/tests/scenario_go_test.rs @@ -18,10 +18,10 @@ fn ethereum_to_multiversx_tx_batch_ok_go() { world().run("scenarios/ethereum_to_multiversx_tx_batch_ok.scen.json"); } -// #[test] -// fn ethereum_to_multiversx_tx_batch_rejected_go() { -// world().run("scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json"); -// } +#[test] +fn ethereum_to_multiversx_tx_batch_rejected_go() { + world().run("scenarios/ethereum_to_multiversx_tx_batch_rejected.scen.json"); +} #[test] fn execute_multiversx_to_ethereum_tx_batch_go() {