Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge v3 to v3.5 29.10.2024 #244

Merged
merged 18 commits into from
Oct 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
multi-transfer: add_refund_batch_test: add balances check
CostinCarabas committed Oct 25, 2024
commit e7bd1f01e59e6b2721635672a70d807bf99e4907
62 changes: 62 additions & 0 deletions multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs
Original file line number Diff line number Diff line change
@@ -469,6 +469,58 @@
)
.run();
}

fn check_balances_on_safe(
&mut self,
total_supply: BigUint<StaticApi>,
total_minted: BigUint<StaticApi>,
total_burned: BigUint<StaticApi>,
) {
let actual_total_supply = self
.world
.query()
.to(ESDT_SAFE_ADDRESS)
.typed(esdt_safe_proxy::EsdtSafeProxy)
.total_balances(TOKEN_ID)
.returns(ReturnsResult)
.run();

assert_eq!(
actual_total_supply,
BigUint::from(total_supply),

Check warning on line 490 in multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs

GitHub Actions / clippy

[clippy] multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs#L490

warning: useless conversion to the same type: `multiversx_sc::types::BigUint<multiversx_sc_scenario::api::VMHooksApi<multiversx_sc_scenario::api::impl_vh::static_api::StaticApiBackend>>` --> multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs:490:13 | 490 | BigUint::from(total_supply), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `BigUint::from()`: `total_supply` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` on by default
Raw output
multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs:490:13:w:warning: useless conversion to the same type: `multiversx_sc::types::BigUint<multiversx_sc_scenario::api::VMHooksApi<multiversx_sc_scenario::api::impl_vh::static_api::StaticApiBackend>>`
   --> multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs:490:13
    |
490 |             BigUint::from(total_supply),
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `BigUint::from()`: `total_supply`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
    = note: `#[warn(clippy::useless_conversion)]` on by default


__END__
"Total supply balance is wrong"
);
let actual_total_burned = self
.world
.query()
.to(ESDT_SAFE_ADDRESS)
.typed(esdt_safe_proxy::EsdtSafeProxy)
.burn_balances(TOKEN_ID)
.returns(ReturnsResult)
.run();

assert_eq!(
actual_total_burned,
BigUint::from(total_burned),

Check warning on line 504 in multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs

GitHub Actions / clippy

[clippy] multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs#L504

warning: useless conversion to the same type: `multiversx_sc::types::BigUint<multiversx_sc_scenario::api::VMHooksApi<multiversx_sc_scenario::api::impl_vh::static_api::StaticApiBackend>>` --> multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs:504:13 | 504 | BigUint::from(total_burned), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `BigUint::from()`: `total_burned` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
Raw output
multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs:504:13:w:warning: useless conversion to the same type: `multiversx_sc::types::BigUint<multiversx_sc_scenario::api::VMHooksApi<multiversx_sc_scenario::api::impl_vh::static_api::StaticApiBackend>>`
   --> multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs:504:13
    |
504 |             BigUint::from(total_burned),
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `BigUint::from()`: `total_burned`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion


__END__
"Total burned balance is wrong"
);

let actual_total_minted = self
.world
.query()
.to(ESDT_SAFE_ADDRESS)
.typed(esdt_safe_proxy::EsdtSafeProxy)
.mint_balances(TOKEN_ID)
.returns(ReturnsResult)
.run();

assert_eq!(
actual_total_minted,
BigUint::from(total_minted),

Check warning on line 519 in multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs

GitHub Actions / clippy

[clippy] multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs#L519

warning: useless conversion to the same type: `multiversx_sc::types::BigUint<multiversx_sc_scenario::api::VMHooksApi<multiversx_sc_scenario::api::impl_vh::static_api::StaticApiBackend>>` --> multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs:519:13 | 519 | BigUint::from(total_minted), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `BigUint::from()`: `total_minted` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
Raw output
multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs:519:13:w:warning: useless conversion to the same type: `multiversx_sc::types::BigUint<multiversx_sc_scenario::api::VMHooksApi<multiversx_sc_scenario::api::impl_vh::static_api::StaticApiBackend>>`
   --> multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs:519:13
    |
519 |             BigUint::from(total_minted),
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `BigUint::from()`: `total_minted`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion


__END__
"Total minted balance is wrong"
);
}

fn deploy_contracts(&mut self) {
self.multi_transfer_deploy();
self.bridge_proxy_deploy();
@@ -896,6 +948,9 @@
MultiValueEncoded::new();
transfers.push(eth_tx.clone());

let fee = 22_500_000_000u64;
state.check_balances_on_safe(BigUint::from(MAX_AMOUNT), BigUint::zero(), BigUint::zero());

state
.world
.tx()
@@ -904,6 +959,7 @@
.typed(multi_transfer_proxy::MultiTransferEsdtProxy)
.batch_transfer_esdt_token(1u32, transfers)
.run();
state.check_balances_on_safe(BigUint::zero(), BigUint::zero(), BigUint::zero());

state
.world
@@ -913,4 +969,10 @@
.typed(multi_transfer_proxy::MultiTransferEsdtProxy)
.move_refund_batch_to_safe()
.run();

state.check_balances_on_safe(
BigUint::from(MAX_AMOUNT) - fee,
BigUint::zero(),
BigUint::zero(),
);
}