qa: Premine to deterministic address with -disablewallet
Github-Pull: #14180
Rebased-From: faa669cbcd
This commit is contained in:
parent
8bc1badada
commit
86fadee990
10 changed files with 120 additions and 57 deletions
|
@ -168,6 +168,11 @@ class EstimateFeeTest(BitcoinTestFramework):
|
||||||
newmem.append(utx)
|
newmem.append(utx)
|
||||||
self.memutxo = newmem
|
self.memutxo = newmem
|
||||||
|
|
||||||
|
def import_deterministic_coinbase_privkeys(self):
|
||||||
|
self.start_nodes()
|
||||||
|
super().import_deterministic_coinbase_privkeys()
|
||||||
|
self.stop_nodes()
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.log.info("This test is time consuming, please be patient")
|
self.log.info("This test is time consuming, please be patient")
|
||||||
self.log.info("Splitting inputs so we can generate tx's")
|
self.log.info("Splitting inputs so we can generate tx's")
|
||||||
|
|
|
@ -40,6 +40,13 @@ class ZMQTest (BitcoinTestFramework):
|
||||||
def setup_nodes(self):
|
def setup_nodes(self):
|
||||||
skip_if_no_py3_zmq()
|
skip_if_no_py3_zmq()
|
||||||
skip_if_no_bitcoind_zmq(self)
|
skip_if_no_bitcoind_zmq(self)
|
||||||
|
|
||||||
|
# Import keys
|
||||||
|
self.add_nodes(self.num_nodes)
|
||||||
|
self.start_nodes()
|
||||||
|
super().import_deterministic_coinbase_privkeys()
|
||||||
|
self.stop_nodes()
|
||||||
|
|
||||||
import zmq
|
import zmq
|
||||||
|
|
||||||
# Initialize ZMQ context and socket.
|
# Initialize ZMQ context and socket.
|
||||||
|
@ -59,10 +66,12 @@ class ZMQTest (BitcoinTestFramework):
|
||||||
self.rawblock = ZMQSubscriber(socket, b"rawblock")
|
self.rawblock = ZMQSubscriber(socket, b"rawblock")
|
||||||
self.rawtx = ZMQSubscriber(socket, b"rawtx")
|
self.rawtx = ZMQSubscriber(socket, b"rawtx")
|
||||||
|
|
||||||
self.extra_args = [["-zmqpub%s=%s" % (sub.topic.decode(), address) for sub in [self.hashblock, self.hashtx, self.rawblock, self.rawtx]], []]
|
self.nodes[0].extra_args = ["-zmqpub%s=%s" % (sub.topic.decode(), address) for sub in [self.hashblock, self.hashtx, self.rawblock, self.rawtx]]
|
||||||
self.add_nodes(self.num_nodes, self.extra_args)
|
|
||||||
self.start_nodes()
|
self.start_nodes()
|
||||||
|
|
||||||
|
def import_deterministic_coinbase_privkeys(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
try:
|
try:
|
||||||
self._zmq_test()
|
self._zmq_test()
|
||||||
|
|
|
@ -34,7 +34,7 @@ class MempoolPackagesTest(BitcoinTestFramework):
|
||||||
return (txid, send_value)
|
return (txid, send_value)
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
''' Mine some blocks and have them mature. '''
|
# Mine some blocks and have them mature.
|
||||||
self.nodes[0].generate(101)
|
self.nodes[0].generate(101)
|
||||||
utxo = self.nodes[0].listunspent(10)
|
utxo = self.nodes[0].listunspent(10)
|
||||||
txid = utxo[0]['txid']
|
txid = utxo[0]['txid']
|
||||||
|
|
|
@ -70,4 +70,3 @@ class GetBlockTemplateLPTest(BitcoinTestFramework):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
GetBlockTemplateLPTest().main()
|
GetBlockTemplateLPTest().main()
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,10 @@ from test_framework.mininode import (
|
||||||
class BlockchainTest(BitcoinTestFramework):
|
class BlockchainTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 1
|
self.num_nodes = 1
|
||||||
self.extra_args = [['-stopatheight=207', '-prune=1']]
|
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
|
self.restart_node(0, extra_args=['-stopatheight=207', '-prune=1']) # Set extra args with pruning after rescan is complete
|
||||||
|
|
||||||
self._test_getblockchaininfo()
|
self._test_getblockchaininfo()
|
||||||
self._test_getchaintxstats()
|
self._test_getchaintxstats()
|
||||||
self._test_gettxoutsetinfo()
|
self._test_gettxoutsetinfo()
|
||||||
|
@ -169,7 +170,7 @@ class BlockchainTest(BitcoinTestFramework):
|
||||||
assert_equal(res['transactions'], 200)
|
assert_equal(res['transactions'], 200)
|
||||||
assert_equal(res['height'], 200)
|
assert_equal(res['height'], 200)
|
||||||
assert_equal(res['txouts'], 200)
|
assert_equal(res['txouts'], 200)
|
||||||
assert_equal(res['bogosize'], 17000),
|
assert_equal(res['bogosize'], 15000),
|
||||||
assert_equal(res['bestblock'], node.getblockhash(200))
|
assert_equal(res['bestblock'], node.getblockhash(200))
|
||||||
size = res['disk_size']
|
size = res['disk_size']
|
||||||
assert size > 6400
|
assert size > 6400
|
||||||
|
|
|
@ -158,6 +158,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
raise SkipTest("--usecli specified but test does not support using CLI")
|
raise SkipTest("--usecli specified but test does not support using CLI")
|
||||||
self.setup_chain()
|
self.setup_chain()
|
||||||
self.setup_network()
|
self.setup_network()
|
||||||
|
self.import_deterministic_coinbase_privkeys()
|
||||||
self.run_test()
|
self.run_test()
|
||||||
success = TestStatus.PASSED
|
success = TestStatus.PASSED
|
||||||
except JSONRPCException as e:
|
except JSONRPCException as e:
|
||||||
|
@ -247,6 +248,19 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
self.add_nodes(self.num_nodes, extra_args)
|
self.add_nodes(self.num_nodes, extra_args)
|
||||||
self.start_nodes()
|
self.start_nodes()
|
||||||
|
|
||||||
|
def import_deterministic_coinbase_privkeys(self):
|
||||||
|
if self.setup_clean_chain:
|
||||||
|
return
|
||||||
|
|
||||||
|
for n in self.nodes:
|
||||||
|
try:
|
||||||
|
n.getwalletinfo()
|
||||||
|
except JSONRPCException as e:
|
||||||
|
assert str(e).startswith('Method not found')
|
||||||
|
continue
|
||||||
|
|
||||||
|
n.importprivkey(n.get_deterministic_priv_key()[1])
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
"""Tests must override this method to define test logic"""
|
"""Tests must override this method to define test logic"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
@ -415,7 +429,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
# Create cache directories, run bitcoinds:
|
# Create cache directories, run bitcoinds:
|
||||||
for i in range(MAX_NODES):
|
for i in range(MAX_NODES):
|
||||||
datadir = initialize_datadir(self.options.cachedir, i)
|
datadir = initialize_datadir(self.options.cachedir, i)
|
||||||
args = [self.options.bitcoind, "-datadir=" + datadir]
|
args = [self.options.bitcoind, "-datadir=" + datadir, '-disablewallet']
|
||||||
if i > 0:
|
if i > 0:
|
||||||
args.append("-connect=127.0.0.1:" + str(p2p_port(0)))
|
args.append("-connect=127.0.0.1:" + str(p2p_port(0)))
|
||||||
self.nodes.append(TestNode(i, get_datadir_path(self.options.cachedir, i), extra_conf=["bind=127.0.0.1"], extra_args=[], rpchost=None, timewait=self.rpc_timewait, bitcoind=self.options.bitcoind, bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=None))
|
self.nodes.append(TestNode(i, get_datadir_path(self.options.cachedir, i), extra_conf=["bind=127.0.0.1"], extra_args=[], rpchost=None, timewait=self.rpc_timewait, bitcoind=self.options.bitcoind, bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=None))
|
||||||
|
@ -439,7 +453,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
for peer in range(4):
|
for peer in range(4):
|
||||||
for j in range(25):
|
for j in range(25):
|
||||||
set_node_times(self.nodes, block_time)
|
set_node_times(self.nodes, block_time)
|
||||||
self.nodes[peer].generate(1)
|
self.nodes[peer].generatetoaddress(1, self.nodes[peer].get_deterministic_priv_key()[0])
|
||||||
block_time += 10 * 60
|
block_time += 10 * 60
|
||||||
# Must sync before next peer starts generating blocks
|
# Must sync before next peer starts generating blocks
|
||||||
sync_blocks(self.nodes)
|
sync_blocks(self.nodes)
|
||||||
|
@ -453,8 +467,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
return os.path.join(get_datadir_path(self.options.cachedir, n), "regtest", *paths)
|
return os.path.join(get_datadir_path(self.options.cachedir, n), "regtest", *paths)
|
||||||
|
|
||||||
for i in range(MAX_NODES):
|
for i in range(MAX_NODES):
|
||||||
|
os.rmdir(cache_path(i, 'wallets')) # Remove empty wallets dir
|
||||||
for entry in os.listdir(cache_path(i)):
|
for entry in os.listdir(cache_path(i)):
|
||||||
if entry not in ['wallets', 'chainstate', 'blocks']:
|
if entry not in ['chainstate', 'blocks']:
|
||||||
os.remove(cache_path(i, entry))
|
os.remove(cache_path(i, entry))
|
||||||
|
|
||||||
for i in range(self.num_nodes):
|
for i in range(self.num_nodes):
|
||||||
|
|
|
@ -97,6 +97,22 @@ class TestNode():
|
||||||
|
|
||||||
self.p2ps = []
|
self.p2ps = []
|
||||||
|
|
||||||
|
def get_deterministic_priv_key(self):
|
||||||
|
"""Return a deterministic priv key in base58, that only depends on the node's index"""
|
||||||
|
PRIV_KEYS = [
|
||||||
|
# adress , privkey
|
||||||
|
('mjTkW3DjgyZck4KbiRusZsqTgaYTxdSz6z', 'cVpF924EspNh8KjYsfhgY96mmxvT6DgdWiTYMtMjuM74hJaU5psW'),
|
||||||
|
('msX6jQXvxiNhx3Q62PKeLPrhrqZQdSimTg', 'cUxsWyKyZ9MAQTaAhUQWJmBbSvHMwSmuv59KgxQV7oZQU3PXN3KE'),
|
||||||
|
('mnonCMyH9TmAsSj3M59DsbH8H63U3RKoFP', 'cTrh7dkEAeJd6b3MRX9bZK8eRmNqVCMH3LSUkE3dSFDyzjU38QxK'),
|
||||||
|
('mqJupas8Dt2uestQDvV2NH3RU8uZh2dqQR', 'cVuKKa7gbehEQvVq717hYcbE9Dqmq7KEBKqWgWrYBa2CKKrhtRim'),
|
||||||
|
('msYac7Rvd5ywm6pEmkjyxhbCDKqWsVeYws', 'cQDCBuKcjanpXDpCqacNSjYfxeQj8G6CAtH1Dsk3cXyqLNC4RPuh'),
|
||||||
|
('n2rnuUnwLgXqf9kk2kjvVm8R5BZK1yxQBi', 'cQakmfPSLSqKHyMFGwAqKHgWUiofJCagVGhiB4KCainaeCSxeyYq'),
|
||||||
|
('myzuPxRwsf3vvGzEuzPfK9Nf2RfwauwYe6', 'cQMpDLJwA8DBe9NcQbdoSb1BhmFxVjWD5gRyrLZCtpuF9Zi3a9RK'),
|
||||||
|
('mumwTaMtbxEPUswmLBBN3vM9oGRtGBrys8', 'cSXmRKXVcoouhNNVpcNKFfxsTsToY5pvB9DVsFksF1ENunTzRKsy'),
|
||||||
|
('mpV7aGShMkJCZgbW7F6iZgrvuPHjZjH9qg', 'cSoXt6tm3pqy43UMabY6eUTmR3eSUYFtB2iNQDGgb3VUnRsQys2k'),
|
||||||
|
]
|
||||||
|
return PRIV_KEYS[self.index]
|
||||||
|
|
||||||
def _node_msg(self, msg: str) -> str:
|
def _node_msg(self, msg: str) -> str:
|
||||||
"""Return a modified msg that identifies this node by its index as a debugging aid."""
|
"""Return a modified msg that identifies this node by its index as a debugging aid."""
|
||||||
return "[node %d] %s" % (self.index, msg)
|
return "[node %d] %s" % (self.index, msg)
|
||||||
|
|
|
@ -29,10 +29,14 @@ def read_dump(file_name, addrs, script_addrs, hd_master_addr_old):
|
||||||
# only read non comment lines
|
# only read non comment lines
|
||||||
if line[0] != "#" and len(line) > 10:
|
if line[0] != "#" and len(line) > 10:
|
||||||
# split out some data
|
# split out some data
|
||||||
key_label, comment = line.split("#")
|
key_date_label, comment = line.split("#")
|
||||||
# key = key_label.split(" ")[0]
|
key_date_label = key_date_label.split(" ")
|
||||||
keytype = key_label.split(" ")[2]
|
# key = key_date_label[0]
|
||||||
if len(comment) > 1:
|
date = key_date_label[1]
|
||||||
|
keytype = key_date_label[2]
|
||||||
|
if not len(comment) or date.startswith('1970'):
|
||||||
|
continue
|
||||||
|
|
||||||
addr_keypath = comment.split(" addr=")[1]
|
addr_keypath = comment.split(" addr=")[1]
|
||||||
addr = addr_keypath.split(" ")[0]
|
addr = addr_keypath.split(" ")[0]
|
||||||
keypath = None
|
keypath = None
|
||||||
|
@ -116,7 +120,7 @@ class WalletDumpTest(BitcoinTestFramework):
|
||||||
read_dump(wallet_unenc_dump, addrs, script_addrs, None)
|
read_dump(wallet_unenc_dump, addrs, script_addrs, None)
|
||||||
assert_equal(found_addr, test_addr_count) # all keys must be in the dump
|
assert_equal(found_addr, test_addr_count) # all keys must be in the dump
|
||||||
assert_equal(found_script_addr, 2) # all scripts must be in the dump
|
assert_equal(found_script_addr, 2) # all scripts must be in the dump
|
||||||
assert_equal(found_addr_chg, 50) # 50 blocks where mined
|
assert_equal(found_addr_chg, 0) # 0 blocks where mined
|
||||||
assert_equal(found_addr_rsv, 90 * 2) # 90 keys plus 100% internal keys
|
assert_equal(found_addr_rsv, 90 * 2) # 90 keys plus 100% internal keys
|
||||||
assert_equal(witness_addr_ret, witness_addr) # p2sh-p2wsh address added to the first key
|
assert_equal(witness_addr_ret, witness_addr) # p2sh-p2wsh address added to the first key
|
||||||
|
|
||||||
|
@ -132,7 +136,7 @@ class WalletDumpTest(BitcoinTestFramework):
|
||||||
read_dump(wallet_enc_dump, addrs, script_addrs, hd_master_addr_unenc)
|
read_dump(wallet_enc_dump, addrs, script_addrs, hd_master_addr_unenc)
|
||||||
assert_equal(found_addr, test_addr_count)
|
assert_equal(found_addr, test_addr_count)
|
||||||
assert_equal(found_script_addr, 2)
|
assert_equal(found_script_addr, 2)
|
||||||
assert_equal(found_addr_chg, 90*2 + 50) # old reserve keys are marked as change now
|
assert_equal(found_addr_chg, 90 * 2) # old reserve keys are marked as change now
|
||||||
assert_equal(found_addr_rsv, 90 * 2)
|
assert_equal(found_addr_rsv, 90 * 2)
|
||||||
assert_equal(witness_addr_ret, witness_addr)
|
assert_equal(witness_addr_ret, witness_addr)
|
||||||
|
|
||||||
|
|
|
@ -116,10 +116,19 @@ class ImportRescanTest(BitcoinTestFramework):
|
||||||
extra_args[i] += ["-prune=1"]
|
extra_args[i] += ["-prune=1"]
|
||||||
|
|
||||||
self.add_nodes(self.num_nodes, extra_args=extra_args)
|
self.add_nodes(self.num_nodes, extra_args=extra_args)
|
||||||
|
|
||||||
|
# Import keys
|
||||||
|
self.start_nodes(extra_args=[[]] * self.num_nodes)
|
||||||
|
super().import_deterministic_coinbase_privkeys()
|
||||||
|
self.stop_nodes()
|
||||||
|
|
||||||
self.start_nodes()
|
self.start_nodes()
|
||||||
for i in range(1, self.num_nodes):
|
for i in range(1, self.num_nodes):
|
||||||
connect_nodes(self.nodes[i], 0)
|
connect_nodes(self.nodes[i], 0)
|
||||||
|
|
||||||
|
def import_deterministic_coinbase_privkeys(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
# Create one transaction on node 0 with a unique amount for
|
# Create one transaction on node 0 with a unique amount for
|
||||||
# each possible type of wallet import RPC.
|
# each possible type of wallet import RPC.
|
||||||
|
|
|
@ -18,6 +18,11 @@ class ReceivedByTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 2
|
self.num_nodes = 2
|
||||||
|
|
||||||
|
def import_deterministic_coinbase_privkeys(self):
|
||||||
|
assert_equal(0, len(self.nodes[1].listreceivedbyaddress(minconf=0, include_empty=True, include_watchonly=True)))
|
||||||
|
super().import_deterministic_coinbase_privkeys()
|
||||||
|
self.num_cb_reward_addresses = len(self.nodes[1].listreceivedbyaddress(minconf=0, include_empty=True, include_watchonly=True))
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
# Generate block to get out of IBD
|
# Generate block to get out of IBD
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
|
@ -64,7 +69,7 @@ class ReceivedByTest(BitcoinTestFramework):
|
||||||
assert_raises_rpc_error(-4, "address_filter parameter was invalid", self.nodes[1].listreceivedbyaddress, minconf=0, include_empty=True, include_watchonly=True, address_filter="bamboozling")
|
assert_raises_rpc_error(-4, "address_filter parameter was invalid", self.nodes[1].listreceivedbyaddress, minconf=0, include_empty=True, include_watchonly=True, address_filter="bamboozling")
|
||||||
# Another address receive money
|
# Another address receive money
|
||||||
res = self.nodes[1].listreceivedbyaddress(0, True, True)
|
res = self.nodes[1].listreceivedbyaddress(0, True, True)
|
||||||
assert_equal(len(res), 2) # Right now 2 entries
|
assert_equal(len(res), 2 + self.num_cb_reward_addresses) # Right now 2 entries
|
||||||
other_addr = self.nodes[1].getnewaddress()
|
other_addr = self.nodes[1].getnewaddress()
|
||||||
txid2 = self.nodes[0].sendtoaddress(other_addr, 0.1)
|
txid2 = self.nodes[0].sendtoaddress(other_addr, 0.1)
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
|
@ -81,7 +86,7 @@ class ReceivedByTest(BitcoinTestFramework):
|
||||||
assert_equal(len(res), 1)
|
assert_equal(len(res), 1)
|
||||||
# Should be two entries though without filter
|
# Should be two entries though without filter
|
||||||
res = self.nodes[1].listreceivedbyaddress(0, True, True)
|
res = self.nodes[1].listreceivedbyaddress(0, True, True)
|
||||||
assert_equal(len(res), 3) # Became 3 entries
|
assert_equal(len(res), 3 + self.num_cb_reward_addresses) # Became 3 entries
|
||||||
|
|
||||||
# Not on random addr
|
# Not on random addr
|
||||||
other_addr = self.nodes[0].getnewaddress() # note on node[0]! just a random addr
|
other_addr = self.nodes[0].getnewaddress() # note on node[0]! just a random addr
|
||||||
|
|
Loading…
Reference in a new issue