Changeset View
Changeset View
Standalone View
Standalone View
test/functional/mempool_unbroadcast.py
Show All 39 Lines | def test_broadcast(self): | ||||
create_confirmed_utxos(node, 10) | create_confirmed_utxos(node, 10) | ||||
disconnect_nodes(node, self.nodes[1]) | disconnect_nodes(node, self.nodes[1]) | ||||
self.log.info("Generate transactions that only node 0 knows about") | self.log.info("Generate transactions that only node 0 knows about") | ||||
# generate a wallet txn | # generate a wallet txn | ||||
addr = node.getnewaddress() | addr = node.getnewaddress() | ||||
wallet_tx_hsh = node.sendtoaddress(addr, 0.0001) | wallet_tx_hsh = node.sendtoaddress(addr, 100) | ||||
utxos = node.listunspent() | utxos = node.listunspent() | ||||
# generate a txn using sendrawtransaction | # generate a txn using sendrawtransaction | ||||
us0 = utxos.pop() | us0 = utxos.pop() | ||||
inputs = [{"txid": us0["txid"], "vout": us0["vout"]}] | inputs = [{"txid": us0["txid"], "vout": us0["vout"]}] | ||||
outputs = {addr: 0.0001} | outputs = {addr: 100} | ||||
tx = node.createrawtransaction(inputs, outputs) | tx = node.createrawtransaction(inputs, outputs) | ||||
node.settxfee(min_relay_fee) | node.settxfee(min_relay_fee) | ||||
txF = node.fundrawtransaction(tx) | txF = node.fundrawtransaction(tx) | ||||
txFS = node.signrawtransactionwithwallet(txF["hex"]) | txFS = node.signrawtransactionwithwallet(txF["hex"]) | ||||
rpc_tx_hsh = node.sendrawtransaction(txFS["hex"]) | rpc_tx_hsh = node.sendrawtransaction(txFS["hex"]) | ||||
# check transactions are in unbroadcast using rpc | # check transactions are in unbroadcast using rpc | ||||
mempoolinfo = self.nodes[0].getmempoolinfo() | mempoolinfo = self.nodes[0].getmempoolinfo() | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | def test_txn_removal(self): | ||||
self.log.info( | self.log.info( | ||||
"Test that transactions removed from mempool are removed from unbroadcast set") | "Test that transactions removed from mempool are removed from unbroadcast set") | ||||
node = self.nodes[0] | node = self.nodes[0] | ||||
# since the node doesn't have any connections, it will not receive | # since the node doesn't have any connections, it will not receive | ||||
# any GETDATAs & thus the transaction will remain in the unbroadcast | # any GETDATAs & thus the transaction will remain in the unbroadcast | ||||
# set. | # set. | ||||
addr = node.getnewaddress() | addr = node.getnewaddress() | ||||
txhsh = node.sendtoaddress(addr, 0.0001) | txhsh = node.sendtoaddress(addr, 100) | ||||
# check transaction was removed from unbroadcast set due to presence in | # check transaction was removed from unbroadcast set due to presence in | ||||
# a block | # a block | ||||
removal_reason = "Removed {} from set of unbroadcast txns before " \ | removal_reason = "Removed {} from set of unbroadcast txns before " \ | ||||
"confirmation that txn was sent out".format(txhsh) | "confirmation that txn was sent out".format(txhsh) | ||||
with node.assert_debug_log([removal_reason]): | with node.assert_debug_log([removal_reason]): | ||||
node.generate(1) | node.generate(1) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
MempoolUnbroadcastTest().main() | MempoolUnbroadcastTest().main() |