mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
910dc0c2a6
f3f6dde56e Test coinbase category in wallet rpcs (andrewtoth) e982f0b682 Add all category options to wallet rpc help (andrewtoth) Pull request description: The current helptext for `listtransactions`, `listsinceblock` and `gettransaction` only list two of the five possible options for `category`. This incorrectly implies that these are the only two options, and can cause problems if the other three options aren't accounted for. Also, some of the documentation is incorrect when specifying which options are returned for which categories. This PR updates the helptext for these RPCs and adds a functional regression test for the cases when the other three categories are returned. Tree-SHA512: 67dd7ff6269a3b0f17f5d1a61b0ae1fb1f3778f05e1c440bfbb9b3a005c9c6d740abcace20f3d597cf2bd6779c494448690f13fab0bd2340f206213bc7890b51
60 lines
2.2 KiB
Python
Executable File
60 lines
2.2 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
|
|
|
|
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()
|