Changeset View
Changeset View
Standalone View
Standalone View
test/functional/prioritise_transaction.py
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
assert(len(utxo_list) > 0) | assert(len(utxo_list) > 0) | ||||
utxo = utxo_list[0] | utxo = utxo_list[0] | ||||
inputs = [] | inputs = [] | ||||
outputs = {} | outputs = {} | ||||
inputs.append({"txid": utxo["txid"], "vout": utxo["vout"]}) | inputs.append({"txid": utxo["txid"], "vout": utxo["vout"]}) | ||||
outputs[self.nodes[0].getnewaddress()] = utxo["amount"] - self.relayfee | outputs[self.nodes[0].getnewaddress()] = utxo["amount"] - self.relayfee | ||||
raw_tx = self.nodes[0].createrawtransaction(inputs, outputs) | raw_tx = self.nodes[0].createrawtransaction(inputs, outputs) | ||||
tx_hex = self.nodes[0].signrawtransaction(raw_tx)["hex"] | tx_hex = self.nodes[0].signrawtransactionwithwallet(raw_tx)["hex"] | ||||
txid = self.nodes[0].sendrawtransaction(tx_hex) | txid = self.nodes[0].sendrawtransaction(tx_hex) | ||||
# A tx that spends an in-mempool tx has 0 priority, so we can use it to | # A tx that spends an in-mempool tx has 0 priority, so we can use it to | ||||
# test the effect of using prioritise transaction for mempool | # test the effect of using prioritise transaction for mempool | ||||
# acceptance | # acceptance | ||||
inputs = [] | inputs = [] | ||||
inputs.append({"txid": txid, "vout": 0}) | inputs.append({"txid": txid, "vout": 0}) | ||||
outputs = {} | outputs = {} | ||||
outputs[self.nodes[0].getnewaddress()] = utxo["amount"] - self.relayfee | outputs[self.nodes[0].getnewaddress()] = utxo["amount"] - self.relayfee | ||||
raw_tx2 = self.nodes[0].createrawtransaction(inputs, outputs) | raw_tx2 = self.nodes[0].createrawtransaction(inputs, outputs) | ||||
tx2_hex = self.nodes[0].signrawtransaction(raw_tx2)["hex"] | tx2_hex = self.nodes[0].signrawtransactionwithwallet(raw_tx2)["hex"] | ||||
tx2_id = self.nodes[0].decoderawtransaction(tx2_hex)["txid"] | tx2_id = self.nodes[0].decoderawtransaction(tx2_hex)["txid"] | ||||
# This will raise an exception due to min relay fee not being met | # This will raise an exception due to min relay fee not being met | ||||
assert_raises_rpc_error(-26, "66: insufficient priority", | assert_raises_rpc_error(-26, "66: insufficient priority", | ||||
self.nodes[0].sendrawtransaction, tx2_hex) | self.nodes[0].sendrawtransaction, tx2_hex) | ||||
assert(tx2_id not in self.nodes[0].getrawmempool()) | assert(tx2_id not in self.nodes[0].getrawmempool()) | ||||
# This is a less than 1000-byte transaction, so just set the fee | # This is a less than 1000-byte transaction, so just set the fee | ||||
Show All 13 Lines |