Changeset View
Changeset View
Standalone View
Standalone View
test/functional/mining_prioritisetransaction.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2015-2016 The Bitcoin Core developers | # Copyright (c) 2015-2016 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
# | # | ||||
# Test PrioritiseTransaction code | # Test PrioritiseTransaction code | ||||
# | # | ||||
import time | |||||
from test_framework.blocktools import ( | from test_framework.blocktools import ( | ||||
create_confirmed_utxos, | create_confirmed_utxos, | ||||
send_big_transactions, | send_big_transactions, | ||||
) | ) | ||||
# FIXME: review how this test needs to be adapted w.r.t _LEGACY_MAX_BLOCK_SIZE | # FIXME: review how this test needs to be adapted w.r.t _LEGACY_MAX_BLOCK_SIZE | ||||
from test_framework.cdefs import LEGACY_MAX_BLOCK_SIZE | from test_framework.cdefs import LEGACY_MAX_BLOCK_SIZE | ||||
from test_framework.messages import COIN | from test_framework.messages import COIN | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import assert_equal, assert_raises_rpc_error, time | from test_framework.util import assert_equal, assert_raises_rpc_error | ||||
class PrioritiseTransactionTest(BitcoinTestFramework): | class PrioritiseTransactionTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
self.extra_args = [["-printpriority=1"], ["-printpriority=1"]] | self.extra_args = [["-printpriority=1"], ["-printpriority=1"]] | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
assert_equal(self.nodes[0].sendrawtransaction(tx2_hex), tx2_id) | assert_equal(self.nodes[0].sendrawtransaction(tx2_hex), tx2_id) | ||||
assert(tx2_id in self.nodes[0].getrawmempool()) | assert(tx2_id in self.nodes[0].getrawmempool()) | ||||
# Test that calling prioritisetransaction is sufficient to trigger | # Test that calling prioritisetransaction is sufficient to trigger | ||||
# getblocktemplate to (eventually) return a new block. | # getblocktemplate to (eventually) return a new block. | ||||
mock_time = int(time.time()) | mock_time = int(time.time()) | ||||
self.nodes[0].setmocktime(mock_time) | self.nodes[0].setmocktime(mock_time) | ||||
template = self.nodes[0].getblocktemplate() | template = self.nodes[0].getblocktemplate() | ||||
self.nodes[0].prioritisetransaction(txid, 0, -int(self.relayfee*COIN)) | self.nodes[0].prioritisetransaction( | ||||
tx2_id, 0, -int(self.relayfee * COIN)) | |||||
self.nodes[0].setmocktime(mock_time+10) | self.nodes[0].setmocktime(mock_time + 10) | ||||
new_template = self.nodes[0].getblocktemplate() | new_template = self.nodes[0].getblocktemplate() | ||||
assert(template != new_template) | assert(template != new_template) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
PrioritiseTransactionTest().main() | PrioritiseTransactionTest().main() |