Skip to content

test: add Solana validator test for transaction resubmission#59

Draft
lpahlavi wants to merge 11 commits intomainfrom
lpahlavi/resubmission-integration-test
Draft

test: add Solana validator test for transaction resubmission#59
lpahlavi wants to merge 11 commits intomainfrom
lpahlavi/resubmission-integration-test

Conversation

@lpahlavi
Copy link
Copy Markdown
Contributor

@lpahlavi lpahlavi commented Mar 20, 2026

Add an integration test that verifies deposit consolidation and transaction resubmission against a local Solana validator. The test deposits funds, triggers consolidation, waits for the blockhash to expire, and verifies the minter resubmits the transaction with a fresh blockhash.

To simulate a dropped transaction, the test uses a JsonRpcReverseProxy — a lightweight axum middleware that sits between the minter and the Solana validator. It can be configured to block specific JSON-RPC methods (e.g. sendTransaction) by returning an error instead of forwarding the request. This lets us test the resubmission flow without needing to actually drop network packets: the minter believes the transaction was submitted (and records a SubmittedTransaction event), but the transaction never reaches the validator.

The proxy is integrated into SetupBuilder via with_json_rpc_proxy(url, port), and its blocklist can be toggled at any point during the test with setup.json_rpc_proxy().block(...) and setup.json_rpc_proxy().clear_blocklist().

@lpahlavi lpahlavi changed the base branch from main to lpahlavi/resubmit-transactions-v2 March 20, 2026 09:40
lpahlavi and others added 8 commits March 20, 2026 15:50
Add tests for the consolidate_deposits function covering:
- Early return when no funds to consolidate
- Early return when task already active (guard)
- Early return when fetching blockhash fails
- Single consolidation request with event assertions
- Multiple consolidation batches (11 accounts → 2 batches)

Also adds canister_self() to CanisterRuntime trait to enable
mocking in tests, and extracts MAX_TRANSFERS_PER_CONSOLIDATION
constant for test visibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Record `ConsolidatedDeposits` and `SubmittedTransaction` events before
calling `submit_transaction` to ensure they persist for resubmission
even if the RPC call fails.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add timer task that resubmits all pending transactions every 60 seconds
with a fresh blockhash. Uses ResubmittedTransaction event to track the
signature change and updated slot.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests for the resubmit_transactions function covering:
- Early return when no transactions to resubmit
- Early return when task already active (guard)
- Early return when fetching current slot fails
- No resubmission when transaction not expired
- Single expired transaction resubmission with event assertions
- Event recorded even when submission fails

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@lpahlavi lpahlavi force-pushed the lpahlavi/resubmit-transactions-v2 branch from e2f05f1 to 39855fc Compare March 20, 2026 15:31
@lpahlavi lpahlavi force-pushed the lpahlavi/resubmission-integration-test branch 4 times, most recently from c48f1af to da66190 Compare March 24, 2026 08:32
@lpahlavi lpahlavi changed the title test: add integration test for consolidation transaction resubmission test: add integration test for deposit consolidation and transaction resubmission Mar 24, 2026
@lpahlavi lpahlavi force-pushed the lpahlavi/resubmission-integration-test branch 2 times, most recently from 27931fa to 4a8f2a3 Compare March 24, 2026 13:00
@lpahlavi lpahlavi changed the title test: add integration test for deposit consolidation and transaction resubmission test: add Solana validator test for transaction resubmission Mar 24, 2026
@lpahlavi lpahlavi force-pushed the lpahlavi/resubmission-integration-test branch from 4a8f2a3 to 2114db3 Compare March 24, 2026 13:16
Add a dropping proxy that can simulate network failures where
`sendTransaction` RPC calls appear to succeed but transactions never
land on-chain. This is useful for testing the resubmission logic.

The new test:
1. Starts a proxy that drops the first sendTransaction request
2. Creates deposits and triggers consolidation (transaction dropped)
3. Waits for slots to advance past MAX_BLOCKHASH_AGE
4. Triggers resubmission timer
5. Verifies funds are consolidated after resubmission

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@lpahlavi lpahlavi force-pushed the lpahlavi/resubmission-integration-test branch from 2114db3 to 3af4691 Compare March 24, 2026 13:21
Base automatically changed from lpahlavi/resubmit-transactions-v2 to main March 24, 2026 14:31
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.

1 participant