Skip to content

Commit 4999781

Browse files
committed
test: check custom ancestor limit in mempool_packages.py
To test the custom ancestor limit on node1 (passed by the argument -limitancestorcount), we check for three conditions: -> the # of txs in the node1 mempool is equal to the the limit -> all txs in node1 mempool are a subset of txs in node0 mempool -> the node1 mempool txs match the start of the constructed tx-chain
1 parent 89e9313 commit 4999781

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

test/functional/mempool_packages.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@
1414
satoshi_round,
1515
)
1616

17+
# default limits
1718
MAX_ANCESTORS = 25
1819
MAX_DESCENDANTS = 25
20+
# custom limits for node1
21+
MAX_ANCESTORS_CUSTOM = 5
1922

2023
class MempoolPackagesTest(BitcoinTestFramework):
2124
def set_test_params(self):
2225
self.num_nodes = 2
23-
self.extra_args = [["-maxorphantx=1000"], ["-maxorphantx=1000", "-limitancestorcount=5"]]
26+
self.extra_args = [
27+
["-maxorphantx=1000"],
28+
["-maxorphantx=1000", "-limitancestorcount={}".format(MAX_ANCESTORS_CUSTOM)],
29+
]
2430

2531
def skip_test_if_missing_module(self):
2632
self.skip_if_no_wallet()
@@ -188,7 +194,14 @@ def run_test(self):
188194
assert_equal(mempool[x]['descendantfees'], descendant_fees * COIN + 2000)
189195
assert_equal(mempool[x]['fees']['descendant'], descendant_fees+satoshi_round(0.00002))
190196

191-
# TODO: check that node1's mempool is as expected
197+
# Check that node1's mempool is as expected (-> custom ancestor limit)
198+
mempool0 = self.nodes[0].getrawmempool(False)
199+
mempool1 = self.nodes[1].getrawmempool(False)
200+
assert_equal(len(mempool1), MAX_ANCESTORS_CUSTOM)
201+
assert set(mempool1).issubset(set(mempool0))
202+
for tx in chain[:MAX_ANCESTORS_CUSTOM]:
203+
assert tx in mempool1
204+
# TODO: more detailed check of node1's mempool (fees etc.)
192205

193206
# TODO: test ancestor size limits
194207

0 commit comments

Comments
 (0)