QA: feature_rbf: Test full RBF mode

This commit is contained in:
Luke Dashjr 2020-07-23 17:51:37 +00:00
parent 3d8c6b87b5
commit c757b00501

View File

@ -25,7 +25,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
self.add_wallet_options(parser)
def set_test_params(self):
self.num_nodes = 3
self.num_nodes = 4
self.extra_args = [
[
"-maxorphantx=1000",
@ -42,6 +42,12 @@ class ReplaceByFeeTest(BitcoinTestFramework):
"-mempoolreplacement=0",
],
]
self.extra_args.append(
[
*self.extra_args[0],
"-mempoolreplacement=fee,-optin",
],
)
self.supports_cli = False
def run_test(self):
@ -72,7 +78,10 @@ class ReplaceByFeeTest(BitcoinTestFramework):
self.test_too_many_replacements_with_default_mempool_params()
self.log.info("Running test opt-in...")
self.test_opt_in()
self.test_opt_in(fullrbf=False)
self.nodes[0], self.nodes[-1] = self.nodes[-1], self.nodes[0]
self.test_opt_in(fullrbf=True)
self.nodes[0], self.nodes[-1] = self.nodes[-1], self.nodes[0]
self.log.info("Running test RPC...")
self.test_rpc()
@ -484,7 +493,7 @@ class ReplaceByFeeTest(BitcoinTestFramework):
self.generate(normal_node, 1)
self.wallet.rescan_utxos()
def test_opt_in(self):
def test_opt_in(self, fullrbf):
"""Replacing should only work if orig tx opted in"""
tx0_outpoint = self.make_utxo(self.nodes[0], int(1.1 * COIN))
@ -500,14 +509,19 @@ class ReplaceByFeeTest(BitcoinTestFramework):
assert_equal(self.nodes[0].getmempoolentry(tx1a_utxo["txid"])['bip125-replaceable'], False)
# Shouldn't be able to double-spend
tx1b_hex = self.wallet.create_self_transfer(
tx1b_st = self.wallet.create_self_transfer(
utxo_to_spend=tx0_outpoint,
sequence=0,
fee=Decimal("0.2"),
)["hex"]
)
tx1b_hex = tx1b_st["hex"]
# This will raise an exception
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx1b_hex, 0)
if fullrbf:
self.nodes[0].sendrawtransaction(tx1b_hex, 0)
tx1a_utxo = tx1b_st["new_utxo"]
else:
# This will raise an exception
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx1b_hex, 0)
tx1_outpoint = self.make_utxo(self.nodes[0], int(1.1 * COIN))
@ -520,14 +534,19 @@ class ReplaceByFeeTest(BitcoinTestFramework):
)["new_utxo"]
# Still shouldn't be able to double-spend
tx2b_hex = self.wallet.create_self_transfer(
tx2b_st = self.wallet.create_self_transfer(
utxo_to_spend=tx1_outpoint,
sequence=0,
fee=Decimal("0.2"),
)["hex"]
)
tx2b_hex = tx2b_st["hex"]
# This will raise an exception
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx2b_hex, 0)
if fullrbf:
self.nodes[0].sendrawtransaction(tx2b_hex, 0)
tx2a_utxo = tx2b_st["new_utxo"]
else:
# This will raise an exception
assert_raises_rpc_error(-26, "txn-mempool-conflict", self.nodes[0].sendrawtransaction, tx2b_hex, 0)
# Now create a new transaction that spends from tx1a and tx2a
# opt-in on one of the inputs
@ -559,6 +578,8 @@ class ReplaceByFeeTest(BitcoinTestFramework):
fee=Decimal("0.4"),
)
self.generate(self.nodes[0], 1) # clean mempool
def test_prioritised_transactions(self):
# Ensure that fee deltas used via prioritisetransaction are
# correctly used by replacement logic