Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_mining_basic.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2020 The Bitcoin developers | # Copyright (c) 2020 The Bitcoin 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. | ||||
""" | """ | ||||
Tests for Bitcoin ABC mining RPCs | Tests for Bitcoin ABC mining RPCs | ||||
""" | """ | ||||
from test_framework.cdefs import ( | from test_framework.cdefs import ( | ||||
BLOCK_MAXBYTES_MAXSIGCHECKS_RATIO, | BLOCK_MAXBYTES_MAXSIGCHECKS_RATIO, | ||||
DEFAULT_MAX_BLOCK_SIZE, | DEFAULT_MAX_BLOCK_SIZE, | ||||
) | ) | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
COIN, | XEC, | ||||
) | ) | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import ( | from test_framework.util import ( | ||||
assert_equal, | assert_equal, | ||||
assert_greater_than_or_equal, | assert_greater_than_or_equal, | ||||
connect_nodes, | connect_nodes, | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | def run_for_node(self, node, expectedMinerFundAddress): | ||||
# them are covered in mining_basic.py | # them are covered in mining_basic.py | ||||
assert_equal(node.getmempoolinfo()['size'], 0) | assert_equal(node.getmempoolinfo()['size'], 0) | ||||
assert_getblocktemplate({ | assert_getblocktemplate({ | ||||
'coinbasetxn': { | 'coinbasetxn': { | ||||
# We expect to start seeing the miner fund addresses since the | # We expect to start seeing the miner fund addresses since the | ||||
# next block will start enforcing them. | # next block will start enforcing them. | ||||
'minerfund': { | 'minerfund': { | ||||
'addresses': [expectedMinerFundAddress], | 'addresses': [expectedMinerFundAddress], | ||||
'minimumvalue': block_reward * 8 // 100 * COIN, | 'minimumvalue': block_reward * 8 // 100 * XEC, | ||||
}, | }, | ||||
}, | }, | ||||
# Although the coinbase value need not necessarily be the same as | # Although the coinbase value need not necessarily be the same as | ||||
# the last block due to halvings and fees, we know this to be true | # the last block due to halvings and fees, we know this to be true | ||||
# since we are not crossing a halving boundary and there are no | # since we are not crossing a halving boundary and there are no | ||||
# transactions in the mempool. | # transactions in the mempool. | ||||
'coinbasevalue': block_reward * COIN, | 'coinbasevalue': block_reward * XEC, | ||||
'mintime': AXION_ACTIVATION_TIME + 1, | 'mintime': AXION_ACTIVATION_TIME + 1, | ||||
}) | }) | ||||
# First block with the new rules | # First block with the new rules | ||||
node.generatetoaddress(1, address) | node.generatetoaddress(1, address) | ||||
# We expect the coinbase to have multiple outputs now | # We expect the coinbase to have multiple outputs now | ||||
coinbase = get_best_coinbase() | coinbase = get_best_coinbase() | ||||
assert_greater_than_or_equal(len(coinbase['vout']), 2) | assert_greater_than_or_equal(len(coinbase['vout']), 2) | ||||
total = Decimal() | total = Decimal() | ||||
for o in coinbase['vout']: | for o in coinbase['vout']: | ||||
total += o['value'] | total += o['value'] | ||||
assert_equal(total, block_reward) | assert_equal(total, block_reward) | ||||
assert_getblocktemplate({ | assert_getblocktemplate({ | ||||
'coinbasetxn': { | 'coinbasetxn': { | ||||
'minerfund': { | 'minerfund': { | ||||
'addresses': [expectedMinerFundAddress], | 'addresses': [expectedMinerFundAddress], | ||||
'minimumvalue': block_reward * 8 // 100 * COIN, | 'minimumvalue': block_reward * 8 // 100 * XEC, | ||||
}, | }, | ||||
}, | }, | ||||
# Again, we assume the coinbase value is the same as prior blocks. | # Again, we assume the coinbase value is the same as prior blocks. | ||||
'coinbasevalue': block_reward * COIN, | 'coinbasevalue': block_reward * XEC, | ||||
'mintime': AXION_ACTIVATION_TIME + 1, | 'mintime': AXION_ACTIVATION_TIME + 1, | ||||
}) | }) | ||||
# Move MTP forward | # Move MTP forward | ||||
node.setmocktime(AXION_ACTIVATION_TIME + 1) | node.setmocktime(AXION_ACTIVATION_TIME + 1) | ||||
node.generatetoaddress(6, address) | node.generatetoaddress(6, address) | ||||
assert_getblocktemplate({ | assert_getblocktemplate({ | ||||
'coinbasetxn': { | 'coinbasetxn': { | ||||
'minerfund': { | 'minerfund': { | ||||
'addresses': [expectedMinerFundAddress], | 'addresses': [expectedMinerFundAddress], | ||||
'minimumvalue': block_reward * 8 // 100 * COIN, | 'minimumvalue': block_reward * 8 // 100 * XEC, | ||||
}, | }, | ||||
}, | }, | ||||
'coinbasevalue': block_reward * COIN, | 'coinbasevalue': block_reward * XEC, | ||||
'mintime': AXION_ACTIVATION_TIME + 2, | 'mintime': AXION_ACTIVATION_TIME + 2, | ||||
}) | }) | ||||
def run_test(self): | def run_test(self): | ||||
# node0 is for connectivity only and is not mined on (see | # node0 is for connectivity only and is not mined on (see | ||||
# setup_network) | # setup_network) | ||||
self.run_for_node(self.nodes[1], MINER_FUND_ADDR) | self.run_for_node(self.nodes[1], MINER_FUND_ADDR) | ||||
self.run_for_node(self.nodes[2], MINER_FUND_LEGACY_ADDR) | self.run_for_node(self.nodes[2], MINER_FUND_LEGACY_ADDR) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
AbcMiningRPCTest().main() | AbcMiningRPCTest().main() |