rpc-v2/tx/tests: Add transaction broadcast tests and check propagated tx status (#3193)
This PR adds tests for the `transaction_broadcast` method. The testing needs to coordinate the following components: - The `TestApi` marks transactions as invalid and implements `ChainApi::validate_transaction` - this is what dictates if a transaction is valid or not and is called from within the `BasicPool` - The `BasicPool` which maintains the transactions and implements `submit_and_watch` needed by the tx broadcast to submit the transaction - The status of the transaction pool is exposed by mocking the BasicPool - The `ChainHeadMockClient` which mocks the `BlockchainEvents::import_notification_stream` needed by the tx broadcast to know to which blocks the transaction is submitted The following changes have been added to the substrate testing to accommodate this: - `TestApi` gets ` remove_invalid`, counterpart to `add_invalid` to ensure an invalid transaction can become valid again; as well as a priority setter for extrinsics - `BasicPool` test constructor is extended with options for the `PoolRotator` - this mechanism is needed because transactions are banned for 30mins (default) after they are declared invalid - testing bypasses this by providing a `Duration::ZERO` ### Testing Scenarios - Capture the status of the transaction as it is normally broadcasted - `transaction_stop` is valid while the transaction is in progress - A future transaction is handled when the dependencies are completed - Try to resubmit the transaction at a later block (currently invalid) - An invalid transaction status is propagated; the transaction is marked as temporarily banned; then the ban expires and transaction is resubmitted This builds on top of: https://github.com/paritytech/polkadot-sdk/pull/3079 Part of: https://github.com/paritytech/polkadot-sdk/issues/3084 cc @paritytech/subxt-team --------- Signed-off-by:Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by:
James Wilson <james@jsdw.me>
parent
12ce4f7d
Showing
- substrate/client/rpc-spec-v2/src/chain_head/test_utils.rs 2 additions, 2 deletionssubstrate/client/rpc-spec-v2/src/chain_head/test_utils.rs
- substrate/client/rpc-spec-v2/src/transaction/tests.rs 0 additions, 238 deletionssubstrate/client/rpc-spec-v2/src/transaction/tests.rs
- substrate/client/rpc-spec-v2/src/transaction/tests/executor.rs 100 additions, 0 deletions...rate/client/rpc-spec-v2/src/transaction/tests/executor.rs
- substrate/client/rpc-spec-v2/src/transaction/tests/middleware_pool.rs 187 additions, 0 deletions...ient/rpc-spec-v2/src/transaction/tests/middleware_pool.rs
- substrate/client/rpc-spec-v2/src/transaction/tests/mod.rs 24 additions, 0 deletionssubstrate/client/rpc-spec-v2/src/transaction/tests/mod.rs
- substrate/client/rpc-spec-v2/src/transaction/tests/setup.rs 120 additions, 0 deletionssubstrate/client/rpc-spec-v2/src/transaction/tests/setup.rs
- substrate/client/rpc-spec-v2/src/transaction/tests/transaction_broadcast_tests.rs 523 additions, 0 deletions...c-v2/src/transaction/tests/transaction_broadcast_tests.rs
- substrate/client/transaction-pool/src/lib.rs 2 additions, 1 deletionsubstrate/client/transaction-pool/src/lib.rs
- substrate/client/transaction-pool/tests/pool.rs 2 additions, 1 deletionsubstrate/client/transaction-pool/tests/pool.rs
- substrate/test-utils/runtime/transaction-pool/src/lib.rs 25 additions, 2 deletionssubstrate/test-utils/runtime/transaction-pool/src/lib.rs
Please register or sign in to comment