mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
098748ac6a
76a84c0a6cac3df711b1ed907a46c905cb85c485 test: speedup wallet_coinbase_category.py (furszy) Pull request description: No need to create a chain (200 extra blocks), nor use the cache, for it. Top commit has no ACKs. Tree-SHA512: beec64ba6c580d475e19700371ae155f4f3d74325879802da83d02f4153a752d5829b8a4ed77e0c893e79cbc26f66389eed90ac2e8b03a59f6c630ee9333355c
61 lines
2.3 KiB
Python
Executable File
61 lines
2.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2014-2018 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
"""Test coinbase transactions return the correct categories.
|
|
|
|
Tests listtransactions, listsinceblock, and gettransaction.
|
|
"""
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.util import (
|
|
assert_array_result
|
|
)
|
|
|
|
class CoinbaseCategoryTest(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.num_nodes = 1
|
|
self.setup_clean_chain = True
|
|
|
|
def skip_test_if_missing_module(self):
|
|
self.skip_if_no_wallet()
|
|
|
|
def assert_category(self, category, address, txid, skip):
|
|
assert_array_result(self.nodes[0].listtransactions(skip=skip),
|
|
{"address": address},
|
|
{"category": category})
|
|
assert_array_result(self.nodes[0].listsinceblock()["transactions"],
|
|
{"address": address},
|
|
{"category": category})
|
|
assert_array_result(self.nodes[0].gettransaction(txid)["details"],
|
|
{"address": address},
|
|
{"category": category})
|
|
|
|
def run_test(self):
|
|
# Generate one block to an address
|
|
address = self.nodes[0].getnewaddress()
|
|
self.nodes[0].generatetoaddress(1, address)
|
|
hash = self.nodes[0].getbestblockhash()
|
|
txid = self.nodes[0].getblock(hash)["tx"][0]
|
|
|
|
# Coinbase transaction is immature after 1 confirmation
|
|
self.assert_category("immature", address, txid, 0)
|
|
|
|
# Mine another 99 blocks on top
|
|
self.nodes[0].generate(99)
|
|
# Coinbase transaction is still immature after 100 confirmations
|
|
self.assert_category("immature", address, txid, 99)
|
|
|
|
# Mine one more block
|
|
self.nodes[0].generate(1)
|
|
# Coinbase transaction is now matured, so category is "generate"
|
|
self.assert_category("generate", address, txid, 100)
|
|
|
|
# Orphan block that paid to address
|
|
self.nodes[0].invalidateblock(hash)
|
|
# Coinbase transaction is now orphaned
|
|
self.assert_category("orphan", address, txid, 100)
|
|
|
|
if __name__ == '__main__':
|
|
CoinbaseCategoryTest().main()
|