Skip to content

Commit

Permalink
unit tests fixes after reviews applied
Browse files Browse the repository at this point in the history
  • Loading branch information
CostinCarabas committed Dec 12, 2024
1 parent 05515ec commit 7db4577
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 24 deletions.
2 changes: 1 addition & 1 deletion bridge-proxy/tests/bridge_proxy_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ fn bridge_proxy_empty_endpoint_with_gas_test() {

test.world
.check_account(BRIDGE_PROXY_ADDRESS)
.check_storage("str:refundTransactions.mapped|u32:1", "0x30313032303330343035303630373038303931300000000000000000050063726f7766756e64696e675f5f5f5f5f5f5f5f5f5f5f0000000d4252494447452d3132333435360000000201f4000000000000000101000000110000000000000000009896800100000000")
.check_storage("str:refundTransactions.mapped|u32:1", "0x30313032303330343035303630373038303931300000000000000000050063726f7766756e64696e675f5f5f5f5f5f5f5f5f5f5f0000000d4252494447452d3132333435360000000201f40000000000000001010000000d00000000000000000098968000")
.check_storage("str:refundTransactions.value|u32:1", "0x01")
.check_storage("str:refundTransactions.node_id|u32:1", "0x01")
.check_storage("str:refundTransactions.info", "0x00000001000000010000000100000001")
Expand Down
8 changes: 0 additions & 8 deletions common/sc-proxies/src/multisig_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,14 +697,6 @@ where
.original_result()
}

pub fn bridged_tokens_wrapper_deposit_liquidity(
self,
) -> TxTypedCall<Env, From, To, (), Gas, ()> {
self.wrapped_tx
.raw_call("bridgedTokensWrapperDepositLiquidity")
.original_result()
}

