Skip to content

Commit

Permalink
Merge pull request #34 from BitgesellOfficial/functional_tests
Browse files Browse the repository at this point in the history
Functional tests
  • Loading branch information
van-orton authored Jul 19, 2021
2 parents 27d4bd8 + 447c260 commit efc5ae1
Show file tree
Hide file tree
Showing 50 changed files with 488 additions and 376 deletions.
2 changes: 1 addition & 1 deletion src/wallet/wallettool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
tfm::format(std::cerr, "%s\n", error.original);
return ret;
}
tfm::format(std::cout, "The dumpfile may contain private keys. To ensure the safety of your Bitcoin, do not share the dumpfile.\n");
tfm::format(std::cout, "The dumpfile may contain private keys. To ensure the safety of your BGL, do not share the dumpfile.\n");
return ret;
} else if (command == "createfromdump") {
bilingual_str error;
Expand Down
2 changes: 1 addition & 1 deletion test/config.ini.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RPCAUTH=@abs_top_srcdir@/share/rpcauth/rpcauth.py
@USE_BDB_TRUE@USE_BDB=true
@BUILD_BGL_CLI_TRUE@ENABLE_CLI=true
@BUILD_BGL_WALLET_TRUE@ENABLE_WALLET_TOOL=true
@BUILD_BGL_TRUE@ENABLE_BGL=true
@BUILD_BGLD_TRUE@ENABLE_BGLD=true
@ENABLE_FUZZ_TRUE@ENABLE_FUZZ=true
@ENABLE_ZMQ_TRUE@ENABLE_ZMQ=true
@ENABLE_EXTERNAL_SIGNER_TRUE@ENABLE_EXTERNAL_SIGNER=true
2 changes: 1 addition & 1 deletion test/functional/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ don't have test cases for.
load a premined blockchain from cache with the default value of `False`. The
cached data directories contain a 200-block pre-mined blockchain with the
spendable mining rewards being split between four nodes. Each node has 25
mature block subsidies (25x50=1250 BTC) in its wallet. Using them is much more
mature block subsidies (25x200=5000 BGL) in its wallet. Using them is much more
efficient than mining blocks in your test.
- When calling RPCs with lots of arguments, consider using named keyword
arguments instead of positional arguments to make the intent of the call
Expand Down
8 changes: 4 additions & 4 deletions test/functional/data/rpc_bip67.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"02ff12471208c14bd580709cb2358d98975247d8765f92bc25eab3b2763ed605f8"
],
"script": "522102fe6f0a5a297eb38c391581c4413e084773ea23954d93f7753db7dc0adc188b2f2102ff12471208c14bd580709cb2358d98975247d8765f92bc25eab3b2763ed605f852ae",
"address": "2N19tNw3Ss4L9QDERtCw7FhXb6jBsYmeXNu"
"address": "MFopd5XPCigDzvsnJxJaTPnjD5a9pBiXfP"
},
{
"keys": [
Expand All @@ -23,7 +23,7 @@
"02e2cc6bd5f45edd43bebe7cb9b675f0ce9ed3efe613b177588290ad188d11b404"
],
"script": "522102632b12f4ac5b1d1b72b2a3b508c19172de44f6f46bcee50ba33f3f9291e47ed021027735a29bae7780a9755fae7a1c4374c656ac6a69ea9f3697fda61bb99a4f3e772102e2cc6bd5f45edd43bebe7cb9b675f0ce9ed3efe613b177588290ad188d11b40453ae",
"address": "2N3sVXU7MZefmYnZhrVX2bA7LyH6vygFZZ7"
"address": "MJXRmcbHuK1r9WD4HEtVnrNV5dVDBBp38s"
},
{
"keys": [
Expand All @@ -39,7 +39,7 @@
"030000000000000000000000000000000000004141414141414141414141414141"
],
"script": "522102000000000000000000000000000000000000414141414141414141414141414021020000000000000000000000000000000000004141414141414141414141414141210300000000000000000000000000000000000041414141414141414141414141402103000000000000000000000000000000000000414141414141414141414141414154ae",
"address": "2Mt3L9TcDUAfLpSoyB3SNYtJGLiU49DKEWJ"
"address": "M8hGPc69oq1RRATKbnoqkaZQT4rLSDuuqT"
},
{
"keys": [
Expand All @@ -53,6 +53,6 @@
"03e3818b65bcc73a7d64064106a859cc1a5a728c4345ff0b641209fba0d90de6e9"
],
"script": "5221021f2f6e1e50cb6a953935c3601284925decd3fd21bc445712576873fb8c6ebc1821022df8750480ad5b26950b25c7ba79d3e37d75f640f8e5d9bcd5b150a0f85014da2103e3818b65bcc73a7d64064106a859cc1a5a728c4345ff0b641209fba0d90de6e953ae",
"address": "2NFd5JqpwmQNz3gevZJ3rz9ofuHvqaP9Cye"
"address": "MWH1YzJt74j4eQJGz3RLBr4p1eK7goXLMN"
}
]
29 changes: 15 additions & 14 deletions test/functional/feature_asmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
# 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 BGLd in these cases:
1. `bitcoind` with no -asmap arg, using /16 prefix for IP bucketing
1. `BGLd` with no -asmap arg, using /16 prefix for IP bucketing
2. `bitcoind -asmap=<absolute path>`, using the unit test skeleton asmap
2. `BGLd -asmap=<absolute path>`, using the unit test skeleton asmap
3. `bitcoind -asmap=<relative path>`, using the unit test skeleton asmap
3. `BGLd -asmap=<relative path>`, using the unit test skeleton asmap
4. `bitcoind -asmap/-asmap=` with no file specified, using the default asmap
4. `BGLd -asmap/-asmap=` with no file specified, using the default asmap
5. `bitcoind -asmap` with no file specified and a missing default asmap file
5. `BGLd -asmap` with no file specified and a missing default asmap file
6. `bitcoind -asmap` with an empty (unparsable) default asmap file
6. `BGLd -asmap` with an empty (unparsable) default asmap file
The tests are order-independent.
Expand All @@ -28,7 +28,7 @@

