From abc332920a6eabab1915d7a26bece5117ebff09b Mon Sep 17 00:00:00 2001 From: yukang Date: Mon, 14 Aug 2023 21:57:29 +0800 Subject: [PATCH] add test case for RBFEnable and get_transaction_with_verbosity --- test/src/main.rs | 1 + test/src/specs/tx_pool/replace.rs | 39 ++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/test/src/main.rs b/test/src/main.rs index 0658c18d010..81da1d8a279 100644 --- a/test/src/main.rs +++ b/test/src/main.rs @@ -459,6 +459,7 @@ fn all_specs() -> Vec> { Box::new(TxsRelayOrder), Box::new(SendTxChain), Box::new(DifferentTxsWithSameInputWithOutRBF), + Box::new(RbfEnable), Box::new(RbfBasic), Box::new(RbfSameInput), Box::new(RbfOnlyForResolveDead), diff --git a/test/src/specs/tx_pool/replace.rs b/test/src/specs/tx_pool/replace.rs index 0bb4182d0f1..4e88c145c7a 100644 --- a/test/src/specs/tx_pool/replace.rs +++ b/test/src/specs/tx_pool/replace.rs @@ -7,6 +7,37 @@ use ckb_types::{ prelude::*, }; +pub struct RbfEnable; +impl Spec for RbfEnable { + fn run(&self, nodes: &mut Vec) { + let node0 = &nodes[0]; + + node0.mine_until_out_bootstrap_period(); + node0.new_block_with_blocking(|template| template.number.value() != 13); + let tx_hash_0 = node0.generate_transaction(); + info!("Generate 2 txs with same input"); + let tx1 = node0.new_transaction(tx_hash_0); + + let output = CellOutputBuilder::default() + .capacity(capacity_bytes!(70).pack()) + .build(); + + let tx1 = tx1.as_advanced_builder().set_outputs(vec![output]).build(); + + node0.rpc_client().send_transaction(tx1.data().into()); + let ret = node0 + .rpc_client() + .get_transaction_with_verbosity(tx1.hash(), 2); + + assert_eq!(ret.min_replace_fee, None); + } + + fn modify_app_config(&self, config: &mut ckb_app_config::CKBAppConfig) { + config.tx_pool.min_rbf_rate = ckb_types::core::FeeRate(100); + config.tx_pool.min_fee_rate = ckb_types::core::FeeRate(100); + } +} + pub struct RbfBasic; impl Spec for RbfBasic { fn run(&self, nodes: &mut Vec) { @@ -30,6 +61,12 @@ impl Spec for RbfBasic { .build(); node0.rpc_client().send_transaction(tx1.data().into()); + let ret = node0 + .rpc_client() + .get_transaction_with_verbosity(tx1.hash(), 2); + // min_replace_fee is 363 + assert_eq!(ret.min_replace_fee.unwrap().to_string(), "0x16b"); + let res = node0 .rpc_client() .send_transaction_result(tx2.data().into()); @@ -50,7 +87,7 @@ impl Spec for RbfBasic { assert!(!commit_txs_hash.contains(&tx1.hash())); assert!(commit_txs_hash.contains(&tx2.hash())); - // when tx1 was confirmed, tx2 should be rejected + // when tx2 should be committed let ret = node0.rpc_client().get_transaction(tx2.hash()); assert!( matches!(ret.tx_status.status, Status::Committed),