tests: Wait for transaction to be in a finalized block #1236
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.
The test
fetch_block_and_decode_extrinsic_details
failed on this CI job:Rpc(ClientError(Call(ErrorObject { code: ServerError(2001), message: "Invalid block hash", data: None })))
The test is submitting an extrinsic and waiting for inclusion in any block.
Submitting an extrinsic with the unstable backend (rpc v2) implies:
chainHead
for related block hashestransaction
rpc methodIt is entirely possible that the block hash reported by the
transaction
method was not reported yet by thechainHead
class yet:subxt/subxt/src/backend/unstable/mod.rs
Lines 513 to 524 in ff3a086
Given that the test was waiting for any block inclusion (
wait_for_in_block
), the test attempted to callchainHead_header
before the block hash was reported.To mitigate this, the
wait_for_in_block
is replaced bywait_for_finalized
. Thesubmit_transaction
will returnTransactionStatus::InFinalizedBlock
only after the block hash has been reported bychainHead
.The downside of this approach is that the test may wait for a longer time (until the block becomes finalized + overhead of reporting the block via chainHead).
I was unable to reproduce the CI error in ~900 runs.