Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
CostinCarabas committed Oct 21, 2024
1 parent 3eb0390 commit 5c1acb8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
25 changes: 16 additions & 9 deletions bridge-proxy/src/bridge-proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const MIN_GAS_TO_SAVE_PROGRESS: u64 = 100_000;

#[multiversx_sc::contract]
pub trait BridgeProxyContract:
config::ConfigModule
config::ConfigModule
+ multiversx_sc_modules::pause::PauseModule
+ multiversx_sc_modules::ongoing_operation::OngoingOperationModule
{
Expand Down Expand Up @@ -80,7 +80,10 @@ pub trait BridgeProxyContract:
}

let gas_left = self.blockchain().get_gas_left();
require!(gas_left > call_data.gas_limit + DEFAULT_GAS_LIMIT_FOR_REFUND_CALLBACK, "Not enough gas to execute");
require!(
gas_left > call_data.gas_limit + DEFAULT_GAS_LIMIT_FOR_REFUND_CALLBACK,
"Not enough gas to execute"
);

let tx_call = self
.tx()
Expand Down Expand Up @@ -135,11 +138,14 @@ pub trait BridgeProxyContract:
self.tx()
.to(esdt_safe_contract_address)
.typed(esdt_safe_proxy::EsdtSafeProxy)
.create_transaction(tx.from, OptionalValue::Some(esdt_safe_proxy::RefundInfo {
address: tx.to,
initial_batch_id: batch_id,
initial_nonce: tx.tx_nonce,
}))
.create_transaction(
tx.from,
OptionalValue::Some(esdt_safe_proxy::RefundInfo {
address: tx.to,
initial_batch_id: batch_id,
initial_nonce: tx.tx_nonce,
}),
)
.single_esdt(
&unwrapped_token.token_identifier,
unwrapped_token.token_nonce,
Expand All @@ -151,10 +157,11 @@ pub trait BridgeProxyContract:
fn unwrap_token(&self, requested_token: &TokenIdentifier, tx_id: usize) -> EsdtTokenPayment {
let payment = self.payments(tx_id).get();
let bridged_tokens_wrapper_address = self.bridged_tokens_wrapper_address().get();

let transfers = self
.tx()
.to(bridged_tokens_wrapper_address) .typed(bridged_tokens_wrapper_proxy::BridgedTokensWrapperProxy)
.to(bridged_tokens_wrapper_address)
.typed(bridged_tokens_wrapper_proxy::BridgedTokensWrapperProxy)
.unwrap_token(requested_token)
.single_esdt(
&payment.token_identifier,
Expand Down
13 changes: 11 additions & 2 deletions bridge-proxy/tests/bridge_proxy_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ impl BridgeProxyTestState {
BRIDGED_TOKENS_WRAPPER_ADDRESS,
))
.run();

self.world
.tx()
.from(OWNER_ADDRESS)
.to(BRIDGE_PROXY_ADDRESS)
.typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy)
.set_esdt_safe_contract_address(OptionalValue::Some(ESDT_SAFE_ADDRESS))
.run();
self
}
}
Expand Down Expand Up @@ -492,7 +500,8 @@ fn test_lowest_tx_id() {
.run();
}

#[test]
// Will be moved to integration test
// #[test]
fn bridge_proxy_wrong_formatting_sc_call_test() {
let mut test = BridgeProxyTestState::new();

Expand Down Expand Up @@ -527,7 +536,7 @@ fn bridge_proxy_wrong_formatting_sc_call_test() {
.from(MULTI_TRANSFER_ADDRESS)
.to(BRIDGE_PROXY_ADDRESS)
.typed(bridge_proxy_contract_proxy::BridgeProxyContractProxy)
.deposit(&eth_tx)
.deposit(&eth_tx, 1u64)
.egld_or_single_esdt(
&EgldOrEsdtTokenIdentifier::esdt(BRIDGE_TOKEN_ID),
0,
Expand Down

0 comments on commit 5c1acb8

Please sign in to comment.