mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-20 03:50:08 +00:00
Merge #11407: [tests] add functional test for mempoolreplacement command line arg
1088b5322 add functional test for mempoolreplacement command line arg (Gregory Sanders) Pull request description: Currently untested. Tree-SHA512: 2dd9d55a3499844e48b3774df9155fd650220b0761da45d16869570356bb0ed17a88d4efa4302a517dd96e1e9cb34113661b3c9df688736f6849201a3d544deb
This commit is contained in:
commit
8ddf60db7a
@ -62,13 +62,14 @@ def make_utxo(node, amount, confirmed=True, scriptPubKey=CScript([1])):
|
|||||||
class ReplaceByFeeTest(BitcoinTestFramework):
|
class ReplaceByFeeTest(BitcoinTestFramework):
|
||||||
|
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 1
|
self.num_nodes = 2
|
||||||
self.extra_args= [["-maxorphantx=1000",
|
self.extra_args= [["-maxorphantx=1000",
|
||||||
"-whitelist=127.0.0.1",
|
"-whitelist=127.0.0.1",
|
||||||
"-limitancestorcount=50",
|
"-limitancestorcount=50",
|
||||||
"-limitancestorsize=101",
|
"-limitancestorsize=101",
|
||||||
"-limitdescendantcount=200",
|
"-limitdescendantcount=200",
|
||||||
"-limitdescendantsize=101"]]
|
"-limitdescendantsize=101"],
|
||||||
|
["-mempoolreplacement=0"]]
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
make_utxo(self.nodes[0], 1*COIN)
|
make_utxo(self.nodes[0], 1*COIN)
|
||||||
@ -115,6 +116,8 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
|||||||
tx1a_hex = txToHex(tx1a)
|
tx1a_hex = txToHex(tx1a)
|
||||||
tx1a_txid = self.nodes[0].sendrawtransaction(tx1a_hex, True)
|
tx1a_txid = self.nodes[0].sendrawtransaction(tx1a_hex, True)
|
||||||
|
|
||||||
|
self.sync_all([self.nodes])
|
||||||
|
|
||||||
# Should fail because we haven't changed the fee
|
# Should fail because we haven't changed the fee
|
||||||
tx1b = CTransaction()
|
tx1b = CTransaction()
|
||||||
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||||
@ -123,12 +126,17 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
# This will raise an exception due to insufficient fee
|
# This will raise an exception due to insufficient fee
|
||||||
assert_raises_jsonrpc(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, True)
|
assert_raises_jsonrpc(-26, "insufficient fee", self.nodes[0].sendrawtransaction, tx1b_hex, True)
|
||||||
|
# This will raise an exception due to transaction replacement being disabled
|
||||||
|
assert_raises_jsonrpc(-26, "txn-mempool-conflict", self.nodes[1].sendrawtransaction, tx1b_hex, True)
|
||||||
|
|
||||||
# Extra 0.1 BTC fee
|
# Extra 0.1 BTC fee
|
||||||
tx1b = CTransaction()
|
tx1b = CTransaction()
|
||||||
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
tx1b.vin = [CTxIn(tx0_outpoint, nSequence=0)]
|
||||||
tx1b.vout = [CTxOut(int(0.9*COIN), CScript([b'b']))]
|
tx1b.vout = [CTxOut(int(0.9*COIN), CScript([b'b']))]
|
||||||
tx1b_hex = txToHex(tx1b)
|
tx1b_hex = txToHex(tx1b)
|
||||||
|
# Replacement still disabled even with "enough fee"
|
||||||
|
assert_raises_jsonrpc(-26, "txn-mempool-conflict", self.nodes[1].sendrawtransaction, tx1b_hex, True)
|
||||||
|
# Works when enabled
|
||||||
tx1b_txid = self.nodes[0].sendrawtransaction(tx1b_hex, True)
|
tx1b_txid = self.nodes[0].sendrawtransaction(tx1b_hex, True)
|
||||||
|
|
||||||
mempool = self.nodes[0].getrawmempool()
|
mempool = self.nodes[0].getrawmempool()
|
||||||
@ -138,6 +146,11 @@ class ReplaceByFeeTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
assert_equal(tx1b_hex, self.nodes[0].getrawtransaction(tx1b_txid))
|
assert_equal(tx1b_hex, self.nodes[0].getrawtransaction(tx1b_txid))
|
||||||
|
|
||||||
|
# Second node is running mempoolreplacement=0, will not replace originally-seen txn
|
||||||
|
mempool = self.nodes[1].getrawmempool()
|
||||||
|
assert tx1a_txid in mempool
|
||||||
|
assert tx1b_txid not in mempool
|
||||||
|
|
||||||
def test_doublespend_chain(self):
|
def test_doublespend_chain(self):
|
||||||
"""Doublespend of a long chain"""
|
"""Doublespend of a long chain"""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user