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

Multisig unit tests #249

Merged
merged 21 commits into from
Dec 10, 2024
Merged

Multisig unit tests #249

merged 21 commits into from
Dec 10, 2024

Conversation

evelinemolnar
Copy link
Contributor

No description provided.

Base automatically changed from refactor-scstorage to feat/v3.5 November 4, 2024 12:42
Copy link

github-actions bot commented Nov 4, 2024

Coverage Summary

Totals

Count Covered %
Lines 11724 9941 84.79
Regions 1722 1258 73.05
Functions 883 667 75.54
Instantiations 5152 1832 35.56

Files

Expand
File Lines Regions Functions Instantiations
/home/runner/.cargo/git/checkouts/mx-contracts-rs-13011bd47afef959/e72c201/contracts/crowdfunding-esdt/src/crowdfunding_esdt.rs 51.56% 57.14% 77.78% 64.00%
/home/runner/.cargo/git/checkouts/mx-contracts-rs-13011bd47afef959/e72c201/contracts/crowdfunding-esdt/src/crowdfunding_esdt_proxy.rs 100.00% 100.00% 100.00% 100.00%
/bridge-proxy/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/bridge-proxy/src/bridge-proxy.rs 68.21% 70.00% 78.57% 23.12%
/bridge-proxy/src/config.rs 100.00% 66.67% 100.00% 30.00%
/bridge-proxy/tests/bridge_proxy_blackbox_test.rs 71.06% 88.00% 78.57% 78.57%
/bridged-tokens-wrapper/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/bridged-tokens-wrapper/src/dfp_big_uint.rs 100.00% 100.00% 100.00% 50.00%
/bridged-tokens-wrapper/src/events.rs 100.00% 33.33% 100.00% 10.34%
/bridged-tokens-wrapper/src/lib.rs 100.00% 100.00% 100.00% 23.19%
/bridged-tokens-wrapper/tests/bridged_tokens_wrapper_whitebox_test.rs 89.58% 90.80% 90.22% 90.22%
/bridged-tokens-wrapper/tests/dfp_big_uint_test.rs 100.00% 100.00% 100.00% 100.00%
/bridged-tokens-wrapper/tests/scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/common/eth-address/src/lib.rs 93.33% 66.67% 88.89% 57.73%
/common/fee-estimator-module/src/lib.rs 100.00% 93.33% 100.00% 33.33%
/common/fee-estimator-module/src/price_aggregator_proxy.rs 6.14% 4.76% 6.67% 13.16%
/common/max-bridged-amount-module/src/lib.rs 100.00% 87.50% 100.00% 33.98%
/common/mock-contracts/mock-bridge-proxy/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/common/mock-contracts/mock-bridge-proxy/src/mock_bridge_proxy.rs 100.00% 33.33% 100.00% 3.70%
/common/mock-contracts/mock-bridged-tokens-wrapper/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/common/mock-contracts/mock-bridged-tokens-wrapper/src/mock_bridged_tokens_wrapper.rs 100.00% 33.33% 100.00% 5.26%
/common/mock-contracts/mock-esdt-safe/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/common/mock-contracts/mock-esdt-safe/src/mock_esdt_safe.rs 25.00% 26.32% 25.00% 16.92%
/common/mock-contracts/mock-multi-transfer-esdt/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/common/mock-contracts/mock-multi-transfer-esdt/src/mock_multi_transfer_esdt.rs 100.00% 100.00% 100.00% 17.31%
/common/mock-contracts/mock-multisig/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/common/mock-contracts/mock-multisig/src/mock_multisig.rs 100.00% 100.00% 100.00% 35.48%
/common/mock-contracts/mock-price-aggregator/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/common/mock-contracts/mock-price-aggregator/src/mock_price_aggregator.rs 100.00% 66.67% 100.00% 25.00%
/common/mock-proxies/src/mock_multisig_proxy.rs 72.41% 62.50% 62.50% 55.56%
/common/sc-proxies/src/bridge_proxy_contract_proxy.rs 83.51% 81.82% 81.82% 59.52%
/common/sc-proxies/src/bridged_tokens_wrapper_proxy.rs 43.98% 45.00% 45.00% 38.18%
/common/sc-proxies/src/crowdfunding_esdt_proxy.rs 0.00% 0.00% 0.00% 0.00%
/common/sc-proxies/src/esdt_safe_proxy.rs 84.19% 64.52% 73.58% 49.45%
/common/sc-proxies/src/multi_transfer_esdt_proxy.rs 70.19% 68.75% 68.75% 46.67%
/common/sc-proxies/src/multisig_proxy.rs 72.49% 53.12% 61.45% 40.56%
/common/storage-module/src/lib.rs 100.00% 88.89% 100.00% 29.41%
/common/token-module/src/lib.rs 91.95% 82.28% 90.00% 34.62%
/common/transaction/src/lib.rs 73.58% 50.98% 66.67% 39.80%
/common/transaction/src/transaction_status.rs 83.33% 66.67% 83.33% 45.10%
/common/tx-batch-module/src/batch_status.rs 66.67% 50.00% 66.67% 20.00%
/common/tx-batch-module/src/lib.rs 96.02% 87.67% 100.00% 28.19%
/common/tx-batch-module/src/tx_batch_mapper.rs 97.01% 93.10% 100.00% 55.00%
/esdt-safe/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/esdt-safe/src/lib.rs 88.24% 71.33% 77.78% 30.21%
/esdt-safe/tests/esdt_safe_blackbox_test.rs 99.18% 83.05% 100.00% 100.00%
/esdt-safe/tests/esdt_safe_scenario_rs_test.rs 100.00% 100.00% 100.00% 100.00%
/esdt-safe/tests/scenario_go_test.rs 100.00% 100.00% 100.00% 100.00%
/multi-transfer-esdt/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/multi-transfer-esdt/src/lib.rs 88.24% 84.00% 84.62% 25.48%
/multi-transfer-esdt/tests/multi_transfer_blackbox_test.rs 86.37% 75.61% 78.79% 78.79%
/multi-transfer-esdt/tests/multi_transfer_esdt_scenario_rs_test.rs 57.14% 30.00% 30.00% 30.00%
/multi-transfer-esdt/tests/scenario_go_test.rs 30.00% 30.00% 30.00% 30.00%
/multisig/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/multisig/src/action.rs 25.00% 22.22% 33.33% 30.77%
/multisig/src/events.rs 100.00% 66.67% 100.00% 29.03%
/multisig/src/lib.rs 91.84% 86.25% 100.00% 38.16%
/multisig/src/multisig_general.rs 98.00% 80.77% 100.00% 41.03%
/multisig/src/queries.rs 64.52% 61.76% 57.89% 15.79%
/multisig/src/setup.rs 100.00% 97.62% 100.00% 30.33%
/multisig/src/storage.rs 100.00% 66.67% 100.00% 33.11%
/multisig/src/user_role.rs 83.33% 72.73% 75.00% 41.67%
/multisig/src/util.rs 94.44% 84.38% 100.00% 44.12%
/multisig/tests/multisig_blackbox_test.rs 100.00% 100.00% 100.00% 100.00%
/multisig/tests/multisig_scenario_rs_test.rs 82.69% 72.73% 72.73% 72.73%
/multisig/tests/scenario_go_test.rs 70.00% 70.00% 70.00% 70.00%
/test-caller/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/test-caller/src/test-caller.rs 0.00% 0.00% 0.00% 0.00%

