test: add Solana validator test for transaction resubmission#59
Draft
test: add Solana validator test for transaction resubmission#59
Conversation
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>
e2f05f1 to
39855fc
Compare
c48f1af to
da66190
Compare
27931fa to
4a8f2a3
Compare
4a8f2a3 to
2114db3
Compare
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>
2114db3 to
3af4691
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 lightweightaxummiddleware 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 aSubmittedTransactionevent), but the transaction never reaches the validator.The proxy is integrated into
SetupBuilderviawith_json_rpc_proxy(url, port), and its blocklist can be toggled at any point during the test withsetup.json_rpc_proxy().block(...)andsetup.json_rpc_proxy().clear_blocklist().