MCPcopy Create free account
hub / github.com/ElementsProject/elements / run_test

Method run_test

test/functional/mempool_limit.py:45–91  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

43 miniwallet.sendrawtransaction(from_node=node, tx_hex=tx.serialize().hex())
44
45 def run_test(self):
46 txouts = gen_return_txouts()
47 node = self.nodes[0]
48 miniwallet = MiniWallet(node)
49 relayfee = node.getnetworkinfo()['relayfee']
50
51 self.log.info('Check that mempoolminfee is minrelaytxfee')
52 assert_equal(node.getmempoolinfo()['minrelaytxfee'], Decimal('0.00001000'))
53 assert_equal(node.getmempoolinfo()['mempoolminfee'], Decimal('0.00001000'))
54
55 tx_batch_size = 25
56 num_of_batches = 3
57 # Generate UTXOs to flood the mempool
58 # 1 to create a tx initially that will be evicted from the mempool later
59 # 3 batches of multiple transactions with a fee rate much higher than the previous UTXO
60 # And 1 more to verify that this tx does not get added to the mempool with a fee rate less than the mempoolminfee
61 self.generate(miniwallet, 1 + (num_of_batches * tx_batch_size) + 1)
62
63 # Mine 99 blocks so that the UTXOs are allowed to be spent
64 self.generate(node, COINBASE_MATURITY - 1)
65
66 self.log.info('Create a mempool tx that will be evicted')
67 tx_to_be_evicted_id = miniwallet.send_self_transfer(from_node=node, fee_rate=relayfee)["txid"]
68
69 # Increase the tx fee rate to give the subsequent transactions a higher priority in the mempool
70 # The tx has an approx. vsize of 65k, i.e. multiplying the previous fee rate (in sats/kvB)
71 # by 130 should result in a fee that corresponds to 2x of that fee rate
72 base_fee = relayfee * 130
73
74 self.log.info("Fill up the mempool with txs with higher fee rate")
75 for batch_of_txid in range(num_of_batches):
76 fee = (batch_of_txid + 1) * base_fee
77 self.send_large_txs(node, miniwallet, txouts, fee, tx_batch_size)
78
79 self.log.info('The tx should be evicted by now')
80 # The number of transactions created should be greater than the ones present in the mempool
81 assert_greater_than(tx_batch_size * num_of_batches, len(node.getrawmempool()))
82 # Initial tx created should not be present in the mempool anymore as it had a lower fee rate
83 assert tx_to_be_evicted_id not in node.getrawmempool()
84
85 self.log.info('Check that mempoolminfee is larger than minrelaytxfee')
86 assert_equal(node.getmempoolinfo()['minrelaytxfee'], Decimal('0.00001000'))
87 assert_greater_than(node.getmempoolinfo()['mempoolminfee'], Decimal('0.00001000'))
88
89 # Deliberately try to create a tx with a fee less than the minimum mempool fee to assert that it does not get added to the mempool
90 self.log.info('Create a mempool tx that will not pass mempoolminfee')
91 assert_raises_rpc_error(-26, "mempool min fee not met", miniwallet.send_self_transfer, from_node=node, fee_rate=relayfee, mempool_valid=False)
92
93
94if __name__ == '__main__':

Callers

nothing calls this directly

Calls 9

send_self_transferMethod · 0.95
send_large_txsMethod · 0.95
gen_return_txoutsFunction · 0.90
MiniWalletClass · 0.90
assert_equalFunction · 0.90
assert_greater_thanFunction · 0.90
assert_raises_rpc_errorFunction · 0.90
infoMethod · 0.80
generateMethod · 0.45

Tested by

no test coverage detected