Skip to content

Commit

Permalink
test: Set some more Blackcoin values in test framework
Browse files Browse the repository at this point in the history
  • Loading branch information
lateminer committed Jan 27, 2024
1 parent 55f026c commit 06ff56e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 42 deletions.
30 changes: 15 additions & 15 deletions test/functional/feature_asmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test asmap config argument for ASN-based IP bucketing.
Verify node behaviour and debug log when launching bitcoind in these cases:
Verify node behaviour and debug log when launching blackmored in these cases:
1. `bitcoind` with no -asmap arg, using /16 prefix for IP bucketing
1. `blackmored` with no -asmap arg, using /16 prefix for IP bucketing
2. `bitcoind -asmap=<absolute path>`, using the unit test skeleton asmap
2. `blackmored -asmap=<absolute path>`, using the unit test skeleton asmap
3. `bitcoind -asmap=<relative path>`, using the unit test skeleton asmap
3. `blackmored -asmap=<relative path>`, using the unit test skeleton asmap
4. `bitcoind -asmap/-asmap=` with no file specified, using the default asmap
4. `blackmored -asmap/-asmap=` with no file specified, using the default asmap
5. `bitcoind -asmap` restart with an addrman containing new and tried entries
5. `blackmored -asmap` restart with an addrman containing new and tried entries
6. `bitcoind -asmap` with no file specified and a missing default asmap file
6. `blackmored -asmap` with no file specified and a missing default asmap file
7. `bitcoind -asmap` with an empty (unparsable) default asmap file
7. `blackmored -asmap` with an empty (unparsable) default asmap file
The tests are order-independent.
Expand Down Expand Up @@ -47,13 +47,13 @@ def fill_addrman(self, node_id):
self.nodes[node_id].addpeeraddress(address=f"101.{addr}.0.0", tried=tried, port=15714)

def test_without_asmap_arg(self):
self.log.info('Test bitcoind with no -asmap arg passed')
self.log.info('Test blackmored with no -asmap arg passed')
self.stop_node(0)
with self.node.assert_debug_log(['Using /16 prefix for IP bucketing']):
self.start_node(0)

def test_asmap_with_absolute_path(self):
self.log.info('Test bitcoind -asmap=<absolute path>')
self.log.info('Test blackmored -asmap=<absolute path>')
self.stop_node(0)
filename = os.path.join(self.datadir, 'my-map-file.map')
shutil.copyfile(self.asmap_raw, filename)
Expand All @@ -62,7 +62,7 @@ def test_asmap_with_absolute_path(self):
os.remove(filename)

def test_asmap_with_relative_path(self):
self.log.info('Test bitcoind -asmap=<relative path>')
self.log.info('Test blackmored -asmap=<relative path>')
self.stop_node(0)
name = 'ASN_map'
filename = os.path.join(self.datadir, name)
Expand All @@ -74,14 +74,14 @@ def test_asmap_with_relative_path(self):
def test_default_asmap(self):
shutil.copyfile(self.asmap_raw, self.default_asmap)
for arg in ['-asmap', '-asmap=']:
self.log.info(f'Test bitcoind {arg} (using default map file)')
self.log.info(f'Test blackmored {arg} (using default map file)')
self.stop_node(0)
with self.node.assert_debug_log(expected_messages(self.default_asmap)):
self.start_node(0, [arg])
os.remove(self.default_asmap)

def test_asmap_interaction_with_addrman_containing_entries(self):
self.log.info("Test bitcoind -asmap restart with addrman containing new and tried entries")
self.log.info("Test blackmored -asmap restart with addrman containing new and tried entries")
self.stop_node(0)
shutil.copyfile(self.asmap_raw, self.default_asmap)
self.start_node(0, ["-asmap", "-checkaddrman=1"])
Expand All @@ -97,13 +97,13 @@ def test_asmap_interaction_with_addrman_containing_entries(self):
os.remove(self.default_asmap)