DEFAULT_ASMAP_FILENAME = 'ip_asn.map' # defined in src/init.cpp
ASMAP = '../../src/test/data/asmap.raw' # path to unit test skeleton asmap
VERSION = 'fec61fa21a9f46f3b17bdcd660d7f4cd90b966aad3aec593c99b35f0aca15853'
VERSION = 'c88edc2215daef7b5ae0b71bd0bc100e1c4928cd59634e66938860a6b73a6b0e'

def expected_messages(filename):
return ['Opened asmap file "{}" (59 bytes) from disk'.format(filename),
Expand All @@ -39,13 +39,13 @@ def set_test_params(self):
self.num_nodes = 1

def test_without_asmap_arg(self):
self.log.info('Test bitcoind with no -asmap arg passed')
self.log.info('Test BGLd 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 BGLd -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 @@ -54,32 +54,33 @@ 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 BGLd -asmap=<relative path>')
self.stop_node(0)
name = 'ASN_map'
filename = os.path.join(self.datadir, name)
shutil.copyfile(self.asmap_raw, filename)

with self.node.assert_debug_log(expected_messages(filename)):
self.start_node(0, ['-asmap={}'.format(name)])
os.remove(filename)

def test_default_asmap(self):
shutil.copyfile(self.asmap_raw, self.default_asmap)
for arg in ['-asmap', '-asmap=']:
self.log.info('Test bitcoind {} (using default map file)'.format(arg))
self.log.info('Test BGLd {} (using default map file)'.format(arg))
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_default_asmap_with_missing_file(self):
self.log.info('Test bitcoind -asmap with missing default map file')
self.log.info('Test BGLd -asmap with missing default map file')
self.stop_node(0)
msg = "Error: Could not find asmap file \"{}\"".format(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 BGLd -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_bip68_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def run_test(self):
def test_disable_flag(self):
# Create some unconfirmed inputs
new_addr = self.nodes[0].getnewaddress()
self.nodes[0].sendtoaddress(new_addr, 2) # send 2 BTC
self.nodes[0].sendtoaddress(new_addr, 2) # send 2 BGL

utxos = self.nodes[0].listunspent(0, 0)
assert len(utxos) > 0
Expand Down
14 changes: 7 additions & 7 deletions test/functional/feature_blockfilterindex_prune.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ def run_test(self):
self.sync_index(height=200)
assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getbestblockhash())['filter']), 0)
# Mine two batches of blocks to avoid hitting NODE_NETWORK_LIMITED_MIN_BLOCKS disconnection
self.nodes[0].generate(250)
self.nodes[0].generate(400)
self.sync_all()
self.nodes[0].generate(250)
self.nodes[0].generate(400)
self.sync_all()
self.sync_index(height=700)
self.sync_index(height=1000)

self.log.info("prune some blocks")
pruneheight = self.nodes[0].pruneblockchain(400)
assert_equal(pruneheight, 250)
pruneheight = self.nodes[0].pruneblockchain(1000)
assert_equal(pruneheight, 506)

self.log.info("check if we can access the tips blockfilter when we have pruned some blocks")
assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getbestblockhash())['filter']), 0)
Expand All @@ -46,10 +46,10 @@ def run_test(self):

self.log.info("make sure accessing the blockfilters throws an error")
assert_raises_rpc_error(-1, "Index is not enabled for filtertype basic", self.nodes[0].getblockfilter, self.nodes[0].getblockhash(2))
self.nodes[0].generate(1000)
self.nodes[0].generate(400)

self.log.info("prune below the blockfilterindexes best block while blockfilters are disabled")
pruneheight_new = self.nodes[0].pruneblockchain(1000)
pruneheight_new = self.nodes[0].pruneblockchain(1400)
assert_greater_than(pruneheight_new, pruneheight)
self.stop_node(0)

Expand Down
1 change: 1 addition & 0 deletions test/functional/feature_config_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import time

from test_framework.test_framework import BGLTestFramework
from test_framework import util


class ConfArgsTest(BGLTestFramework):
Expand Down
Loading

0 comments on commit efc5ae1

Please sign in to comment.