|
11 | 11 | def satoshi_round(amount):
|
12 | 12 | return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)
|
13 | 13 |
|
| 14 | +MAX_ANCESTORS = 25 |
| 15 | +MAX_DESCENDANTS = 25 |
| 16 | + |
14 | 17 | class MempoolPackagesTest(BitcoinTestFramework):
|
15 | 18 |
|
16 | 19 | def setup_network(self):
|
@@ -45,17 +48,17 @@ def run_test(self):
|
45 | 48 | value = utxo[0]['amount']
|
46 | 49 |
|
47 | 50 | fee = Decimal("0.0001")
|
48 |
| - # 100 transactions off a confirmed tx should be fine |
| 51 | + # MAX_ANCESTORS transactions off a confirmed tx should be fine |
49 | 52 | chain = []
|
50 |
| - for i in xrange(100): |
| 53 | + for i in xrange(MAX_ANCESTORS): |
51 | 54 | (txid, sent_value) = self.chain_transaction(self.nodes[0], txid, 0, value, fee, 1)
|
52 | 55 | value = sent_value
|
53 | 56 | chain.append(txid)
|
54 | 57 |
|
55 |
| - # Check mempool has 100 transactions in it, and descendant |
| 58 | + # Check mempool has MAX_ANCESTORS transactions in it, and descendant |
56 | 59 | # count and fees should look correct
|
57 | 60 | mempool = self.nodes[0].getrawmempool(True)
|
58 |
| - assert_equal(len(mempool), 100) |
| 61 | + assert_equal(len(mempool), MAX_ANCESTORS) |
59 | 62 | descendant_count = 1
|
60 | 63 | descendant_fees = 0
|
61 | 64 | descendant_size = 0
|
@@ -91,18 +94,18 @@ def run_test(self):
|
91 | 94 | for i in xrange(10):
|
92 | 95 | transaction_package.append({'txid': txid, 'vout': i, 'amount': sent_value})
|
93 | 96 |
|
94 |
| - for i in xrange(1000): |
| 97 | + for i in xrange(MAX_DESCENDANTS): |
95 | 98 | utxo = transaction_package.pop(0)
|
96 | 99 | try:
|
97 | 100 | (txid, sent_value) = self.chain_transaction(self.nodes[0], utxo['txid'], utxo['vout'], utxo['amount'], fee, 10)
|
98 | 101 | for j in xrange(10):
|
99 | 102 | transaction_package.append({'txid': txid, 'vout': j, 'amount': sent_value})
|
100 |
| - if i == 998: |
| 103 | + if i == MAX_DESCENDANTS - 2: |
101 | 104 | mempool = self.nodes[0].getrawmempool(True)
|
102 |
| - assert_equal(mempool[parent_transaction]['descendantcount'], 1000) |
| 105 | + assert_equal(mempool[parent_transaction]['descendantcount'], MAX_DESCENDANTS) |
103 | 106 | except JSONRPCException as e:
|
104 | 107 | print e.error['message']
|
105 |
| - assert_equal(i, 999) |
| 108 | + assert_equal(i, MAX_DESCENDANTS - 1) |
106 | 109 | print "tx that would create too large descendant package successfully rejected"
|
107 | 110 |
|
108 | 111 | # TODO: check that node1's mempool is as expected
|
|
0 commit comments