/// Minimum number of signatures needed to perform any action.
pub fn quorum(
self,
Expand Down
76 changes: 72 additions & 4 deletions esdt-safe/tests/esdt_safe_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,9 @@ impl EsdtSafeTestState {
) {
self.esdt_raw_transaction()
.create_transaction(
EthAddress::zero(),
EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"),
},
OptionalValue::<BigUint<StaticApi>>::None,
)
.egld_or_single_esdt(
Expand All @@ -362,7 +364,9 @@ impl EsdtSafeTestState {
fn single_transaction_should_work(&mut self, token_id: TestTokenIdentifier, amount: u64) {
self.esdt_raw_transaction()
.create_transaction(
EthAddress::zero(),
EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"),
},
OptionalValue::<BigUint<StaticApi>>::None,
)
.egld_or_single_esdt(
Expand Down Expand Up @@ -717,7 +721,12 @@ fn esdt_safe_create_transaction() {
.from(BRIDGE_PROXY_ADDRESS)
.to(ESDT_SAFE_ADDRESS)
.typed(esdt_safe_proxy::EsdtSafeProxy)
.create_refund_transaction(EthAddress::zero(), OptionalValue::Some(refund_info.clone()))
.create_refund_transaction(
EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"),
},
OptionalValue::Some(refund_info.clone()),
)
.single_esdt(&TOKEN_ID.into(), 0, &BigUint::from(10u64))
.run();

Expand All @@ -727,7 +736,12 @@ fn esdt_safe_create_transaction() {
.from(BRIDGED_TOKENS_WRAPPER_ADDRESS)
.to(ESDT_SAFE_ADDRESS)
.typed(esdt_safe_proxy::EsdtSafeProxy)
.create_refund_transaction(EthAddress::zero(), OptionalValue::Some(refund_info.clone()))
.create_transaction(
EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"),
},
OptionalValue::<BigUint<StaticApi>>::None,
)
.single_esdt(&TOKEN_ID.into(), 0, &BigUint::from(10u64))
.run();

Expand Down Expand Up @@ -776,6 +790,44 @@ fn esdt_safe_create_transaction() {
assert_eq!(total_balances, 120000u64);
}

#[test]
fn create_refund_transaction_not_from_bridge_proxy_test() {
let mut state = EsdtSafeTestState::new();
state.multisig_deploy();
state.safe_deploy();

state.world.set_esdt_balance(
MULTISIG_ADDRESS,
b"TOKEN-WITH",
BigUint::from(10_000_000u64),
);

let refund_info = sc_proxies::esdt_safe_proxy::RefundInfo::<StaticApi> {
address: ManagedAddress::from(OWNER_ADDRESS.eval_to_array()),
initial_batch_id: 1u64,
initial_nonce: 1u64,
};

state
.world
.tx()
.from(OWNER_ADDRESS)
.to(ESDT_SAFE_ADDRESS)
.typed(esdt_safe_proxy::EsdtSafeProxy)
.create_refund_transaction(
EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"),
},
OptionalValue::Some(refund_info.clone()),
)
.single_esdt(&TOKEN_ID.into(), 0, &BigUint::from(10u64))
.returns(ExpectError(
ERROR,
"Only BridgeProxy SC can call this endpoint",
))
.run();
}

#[test]
fn add_refund_batch_test() {
let mut state = EsdtSafeTestState::new();
Expand Down Expand Up @@ -1233,6 +1285,22 @@ fn withdraw_transaction_fees_test() {
OptionalValue::<BigUint<StaticApi>>::None,
)
.single_esdt(&TOKEN_ID.into(), 0, &BigUint::from(1_000_000u64))
.returns(ExpectError(ERROR, "Cannot send to an empty address"))
.run();

state
.world
.tx()
.from(OWNER_ADDRESS)
.to(ESDT_SAFE_ADDRESS)
.typed(esdt_safe_proxy::EsdtSafeProxy)
.create_transaction(
EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"),
},
OptionalValue::<BigUint<StaticApi>>::None,
)
.single_esdt(&TOKEN_ID.into(), 0, &BigUint::from(1_000_000u64))
.returns(ReturnsResult)
.run();

Expand Down
4 changes: 3 additions & 1 deletion multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,9 @@ fn test_unwrap_token_create_transaction_should_work() {
.unwrap_token_create_transaction(
WRAPPED_TOKEN_ID,
ESDT_SAFE_ADDRESS.to_address(),
EthAddress::zero(),
EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"),
},
OptionalValue::<BigUint<StaticApi>>::None,
)
.egld_or_single_esdt(
Expand Down
5 changes: 1 addition & 4 deletions multisig/src/setup.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use multiversx_sc::imports::*;

use eth_address::EthAddress;
use sc_proxies::{
bridge_proxy_contract_proxy, esdt_safe_proxy,
multi_transfer_esdt_proxy,
};
use sc_proxies::{bridge_proxy_contract_proxy, esdt_safe_proxy, multi_transfer_esdt_proxy};

const MAX_BOARD_MEMBERS: usize = 40;

Expand Down
24 changes: 18 additions & 6 deletions multisig/tests/multisig_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,9 @@ impl MultiTransferTestState {
.to(ESDT_SAFE_ADDRESS)
.typed(esdt_safe_proxy::EsdtSafeProxy)
.create_transaction(
EthAddress::zero(),
EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"),
},
OptionalValue::<BigUint<StaticApi>>::None,
)
.single_esdt(
Expand All @@ -431,7 +433,9 @@ impl MultiTransferTestState {
.to(ESDT_SAFE_ADDRESS)
.typed(esdt_safe_proxy::EsdtSafeProxy)
.create_transaction(
EthAddress::zero(),
EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"),
},
OptionalValue::<BigUint<StaticApi>>::None,
)
.single_esdt(
Expand Down Expand Up @@ -1820,7 +1824,9 @@ fn test_add_mapping_success() {

let token_id = TokenIdentifier::from(WEGLD_TOKEN_ID);

let erc20_address = EthAddress::zero();
let erc20_address = EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"),
};

state
.world
Expand Down Expand Up @@ -1858,7 +1864,9 @@ fn test_add_mapping_token_id_already_mapped() {

let token_id = TokenIdentifier::from(WEGLD_TOKEN_ID);

let erc20_address = EthAddress::zero();
let erc20_address = EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"),
};

state
.world
Expand Down Expand Up @@ -1888,7 +1896,9 @@ fn test_add_mapping_erc20_address_already_mapped() {

let token_id = TokenIdentifier::from(WEGLD_TOKEN_ID);

let erc20_address = EthAddress::zero();
let erc20_address = EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"),
};

state
.world
Expand Down Expand Up @@ -1918,7 +1928,9 @@ fn test_clear_mapping_success() {

let token_id = TokenIdentifier::from(WEGLD_TOKEN_ID);

let erc20_address = EthAddress::zero();
let erc20_address = EthAddress {
raw_addr: ManagedByteArray::new_from_bytes(b"01020304050607080910"),
};

state
.world
Expand Down

0 comments on commit 7db4577

Please sign in to comment.