Skip to content

Commit 1088b53

Browse files
committed
add functional test for mempoolreplacement command line arg
1 parent a72003d commit 1088b53

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

test/functional/replace-by-fee.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ def make_utxo(node, amount, confirmed=True, scriptPubKey=CScript([1])):
6262
class ReplaceByFeeTest(BitcoinTestFramework):
6363

6464
def set_test_params(self):
65-
self.num_nodes = 1
65+
self.num_nodes = 2
6666
self.extra_args= [["-maxorphantx=1000",
6767
"-whitelist=127.0.0.1",
6868
"-limitancestorcount=50",
6969
"-limitancestorsize=101",
7070
"-limitdescendantcount=200",
71-
"-limitdescendantsize=101"]]
71+
"-limitdescendantsize=101"],
72+
["-mempoolreplacement=0"]]
7273

7374
def run_test(self):
7475
make_utxo(self.nodes[0], 1*COIN)
@@ -115,6 +116,8 @@ def test_simple_doublespend(self):
115116
tx1a_hex = txToHex(tx1a)
116117
tx1a_txid = self.nodes[0].sendrawtransaction(tx1a_hex, True)
117118

119+
self.sync_all([self.nodes])
120+
118121
# Should fail because we haven't changed the fee
119122
tx1b = CTransaction()
120123
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
@@ -123,12 +126,17 @@ def test_simple_doublespend(self):
123126

124127
# This will raise an exception due to insufficient fee
125128
assert_raises_jsonrpc(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, True)
129+
# This will raise an exception due to transaction replacement being disabled
130+
assert_raises_jsonrpc(-26, "txn-mempool-conflict", self.nodes[1].sendrawtransaction, tx1b_hex, True)
126131

127132
# Extra 0.1 BTC fee
128133
tx1b = CTransaction()
129134
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
130135
tx1b.vout = [CTxOut(int(0.9*COIN), CScript([b'b']))]
131136
tx1b_hex = txToHex(tx1b)
137+
# Replacement still disabled even with "enough fee"
138+
assert_raises_jsonrpc(-26, "txn-mempool-conflict", self.nodes[1].sendrawtransaction, tx1b_hex, True)
139+
# Works when enabled
132140
tx1b_txid = self.nodes[0].sendrawtransaction(tx1b_hex, True)
133141

134142
mempool = self.nodes[0].getrawmempool()
@@ -138,6 +146,11 @@ def test_simple_doublespend(self):
138146

139147
assert_equal(tx1b_hex, self.nodes[0].getrawtransaction(tx1b_txid))
140148

149+
# Second node is running mempoolreplacement=0, will not replace originally-seen txn
150+
mempool = self.nodes[1].getrawmempool()
151+
assert tx1a_txid in mempool
152+
assert tx1b_txid not in mempool
153+
141154
def test_doublespend_chain(self):
142155
"""Doublespend of a long chain"""
143156

0 commit comments

Comments
 (0)