Skip to content

Commit

Permalink
bridge-proxy: add unit test for empty endpoint and non-empty gas limit
Browse files Browse the repository at this point in the history
  • Loading branch information
CostinCarabas committed Dec 12, 2024
1 parent 227e6da commit 4f6a6eb
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions bridge-proxy/tests/bridge_proxy_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,83 @@ fn bridge_proxy_empty_endpoint_with_args_test() {
);
}

#[test]
fn bridge_proxy_empty_endpoint_with_gas_test() {
let mut test = BridgeProxyTestState::new();

test.world.start_trace();

test.multisig_deploy();
test.deploy_bridge_proxy();
test.deploy_crowdfunding();
test.config_bridge();

let call_data: CallData<StaticApi> = CallData {
endpoint: ManagedBuffer::new(),
gas_limit: GAS_LIMIT,
args: ManagedOption::none(),
};

let call_data: ManagedBuffer<StaticApi> =
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);

test.world
.tx()
.from(MULTI_TRANSFER_ADDRESS)
.to(BRIDGE_PROXY_ADDRESS)
.typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy)
.deposit(&eth_tx, 1u64)
.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(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();

test.world
.check_account(BRIDGE_PROXY_ADDRESS)
.check_storage("str:refundTransactions.mapped|u32:1", "0x30313032303330343035303630373038303931300000000000000000050063726f7766756e64696e675f5f5f5f5f5f5f5f5f5f5f0000000d4252494447452d3132333435360000000201f4000000000000000101000000110000000000000000009896800100000000")
.check_storage("str:refundTransactions.value|u32:1", "0x01")
.check_storage("str:refundTransactions.node_id|u32:1", "0x01")
.check_storage("str:refundTransactions.info", "0x00000001000000010000000100000001")
.check_storage("str:refundTransactions.node_links|u32:1", "0x0000000000000000")
.check_storage("str:batchId|u32:1", "1")
.check_storage("str:highestTxId", "1")
.check_storage(
"str:payments|u32:1",
"nested:str:BRIDGE-123456|u64:0|biguint:500",
);
}

#[test]
fn bridge_proxy_refund_tx_test() {
let mut test = BridgeProxyTestState::new();
Expand Down

0 comments on commit 4f6a6eb

Please sign in to comment.