test: add integration tests for transaction resubmission#81
test: add integration tests for transaction resubmission#81
Conversation
There was a problem hiding this comment.
Pull request overview
Adds new integration tests that exercise the monitor_submitted_transactions timer task’s resubmission behavior when previously-submitted transactions become “expired” due to slot advancing beyond MAX_BLOCKHASH_AGE.
Changes:
- Added an integration test covering resubmission of an expired deposit consolidation transaction.
- Added an integration test covering resubmission of an expired withdrawal transaction (and asserting withdrawal status stays
TxSent). - Introduced helper HTTP-mock builders to drive consolidation/withdrawal submission and monitor-driven resubmission.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
64bf13e to
46cb034
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
46cb034 to
cf75438
Compare
Adds `should_resubmit_expired_consolidation_transaction` which verifies that the monitor resubmits a consolidation transaction whose blockhash has expired (slot > original_slot + MAX_BLOCKHASH_AGE). Also moves MAX_BLOCKHASH_AGE and SOL_RPC_SLOT_ROUNDING to file scope so they can be shared between the withdrawal and consolidation test modules. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cf75438 to
14599f6
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…mission Address Copilot review comments: - Fix e.payload -> e in assert_that_events (events are EventType directly) - Move INITIAL_SLOT to module scope and use it in http_mocks_for_deposit_consolidation - Strengthen ResubmittedTransaction assertion with new_slot >= expiry threshold Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// The SOL RPC canister rounds the slot returned by getSlot down to the nearest multiple | ||
| /// of this value before querying getBlock and returning the slot to callers. | ||
| const SOL_RPC_SLOT_ROUNDING: u64 = 20; | ||
|
|
There was a problem hiding this comment.
MAX_BLOCKHASH_AGE and SOL_RPC_SLOT_ROUNDING are duplicated test constants that must stay in sync with production code and the HTTP mock behavior (e.g., integration_tests/src/fixtures.rs hard-codes the / 20 * 20 rounding in get_block_request). To avoid drift, consider defining these values in one place (e.g., export a constant from the SOL-RPC fixture/helpers for the rounding, and/or expose MAX_BLOCKHASH_AGE from the minter monitor module for tests) and referencing that here instead of re-stating the numbers.
| /// The SOL RPC canister rounds the slot returned by getSlot down to the nearest multiple | |
| /// of this value before querying getBlock and returning the slot to callers. | |
| const SOL_RPC_SLOT_ROUNDING: u64 = 20; | |
| /// Mirrors the SOL RPC mock behavior in `integration_tests/src/fixtures.rs`, which rounds | |
| /// the slot returned by `getSlot` down to the nearest multiple of 20 before issuing `getBlock`. | |
| fn round_sol_rpc_slot(slot: Slot) -> Slot { | |
| (slot / 20) * 20 | |
| } |
| check!(events.iter().any(|e| matches!( | ||
| e, | ||
| // new_slot must be past the original blockhash expiry threshold, | ||
| // confirming the resubmitted transaction uses a fresh blockhash. | ||
| EventType::ResubmittedTransaction { new_slot, .. } | ||
| if *new_slot >= INITIAL_SLOT + MAX_BLOCKHASH_AGE | ||
| ))); |
There was a problem hiding this comment.
The test only asserts new_slot is past the expiry threshold, but it doesn't verify that the resubmission actually produced a replacement transaction for the original consolidation (e.g., that ResubmittedTransaction.old_signature matches the original SubmittedTransaction.signature, and that new_signature != old_signature). Capturing the original signature from the SubmittedTransaction event and asserting it is the one resubmitted (with a different new signature) would make this test reliably detect regressions where the blockhash/signature is not actually refreshed.
Summary
Adds an integration test verifying that the monitor resubmits an expired consolidation transaction.
should_resubmit_expired_consolidation_transactiontoconsolidation_tests: deposits funds, consolidates them, advances the slot pastMAX_BLOCKHASH_AGE, and asserts that aResubmittedTransactionevent is recorded with a fresh blockhash.MAX_BLOCKHASH_AGEandSOL_RPC_SLOT_ROUNDINGto file scope so they are shared betweenwithdrawal_testsandconsolidation_tests.INITIAL_SLOTto module scope inconsolidation_testsand use it inhttp_mocks_for_deposit_consolidationto keep the slot value in one place.🤖 Generated with Claude Code