Copy link

github-actions bot commented Nov 4, 2024

Contract comparison - from ea7ea9b to 31805a0

Path                                                                                             size                  has-allocator                     has-format
test-caller.wasm 3274 false without message
esdt-safe.wasm 25531 false without message
mock-multi-transfer-esdt.wasm 241 ➡️ 521 🔴 false none
mock-multisig.wasm 2186 false none
mock-esdt-safe.wasm 1800 ➡️ 1931 🔴 false without message
mock-price-aggregator.wasm 1099 false none
mock-bridge-proxy.wasm 728 ➡️ 241 🟢 false none
mock-bridged-tokens-wrapper.wasm 942 false none
multi-transfer-esdt.wasm 16519 false without message
bridge-proxy.wasm 13363 false without message
bridged-tokens-wrapper.wasm 8781 false without message
multisig.wasm 28936 false without message

dorin-iancu
dorin-iancu previously approved these changes Nov 5, 2024
@evelinemolnar evelinemolnar marked this pull request as ready for review November 8, 2024 09:49
CostinCarabas
CostinCarabas previously approved these changes Nov 11, 2024
.to(MULTISIG_ADDRESS)
.typed(multisig_proxy::MultisigProxy)
.distribute_fees_from_child_contracts(dest_address_percentage_pairs)
.run();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also check that the dest_addresses has the balances? before and after

