Changeset View
Changeset View
Standalone View
Standalone View
test/functional/mempool_accept.py
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
coin = node.listunspent()[0] # Pick a random coin(base) to spend | coin = node.listunspent()[0] # Pick a random coin(base) to spend | ||||
raw_tx_in_block = node.signrawtransactionwithwallet(node.createrawtransaction( | raw_tx_in_block = node.signrawtransactionwithwallet(node.createrawtransaction( | ||||
inputs=[{'txid': coin['txid'], 'vout': coin['vout']}], | inputs=[{'txid': coin['txid'], 'vout': coin['vout']}], | ||||
outputs=[{node.getnewaddress(): 0.3}, {node.getnewaddress(): 49}], | outputs=[{node.getnewaddress(): 0.3}, {node.getnewaddress(): 49}], | ||||
))['hex'] | ))['hex'] | ||||
txid_in_block = node.sendrawtransaction( | txid_in_block = node.sendrawtransaction( | ||||
hexstring=raw_tx_in_block, allowhighfees=True) | hexstring=raw_tx_in_block, allowhighfees=True) | ||||
node.generate(1) | node.generate(1) | ||||
self.mempool_size = 0 | |||||
self.check_mempool_result( | self.check_mempool_result( | ||||
result_expected=[{'txid': txid_in_block, 'allowed': False, | result_expected=[{'txid': txid_in_block, 'allowed': False, | ||||
'reject-reason': '18: txn-already-known'}], | 'reject-reason': '18: txn-already-known'}], | ||||
rawtxs=[raw_tx_in_block], | rawtxs=[raw_tx_in_block], | ||||
) | ) | ||||
self.log.info('A transaction not in the mempool') | self.log.info('A transaction not in the mempool') | ||||
fee = 0.00000700 | fee = 0.00000700 | ||||
raw_tx_0 = node.signrawtransactionwithwallet(node.createrawtransaction( | raw_tx_0 = node.signrawtransactionwithwallet(node.createrawtransaction( | ||||
inputs=[{"txid": txid_in_block, "vout": 0, | inputs=[{"txid": txid_in_block, "vout": 0, | ||||
"sequence": 0xfffffffd}], | "sequence": 0xfffffffd}], | ||||
outputs=[{node.getnewaddress(): 0.3 - fee}], | outputs=[{node.getnewaddress(): 0.3 - fee}], | ||||
))['hex'] | ))['hex'] | ||||
tx = CTransaction() | tx = CTransaction() | ||||
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_0))) | tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_0))) | ||||
txid_0 = tx.rehash() | txid_0 = tx.rehash() | ||||
self.check_mempool_result( | self.check_mempool_result( | ||||
result_expected=[{'txid': txid_0, 'allowed': True}], | result_expected=[{'txid': txid_0, 'allowed': True}], | ||||
rawtxs=[raw_tx_0], | rawtxs=[raw_tx_0], | ||||
) | ) | ||||
self.log.info('A final transaction not in the mempool') | |||||
coin = node.listunspent()[0] # Pick a random coin(base) to spend | |||||
raw_tx_final = node.signrawtransactionwithwallet(node.createrawtransaction( | |||||
inputs=[{'txid': coin['txid'], 'vout': coin['vout'], | |||||
"sequence": 0xffffffff}], # SEQUENCE_FINAL | |||||
outputs=[{node.getnewaddress(): 0.025}], | |||||
locktime=node.getblockcount() + 2000, # Can be anything | |||||
))['hex'] | |||||
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_final))) | |||||
self.check_mempool_result( | |||||
result_expected=[{'txid': tx.rehash(), 'allowed': True}], | |||||
rawtxs=[tx.serialize().hex()], | |||||
allowhighfees=True, | |||||
) | |||||
node.sendrawtransaction(hexstring=raw_tx_final, allowhighfees=True) | |||||
self.mempool_size += 1 | |||||
self.log.info('A transaction in the mempool') | self.log.info('A transaction in the mempool') | ||||
node.sendrawtransaction(hexstring=raw_tx_0) | node.sendrawtransaction(hexstring=raw_tx_0) | ||||
self.mempool_size = 1 | self.mempool_size += 1 | ||||
self.check_mempool_result( | self.check_mempool_result( | ||||
result_expected=[{'txid': txid_0, 'allowed': False, | result_expected=[{'txid': txid_0, 'allowed': False, | ||||
'reject-reason': '18: txn-already-in-mempool'}], | 'reject-reason': '18: txn-already-in-mempool'}], | ||||
rawtxs=[raw_tx_0], | rawtxs=[raw_tx_0], | ||||
) | ) | ||||
# Removed RBF test | # Removed RBF test | ||||
# self.log.info('A transaction that replaces a mempool transaction') | # self.log.info('A transaction that replaces a mempool transaction') | ||||
▲ Show 20 Lines • Show All 219 Lines • Show Last 20 Lines |