Module Integration_test
Use these methods with a disposable integration-test node running Dummy proof of work. They change test chain state or exercise test-only block and transaction paths.
RPC for Integration Test.
Method process_block_without_verify
process block without any block verification.
Params
-
data- a JSONBlockobject. -
broadcast- true to enable broadcast(relay) the block to other peers.
Method truncate
truncate(target_tip_hash)target_tip_hash:H256
- result:
null
Truncate chain to specified tip hash, can only truncate less then 50000 blocks each time.
Params
target_tip_hash- specified header hash
Method generate_block
-
generate_block() -
result:
H256
Generate block(with verification) and broadcast the block.
Note that if called concurrently, it may return the hash of the same block.
Method generate_epochs
generate_epochs(num_epochs)num_epochs:EpochNumberWithFraction
- result:
EpochNumberWithFraction
Advance the local chain by the given epoch duration to test epoch transitions and maturity.
Returns the updated epoch number and its fractional progress after generating blocks.
Params
num_epochs- The number of epochs to generate.
Method notify_transaction
notify_transaction(transaction)transaction:Transaction
- result:
H256
Add transaction to tx-pool.
Params
transaction- specified transaction to add
Method generate_block_with_template
generate_block_with_template(block_template)block_template:BlockTemplate
- result:
H256
Build a block from the template, process it and relay it to the test node’s peers.
Params
block_template- The block template used to build the block.
Method send_test_transaction
send_test_transaction(tx, outputs_validator)tx:Transactionoutputs_validator:OutputsValidator|null
- result:
H256
Submits a new test local transaction into the transaction pool, only for testing. If the transaction is already in the pool, rebroadcast it to peers.
Params
transaction- The transaction.outputs_validator- Validates the transaction outputs before entering the tx-pool. (Optional, default is "passthrough").
Errors
PoolRejectedTransactionByOutputsValidator (-1102)- The transaction is rejected by the validator specified byoutputs_validator. If you really want to send transactions with advanced scripts, please setoutputs_validatorto "passthrough".PoolRejectedTransactionByMinFeeRate (-1104)- The transaction fee rate must be greater than or equal to the config optiontx_pool.min_fee_rate.PoolRejectedTransactionByMaxAncestorsCountLimit (-1105)- The ancestors count must be greater than or equal to the config optiontx_pool.max_ancestors_count.PoolIsFull (-1106)- Pool is full.PoolRejectedDuplicatedTransaction (-1107)- The transaction is already in the pool.TransactionFailedToResolve (-301)- Failed to resolve the referenced cells and headers used in the transaction, as inputs or dependencies.TransactionFailedToVerify (-302)- Failed to verify the transaction.