Skip to content

test: add integration tests for transaction resubmission#81

Open
lpahlavi wants to merge 2 commits intomainfrom
lpahlavi/resubmission-integration-tests
Open

test: add integration tests for transaction resubmission#81
lpahlavi wants to merge 2 commits intomainfrom
lpahlavi/resubmission-integration-tests

Conversation

@lpahlavi
Copy link
Copy Markdown
Contributor

@lpahlavi lpahlavi commented Mar 26, 2026

Summary

Adds an integration test verifying that the monitor resubmits an expired consolidation transaction.

  • Add should_resubmit_expired_consolidation_transaction to consolidation_tests: deposits funds, consolidates them, advances the slot past MAX_BLOCKHASH_AGE, and asserts that a ResubmittedTransaction event is recorded with a fresh blockhash.
  • Move MAX_BLOCKHASH_AGE and SOL_RPC_SLOT_ROUNDING to file scope so they are shared between withdrawal_tests and consolidation_tests.
  • Move INITIAL_SLOT to module scope in consolidation_tests and use it in http_mocks_for_deposit_consolidation to keep the slot value in one place.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 26, 2026 16:32
Copy link
Copy Markdown
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

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.

Comment thread integration_tests/tests/tests.rs Outdated
Comment thread integration_tests/tests/tests.rs Outdated
@lpahlavi lpahlavi force-pushed the lpahlavi/resubmission-integration-tests branch 2 times, most recently from 64bf13e to 46cb034 Compare March 26, 2026 17:05
Copilot AI review requested due to automatic review settings March 26, 2026 17:05
@lpahlavi lpahlavi changed the base branch from main to lpahlavi/update-resubmitted-withdrawal-signature March 26, 2026 17:05
Copy link
Copy Markdown
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

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.

Comment thread integration_tests/tests/tests.rs
Comment thread integration_tests/tests/tests.rs Outdated
Comment thread integration_tests/tests/tests.rs
Comment thread integration_tests/tests/tests.rs Outdated
@lpahlavi lpahlavi force-pushed the lpahlavi/resubmission-integration-tests branch from 46cb034 to cf75438 Compare March 26, 2026 17:15
Base automatically changed from lpahlavi/update-resubmitted-withdrawal-signature to main March 27, 2026 10:19
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>
Copilot AI review requested due to automatic review settings April 17, 2026 13:49
@lpahlavi lpahlavi force-pushed the lpahlavi/resubmission-integration-tests branch from cf75438 to 14599f6 Compare April 17, 2026 13:49
Copy link
Copy Markdown
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

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.

Comment thread integration_tests/tests/tests.rs Outdated
Comment thread integration_tests/tests/tests.rs Outdated
Comment thread integration_tests/tests/tests.rs
…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>
@lpahlavi lpahlavi requested review from THLO and maciejdfinity April 20, 2026 13:52
@lpahlavi lpahlavi marked this pull request as ready for review April 20, 2026 13:52
@lpahlavi lpahlavi requested a review from a team as a code owner April 20, 2026 13:52
Copilot AI review requested due to automatic review settings April 20, 2026 13:52
Copy link
Copy Markdown
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

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.

Comment on lines +36 to +39
/// 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;

Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
/// 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
}

Copilot uses AI. Check for mistakes.
Comment on lines +1146 to +1152
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
)));
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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