Skip to content

chore: refactor proposal cancel tests#808

Draft
ecPablo wants to merge 13 commits into
mainfrom
ecpablo/refactor-proposal-cancel-tests
Draft

chore: refactor proposal cancel tests#808
ecPablo wants to merge 13 commits into
mainfrom
ecpablo/refactor-proposal-cancel-tests

Conversation

@ecPablo

@ecPablo ecPablo commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

This pull request significantly refactors the TestTimelock_Cancel end-to-end test for the Aptos timelock module, making the test more modular, maintainable, and reusable. The refactor replaces a large, monolithic function with a structured approach that leverages shared test hooks and utility functions, reducing duplication and improving clarity.

Key improvements and refactoring:

Test structure and modularization:

  • Replaces the previous inline test logic with a call to e2ecommon.RunScheduleAndCancelTest, centralizing the scheduling and cancellation logic and enabling code reuse across tests.
  • Extracts repeated setup steps (such as ownership transfer and role configuration) into dedicated helper methods: initTransferOwnership, configureRole, and buildAcceptOwnershipTransaction.

Signer and role management:

  • Introduces testutils.MakeNewECDSASigners to generate signers for both proposer and canceller roles, and adds a keysToAddresses utility for address extraction, simplifying signer management and reducing boilerplate. [1] [2]

Flexible test hooks and assertions:

  • Implements flexible hooks (e.g., Setup, Sign, DeriveCancellationMetadata, WaitForTransaction, AssertExtraAfterCancel) to allow custom logic at each stage of the test, improving extensibility and clarity of test intent.

Improved readability and maintainability:

  • Removes large blocks of repetitive code for proposal creation, signing, execution, and assertion, replacing them with concise, well-named function calls and hooks. [1] [2]
  • Ensures all critical assertions (such as owner checks after cancellation) are preserved and clearly expressed in dedicated assertion hooks.

Overall, these changes modernize the test by adopting best practices for modularization and code reuse, making future maintenance and extension much easier.

Most important changes:

Test modularization and reuse:

  • Refactored the test to use e2ecommon.RunScheduleAndCancelTest with custom hooks, replacing the previous large inline test

krebernisak and others added 13 commits June 25, 2026 14:18
… reused by other chain

Signed-off-by: Pablo <pablo.estrada@smartcontract.com>
# Conflicts:
#	e2e/tests/aptos/timelock_cancel.go
#	e2e/tests/ton/executable.go
Signed-off-by: Pablo <pablo.estrada@smartcontract.com>
Signed-off-by: Pablo <pablo.estrada@smartcontract.com>
Signed-off-by: Pablo <pablo.estrada@smartcontract.com>
@cl-sonarqube-production

Copy link
Copy Markdown

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.

2 participants