def test_default_asmap_with_missing_file(self):
self.log.info('Test bitcoind -asmap with missing default map file')
self.log.info('Test blackmored -asmap with missing default map file')
self.stop_node(0)
msg = f"Error: Could not find asmap file \"{self.default_asmap}\""
self.node.assert_start_raises_init_error(extra_args=['-asmap'], expected_msg=msg)

def test_empty_asmap(self):
self.log.info('Test bitcoind -asmap with empty map file')
self.log.info('Test blackmored -asmap with empty map file')
self.stop_node(0)
with open(self.default_asmap, "w", encoding="utf-8") as f:
f.write("")
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_cltv.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class BIP65Test(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.extra_args = [[
f'[email protected]',
'[email protected]',
'-par=1', # Use only one script thread to get the exact reject reason for testing
'-acceptnonstdtxn=1', # cltv_invalidate is nonstandard
]]
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_dersig.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class BIP66Test(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.extra_args = [[
f'[email protected]',
'[email protected]',
'-par=1', # Use only one script thread to get the exact log msg for testing
]]
self.setup_clean_chain = True
Expand Down
30 changes: 16 additions & 14 deletions test/functional/rpc_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ def set_test_params(self):

def run_test(self):
self.wallet = MiniWallet(self.nodes[0])
self._test_prune_disk_space()
# self._test_prune_disk_space()
self.mine_chain()
self._test_max_future_block_time()
self.restart_node(
0,
extra_args=[
"-stopatheight=207",
"-checkblocks=-1", # Check all blocks
"-prune=1", # Set pruning after rescan is complete
# "-prune=1", # Set pruning after rescan is complete
],
)

Expand All @@ -101,12 +101,14 @@ def mine_chain(self):
self.generate(self.wallet, 1)
assert_equal(self.nodes[0].getblockchaininfo()['blocks'], HEIGHT)

'''
def _test_prune_disk_space(self):
self.log.info("Test that a manually pruned node does not run into "
"integer overflow on first start up")
self.restart_node(0, extra_args=["-prune=1"])
self.log.info("Avoid warning when assumed chain size is enough")
self.restart_node(0, extra_args=["-prune=123456789"])
'''

def _test_max_future_block_time(self):
self.stop_node(0)
Expand All @@ -133,7 +135,7 @@ def _test_getblockchaininfo(self):
'headers',
'initialblockdownload',
'mediantime',
'pruned',
# 'pruned',
'size_on_disk',
'time',
'verificationprogress',
Expand All @@ -145,17 +147,17 @@ def _test_getblockchaininfo(self):
assert_equal(res['mediantime'], TIME_RANGE_MTP)

# result should have these additional pruning keys if manual pruning is enabled
assert_equal(sorted(res.keys()), sorted(['pruneheight', 'automatic_pruning'] + keys))
# assert_equal(sorted(res.keys()), sorted(['pruneheight', 'automatic_pruning'] + keys))

# size_on_disk should be > 0
assert_greater_than(res['size_on_disk'], 0)

# pruneheight should be greater or equal to 0
assert_greater_than_or_equal(res['pruneheight'], 0)
# assert_greater_than_or_equal(res['pruneheight'], 0)

# check other pruning fields given that prune=1
assert res['pruned']
assert not res['automatic_pruning']
# assert res['pruned']
# assert not res['automatic_pruning']

self.restart_node(0, ['-stopatheight=207'])
res = self.nodes[0].getblockchaininfo()
Expand All @@ -173,18 +175,18 @@ def _test_getblockchaininfo(self):
)
self.start_node(0, extra_args=[
'-stopatheight=207',
'-prune=550',
# '-prune=550',
])

res = self.nodes[0].getblockchaininfo()
# result should have these additional pruning keys if prune=550
assert_equal(sorted(res.keys()), sorted(['pruneheight', 'automatic_pruning', 'prune_target_size'] + keys))
# assert_equal(sorted(res.keys()), sorted(['pruneheight', 'automatic_pruning', 'prune_target_size'] + keys))

# check related fields
assert res['pruned']
assert_equal(res['pruneheight'], 0)
assert res['automatic_pruning']
assert_equal(res['prune_target_size'], 576716800)
# assert res['pruned']
# assert_equal(res['pruneheight'], 0)
# assert res['automatic_pruning']
# assert_equal(res['prune_target_size'], 576716800)
assert_greater_than(res['size_on_disk'], 0)

def check_signalling_deploymentinfo_result(self, gdi_result, height, blockhash, status_next):
Expand Down Expand Up @@ -321,7 +323,7 @@ def _test_gettxoutsetinfo(self):
node = self.nodes[0]
res = node.gettxoutsetinfo()

assert_equal(res['total_amount'], Decimal('8725.00000000'))
assert_equal(res['total_amount'], Decimal('2000000.00000000'))
assert_equal(res['transactions'], HEIGHT)
assert_equal(res['height'], HEIGHT)
assert_equal(res['txouts'], HEIGHT)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/rpc_createmultisig.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def do_multisig(self):
mredeem = msig["redeemScript"]
assert_equal(desc, msig['descriptor'])
if self.output_type == 'bech32':
assert madd[0:4] == "bcrt" # actually a bech32 address
assert madd[0:4] == "blrt" # actually a bech32 address

if self.is_bdb_compiled():
# compare against addmultisigaddress
Expand Down
4 changes: 2 additions & 2 deletions test/functional/rpc_dumptxoutset.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def run_test(self):

assert expected_path.is_file()

assert_equal(out['coins_written'], 100)
assert_equal(out['base_height'], 100)
assert_equal(out['coins_written'], 10)
assert_equal(out['base_height'], 10)
assert_equal(out['path'], str(expected_path))
# Blockhash should be deterministic based on mocked time.
assert_equal(
Expand Down
16 changes: 8 additions & 8 deletions test/functional/tool_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2018-2022 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 bitcoin-wallet."""
"""Test blackmore-wallet."""

import hashlib
import os
Expand Down Expand Up @@ -32,7 +32,7 @@ def skip_test_if_missing_module(self):
self.skip_if_no_wallet_tool()

def bitcoin_wallet_process(self, *args):
binary = self.config["environment"]["BUILDDIR"] + '/src/bitcoin-wallet' + self.config["environment"]["EXEEXT"]
binary = self.config["environment"]["BUILDDIR"] + '/src/blackmore-wallet' + self.config["environment"]["EXEEXT"]
default_args = ['-datadir={}'.format(self.nodes[0].datadir), '-chain=%s' % self.chain]
if not self.options.descriptors and 'create' in args:
default_args.append('-legacy')
Expand Down Expand Up @@ -176,7 +176,7 @@ def do_tool_createfromdump(self, wallet_name, dumpfile, file_format=None):
self.assert_tool_output(load_output, *args)
assert os.path.isdir(os.path.join(self.nodes[0].datadir, "regtest/wallets", wallet_name))

self.assert_tool_output("The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n", '-wallet={}'.format(wallet_name), '-dumpfile={}'.format(rt_dumppath), 'dump')
self.assert_tool_output("The dumpfile may contain private keys. To ensure the safety of your Blackcoin, do not share the dumpfile.\n", '-wallet={}'.format(wallet_name), '-dumpfile={}'.format(rt_dumppath), 'dump')

rt_dump_data = self.read_dump(rt_dumppath)
wallet_dat = os.path.join(self.nodes[0].datadir, "regtest/wallets/", wallet_name, "wallet.dat")
Expand All @@ -188,11 +188,11 @@ def do_tool_createfromdump(self, wallet_name, dumpfile, file_format=None):
def test_invalid_tool_commands_and_args(self):
self.log.info('Testing that various invalid commands raise with specific error messages')
self.assert_raises_tool_error("Error parsing command line arguments: Invalid command 'foo'", 'foo')
# `bitcoin-wallet help` raises an error. Use `bitcoin-wallet -help`.
# `blackmore-wallet help` raises an error. Use `blackmore-wallet -help`.
self.assert_raises_tool_error("Error parsing command line arguments: Invalid command 'help'", 'help')
self.assert_raises_tool_error('Error: Additional arguments provided (create). Methods do not take arguments. Please refer to `-help`.', 'info', 'create')
self.assert_raises_tool_error('Error parsing command line arguments: Invalid parameter -foo', '-foo')
self.assert_raises_tool_error('No method provided. Run `bitcoin-wallet -help` for valid methods.')
self.assert_raises_tool_error('No method provided. Run `blackmore-wallet -help` for valid methods.')
self.assert_raises_tool_error('Wallet name must be provided when creating a new wallet.', 'create')
locked_dir = os.path.join(self.options.tmpdir, "node0", "regtest", "wallets")
error = 'Error initializing wallet database environment "{}"!'.format(locked_dir)
Expand Down Expand Up @@ -331,7 +331,7 @@ def test_dump_createfromdump(self):

self.log.info('Checking basic dump')
wallet_dump = os.path.join(self.nodes[0].datadir, "wallet.dump")
self.assert_tool_output('The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n', '-wallet=todump', '-dumpfile={}'.format(wallet_dump), 'dump')
self.assert_tool_output('The dumpfile may contain private keys. To ensure the safety of your Blackcoin, do not share the dumpfile.\n', '-wallet=todump', '-dumpfile={}'.format(wallet_dump), 'dump')

dump_data = self.read_dump(wallet_dump)
orig_dump = dump_data.copy()
Expand Down Expand Up @@ -363,12 +363,12 @@ def test_dump_createfromdump(self):
bad_ver_wallet_dump = os.path.join(self.nodes[0].datadir, "wallet-bad_ver1.dump")
dump_data["BITCOIN_CORE_WALLET_DUMP"] = "0"
self.write_dump(dump_data, bad_ver_wallet_dump)
self.assert_raises_tool_error('Error: Dumpfile version is not supported. This version of bitcoin-wallet only supports version 1 dumpfiles. Got dumpfile with version 0', '-wallet=badload', '-dumpfile={}'.format(bad_ver_wallet_dump), 'createfromdump')
self.assert_raises_tool_error('Error: Dumpfile version is not supported. This version of blackmore-wallet only supports version 1 dumpfiles. Got dumpfile with version 0', '-wallet=badload', '-dumpfile={}'.format(bad_ver_wallet_dump), 'createfromdump')
assert not os.path.isdir(os.path.join(self.nodes[0].datadir, "regtest/wallets", "badload"))
bad_ver_wallet_dump = os.path.join(self.nodes[0].datadir, "wallet-bad_ver2.dump")
dump_data["BITCOIN_CORE_WALLET_DUMP"] = "2"
self.write_dump(dump_data, bad_ver_wallet_dump)
self.assert_raises_tool_error('Error: Dumpfile version is not supported. This version of bitcoin-wallet only supports version 1 dumpfiles. Got dumpfile with version 2', '-wallet=badload', '-dumpfile={}'.format(bad_ver_wallet_dump), 'createfromdump')
self.assert_raises_tool_error('Error: Dumpfile version is not supported. This version of blackmore-wallet only supports version 1 dumpfiles. Got dumpfile with version 2', '-wallet=badload', '-dumpfile={}'.format(bad_ver_wallet_dump), 'createfromdump')
assert not os.path.isdir(os.path.join(self.nodes[0].datadir, "regtest/wallets", "badload"))
bad_magic_wallet_dump = os.path.join(self.nodes[0].datadir, "wallet-bad_magic.dump")
del dump_data["BITCOIN_CORE_WALLET_DUMP"]
Expand Down

0 comments on commit 06ff56e

Please sign in to comment.