Skip to content

add wrapper and small refactor#561

Merged
sergiuosvat merged 2 commits intorc/betafrom
create-register-execute-blackbox-wrapper
Dec 9, 2025
Merged

add wrapper and small refactor#561
sergiuosvat merged 2 commits intorc/betafrom
create-register-execute-blackbox-wrapper

Conversation

@sergiuosvat
Copy link
Contributor

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new wrapper function register_and_execute_operation to reduce code duplication in tests and refactors multiple test functions to use this wrapper. It also includes some code quality improvements such as replacing repeated code with loops.

Key Changes:

  • Added register_and_execute_operation helper function that combines operation registration, status checking, and execution into a single call
  • Refactored 8 test functions to use the new wrapper, eliminating repetitive boilerplate code
  • Simplified repetitive checks by introducing loops for checking multiple addresses and tokens

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
mvx_esdt_safe_blackbox_setup.rs Added new register_and_execute_operation wrapper function to consolidate operation registration, status checking, and execution logic
mvx_esdt_safe_blackbox_tests.rs Refactored multiple test functions to use the new wrapper, moved variable declarations for better organization, and replaced repetitive assertion code with loops

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Coverage Summary

Totals

Count Covered %
Lines 19523 13420 68.74
Regions 3442 1736 50.44
Functions 1466 763 52.05
Instantiations 4467 1059 23.71

Files

Expand
File Lines Regions Functions Instantiations
/chain-config/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/chain-config/src/config_utils.rs 93.75% 90.20% 80.00% 22.86%
/chain-config/src/configs.rs 92.11% 83.33% 75.00% 12.90%
/chain-config/src/lib.rs 100.00% 100.00% 100.00% 14.04%
/chain-config/src/storage.rs 96.55% 85.71% 85.71% 19.23%
/chain-config/src/validator.rs 95.80% 80.00% 88.89% 18.33%
/chain-config/tests/chain_config_blackbox_setup.rs 100.00% 100.00% 100.00% 50.00%
/chain-config/tests/chain_config_blackbox_tests.rs 100.00% 100.00% 100.00% 100.00%
/chain-factory/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/chain-factory/src/complete_phases.rs 98.00% 66.67% 66.67% 16.67%
/chain-factory/src/factory.rs 98.33% 83.33% 83.33% 22.22%
/chain-factory/src/lib.rs 100.00% 100.00% 100.00% 22.22%
/chain-factory/src/update_configs.rs 74.00% 70.00% 70.00% 22.22%
/chain-factory/tests/chain_factory_blackbox_setup.rs 100.00% 100.00% 100.00% 50.00%
/chain-factory/tests/chain_factory_blackbox_tests.rs 100.00% 100.00% 100.00% 100.00%
/common/common-interactor/src/common_sovereign_interactor.rs 0.00% 0.00% 0.00% 0.00%
/common/common-interactor/src/interactor_common_state.rs 0.00% 0.00% 0.00% 0.00%
/common/common-interactor/src/interactor_config.rs 0.00% 0.00% 0.00% 0.00%
/common/common-interactor/src/interactor_helpers.rs 0.00% 0.00% 0.00% 0.00%
/common/common-interactor/src/interactor_state.rs 0.00% 0.00% 0.00% 0.00%
/common/common-interactor/src/interactor_structs.rs 0.00% 0.00% 0.00% 0.00%
/common/common-test-setup/src/base_setup/checks.rs 97.88% 91.38% 100.00% 50.00%
/common/common-test-setup/src/base_setup/complete_setup_phase.rs 64.06% 60.00% 60.00% 30.00%
/common/common-test-setup/src/base_setup/contract_endpoints.rs 93.80% 96.00% 92.86% 46.43%
/common/common-test-setup/src/base_setup/deploy.rs 100.00% 100.00% 100.00% 50.00%
/common/common-test-setup/src/base_setup/helpers.rs 94.02% 83.93% 90.48% 46.51%
/common/common-test-setup/src/base_setup/init.rs 83.93% 92.31% 83.33% 41.67%
/common/common-test-setup/src/base_setup/log_validations.rs 79.86% 81.58% 86.96% 43.48%
/common/common-utils/src/lib.rs 87.62% 80.77% 77.78% 29.51%
/common/cross-chain/src/deposit_common.rs 84.50% 82.26% 77.27% 38.30%
/common/cross-chain/src/execute_common.rs 70.00% 50.00% 45.45% 20.83%
/common/cross-chain/src/lib.rs 78.57% 66.67% 50.00% 42.86%
/common/cross-chain/src/storage.rs 50.00% 50.00% 50.00% 27.87%
/common/custom-events/src/lib.rs 50.00% 50.00% 50.00% 5.45%
/common/fee-common/src/endpoints.rs 96.97% 90.91% 75.00% 21.43%
/common/fee-common/src/helpers.rs 96.77% 88.68% 85.71% 40.00%
/common/fee-common/src/lib.rs 0.00% 0.00% 0.00% 0.00%
/common/fee-common/src/storage.rs 87.50% 75.00% 75.00% 39.02%
/common/proxies/src/chain_config_proxy.rs 81.46% 78.57% 78.57% 53.85%
/common/proxies/src/chain_factory_proxy.rs 63.11% 54.17% 54.17% 36.36%
/common/proxies/src/header_verifier_proxy.rs 82.31% 77.78% 77.78% 43.24%
/common/proxies/src/mvx_esdt_safe_proxy.rs 59.20% 55.17% 55.17% 30.86%
/common/proxies/src/mvx_fee_market_proxy.rs 89.69% 87.50% 87.50% 48.00%
/common/proxies/src/sov_esdt_safe_proxy.rs 43.35% 40.00% 40.00% 31.82%
/common/proxies/src/sov_fee_market_proxy.rs 77.24% 72.73% 72.73% 47.62%
/common/proxies/src/sov_registrar_proxy.rs 0.00% 0.00% 0.00% 0.00%
/common/proxies/src/sovereign_forge_proxy.rs 63.51% 60.71% 60.71% 29.69%
/common/proxies/src/testing_sc_proxy.rs 18.33% 33.33% 33.33% 16.67%
/common/setup-phase/src/lib.rs 26.32% 37.50% 50.00% 23.33%
/common/structs/src/configs.rs 44.04% 11.11% 11.11% 10.94%
/common/structs/src/events.rs 9.68% 8.33% 9.09% 3.70%
/common/structs/src/fee.rs 2.38% 2.38% 2.38% 4.00%
/common/structs/src/forge.rs 21.43% 8.33% 8.33% 4.08%
/common/structs/src/generate_hash.rs 92.31% 75.00% 100.00% 71.05%
/common/structs/src/lib.rs 0.00% 0.00% 0.00% 0.00%
/common/structs/src/operation.rs 70.59% 40.00% 27.27% 12.68%
/common/tx-nonce/src/lib.rs 0.00% 0.00% 0.00% 0.00%
/header-verifier/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/header-verifier/src/checks.rs 87.50% 71.43% 71.43% 31.25%
/header-verifier/src/header_utils.rs 95.89% 91.67% 80.00% 39.13%
/header-verifier/src/lib.rs 95.45% 87.50% 100.00% 25.71%
/header-verifier/src/operations.rs 84.62% 84.44% 83.33% 26.67%
/header-verifier/src/storage.rs 50.00% 50.00% 50.00% 34.38%
/header-verifier/tests/header_verifier_blackbox_setup.rs 100.00% 100.00% 100.00% 50.00%
/header-verifier/tests/header_verifier_blackbox_tests.rs 91.80% 87.34% 92.86% 92.86%
/interactor/src/complete_flows/complete_flows_interactor_main.rs 0.00% 0.00% 0.00% 0.00%
/interactor/src/interact.rs 0.00% 0.00% 0.00% 0.00%
/interactor/src/mvx_esdt_safe/mvx_esdt_safe_interactor_main.rs 0.00% 0.00% 0.00% 0.00%
/interactor/tests/always_deploy_setup_first.rs 0.00% 0.00% 0.00% 0.00%
/interactor/tests/mvx_esdt_safe_tests.rs 0.00% 0.00% 0.00% 0.00%
/mvx-esdt-safe/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/mvx-esdt-safe/src/bridging_mechanism.rs 63.68% 66.10% 87.50% 34.69%
/mvx-esdt-safe/src/deposit.rs 75.51% 75.00% 83.33% 27.78%
/mvx-esdt-safe/src/execute.rs 73.12% 73.08% 76.19% 35.09%
/mvx-esdt-safe/src/lib.rs 91.67% 91.18% 100.00% 29.31%
/mvx-esdt-safe/src/register_token.rs 59.17% 60.71% 70.00% 27.27%
/mvx-esdt-safe/tests/mvx_esdt_safe_blackbox_setup.rs 100.00% 100.00% 100.00% 50.00%
/mvx-esdt-safe/tests/mvx_esdt_safe_blackbox_tests.rs 94.30% 94.00% 95.52% 95.52%
/mvx-fee-market/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/mvx-fee-market/src/fee_operations.rs 89.87% 81.58% 85.71% 27.78%
/mvx-fee-market/src/fee_whitelist.rs 71.19% 73.08% 83.33% 26.67%
/mvx-fee-market/src/lib.rs 90.00% 83.33% 100.00% 24.24%
/mvx-fee-market/tests/mvx_fee_market_blackbox_setup.rs 99.19% 94.59% 100.00% 50.00%
/mvx-fee-market/tests/mvx_fee_market_blackbox_test.rs 100.00% 100.00% 100.00% 100.00%
/sov-esdt-safe/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/sov-esdt-safe/src/config_operations.rs 0.00% 0.00% 0.00% 0.00%
/sov-esdt-safe/src/deposit.rs 91.67% 83.33% 80.00% 25.00%
/sov-esdt-safe/src/fee_operations.rs 0.00% 0.00% 0.00% 0.00%
/sov-esdt-safe/src/lib.rs 50.00% 53.85% 83.33% 23.91%
/sov-esdt-safe/tests/sov_esdt_safe_blackbox_setup.rs 97.60% 94.12% 100.00% 50.00%
/sov-esdt-safe/tests/sov_esdt_safe_blackbox_tests.rs 94.48% 90.91% 90.91% 90.91%
/sov-fee-market/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/sov-fee-market/src/fee_operations.rs 93.33% 92.31% 80.00% 25.00%
/sov-fee-market/src/fee_whitelist.rs 87.50% 85.71% 75.00% 22.22%
/sov-fee-market/src/lib.rs 100.00% 100.00% 100.00% 22.22%
/sov-fee-market/tests/sov_fee_market_blackbox_setup.rs 100.00% 100.00% 100.00% 50.00%
/sov-fee-market/tests/sov_fee_market_blackbox_tests.rs 100.00% 100.00% 100.00% 100.00%
/sovereign-forge/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/sovereign-forge/src/forge_common/callbacks.rs 66.67% 63.64% 80.00% 35.48%
/sovereign-forge/src/forge_common/forge_utils.rs 97.50% 91.67% 86.67% 47.22%
/sovereign-forge/src/forge_common/sc_deploy.rs 96.43% 66.67% 66.67% 28.57%
/sovereign-forge/src/forge_common/storage.rs 50.00% 50.00% 50.00% 23.08%
/sovereign-forge/src/lib.rs 100.00% 100.00% 100.00% 25.64%
/sovereign-forge/src/phases.rs 98.98% 92.86% 85.71% 27.78%
/sovereign-forge/src/update_configs.rs 72.97% 63.64% 63.64% 20.00%
/sovereign-forge/tests/sovereign_forge_blackbox_setup.rs 92.05% 89.39% 94.12% 47.06%
/sovereign-forge/tests/sovereign_forge_blackbox_tests.rs 100.00% 100.00% 100.00% 100.00%
/testing-sc/meta/src/main.rs 0.00% 0.00% 0.00% 0.00%
/testing-sc/src/lib.rs 18.18% 50.00% 60.00% 15.22%

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Contract comparison - from 9a8ae62 to 3e2c326

Path                                                                                             size                  has-allocator                     has-format
header-verifier.wasm 9287 false without message
mvx-fee-market.wasm 13413 false None
sov-esdt-safe.wasm 13794 false None
sov-fee-market.wasm 9596 false None
chain-config.wasm 14437 false without message
testing-sc.wasm 1818 false None
sovereign-forge.wasm 17024 false without message
mvx-esdt-safe.wasm 34264 false without message
chain-factory.wasm 11529 false None

⚠️ Could not download the report for the base branch. Displaying only the report for the current branch. ⚠️


state.common_setup.register_operation(
USER_ADDRESS,
OWNER_ADDRESS,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
OWNER_ADDRESS,
USER_ADDRESS,

The caller can be any address as long as it's in the same shard as the contract (otherwise the tx might fail) and the payload is correct.
-> Let's use USER_ADDRESS because that's what you check below.

signature: ManagedBuffer<StaticApi>,
num_validators: usize,
expected_logs: Vec<ExpectedLogs>,
check_status: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

rename to check_hash_status

@sergiuosvat sergiuosvat merged commit d2620f7 into rc/beta Dec 9, 2025
8 checks passed
@sergiuosvat sergiuosvat deleted the create-register-execute-blackbox-wrapper branch December 9, 2025 11:27
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.

4 participants