.typed(multisig_proxy::MultisigProxy)
.distribute_fees_from_child_contracts(dest_address_percentage_pairs)
.returns(ExpectError(4, "Percentages do not add up to 100%"))
.run();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also check that the dest_addresses has the same balances? before and after

4,
"Cannot transfer to smart contract dest_address",
))
.run();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also check that the dest_addresses has the same balances? before and after

.typed(multisig_proxy::MultisigProxy)
.unstake(unstake_amount)
.returns(ExpectError(4, "can't unstake more than amount staked"))
.run();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check that the staked amount remains the same

4,
"can't unstake, must keep minimum amount as insurance",
))
.run();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check that the staked amount remains the same

.returns(ReturnsResult)
.run();

assert_eq!(remaining_stake_relayer2, BigUint::from(2_000u64));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

state
.world
.check_account(ESDT_SAFE_ADDRESS)
.esdt_balance(token_id, amount.clone());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check also the storages

.from(OWNER_ADDRESS)
.to(MULTISIG_ADDRESS)
.typed(multisig_proxy::MultisigProxy)
.add_unprocessed_refund_tx_to_batch(tx_id)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check storages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not have a view for the pending batches. what should i check instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unprocessed_refund_txs(tx_id) has to be cleaned
last_batch_id before and last_batch_id after and should be + 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgot to check earlier, but this endpoint calls the add_unprocessed_refund_tx_to_batch from a mock multi-transfer contract which does not set any storage. this endpoint will be tested from multitransfer directly

.to(MULTISIG_ADDRESS)
.typed(multisig_proxy::MultisigProxy)
.withdraw_refund_fees_for_ethereum(TokenIdentifier::from(WEGLD_TOKEN_ID))
.run();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the balance of the owner

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are using a mock esdt safe contract, so after multisig calling withdraw_refund_fees_for_ethereum from esdt safe, nothing is happening. maybe i can use a storage mapper to see we actually get here, otherwise the functionality from withdraw_refund_fees_for_ethereum on esdt safe was already unit tested in esdt_safe_blackbox_test.rs

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need then 🙏

.from(OWNER_ADDRESS)
.to(MULTISIG_ADDRESS)
.typed(multisig_proxy::MultisigProxy)
.withdraw_transaction_fees(TokenIdentifier::from(WEGLD_TOKEN_ID))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check balances

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. but great observation, i will check also on esdt_safe_blackbox_test.rs the balances. thanks

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then the checks for the balances also on esdt_safe_blackbox_test.rs is enough

CostinCarabas
CostinCarabas previously approved these changes Nov 13, 2024

let mut board: MultiValueEncoded<StaticApi, ManagedAddress<StaticApi>> =
MultiValueEncoded::new();
board.push(ManagedAddress::from(RELAYER1_ADDRESS.eval_to_array()));
Copy link

@andreiblt1304 andreiblt1304 Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's easier to use the to_managed_address() method
RELAYER1_ADDRESS.to_managed_address()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the suggestion, indeed easier

dorin-iancu
dorin-iancu previously approved these changes Nov 13, 2024
andreiblt1304
andreiblt1304 previously approved these changes Nov 13, 2024
alyn509
alyn509 previously approved these changes Nov 13, 2024
CostinCarabas
CostinCarabas previously approved these changes Nov 13, 2024
andreiblt1304
andreiblt1304 previously approved these changes Nov 13, 2024
@CostinCarabas CostinCarabas changed the base branch from feat/v3.5 to feat/v3.1 December 10, 2024 10:10
@CostinCarabas CostinCarabas dismissed stale reviews from andreiblt1304 and themself December 10, 2024 10:10

The base branch was changed.

@CostinCarabas CostinCarabas merged commit e3fed00 into feat/v3.1 Dec 10, 2024
5 checks passed
@CostinCarabas CostinCarabas deleted the multisig-unit-tests branch December 10, 2024 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants