aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/README.md17
-rw-r--r--test/functional/README.md33
-rwxr-xr-xtest/functional/feature_loadblock.py84
-rwxr-xr-xtest/functional/test_runner.py1
-rwxr-xr-xtest/functional/wallet_multiwallet.py8
-rw-r--r--test/lint/README.md2
-rw-r--r--test/sanitizer_suppressions/ubsan13
7 files changed, 131 insertions, 27 deletions
diff --git a/test/README.md b/test/README.md
index 26fd525064..11adc11278 100644
--- a/test/README.md
+++ b/test/README.md
@@ -88,7 +88,7 @@ By default, up to 4 tests will be run in parallel by test_runner. To specify
how many jobs to run, append `--jobs=n`
The individual tests and the test_runner harness have many command-line
-options. Run `test_runner.py -h` to see them all.
+options. Run `test/functional/test_runner.py -h` to see them all.
#### Troubleshooting and debugging test failures
@@ -101,7 +101,7 @@ killed all its bitcoind nodes), then there may be a port conflict which will
cause the test to fail. It is recommended that you run the tests on a system
where no other bitcoind processes are running.
-On linux, the test_framework will warn if there is another
+On linux, the test framework will warn if there is another
bitcoind process running when the tests are started.
If there are zombie bitcoind processes after test failure, you can kill them
@@ -130,7 +130,7 @@ tests will fail. If this happens, remove the cache directory (and make
sure bitcoind processes are stopped as above):
```bash
-rm -rf cache
+rm -rf test/cache
killall bitcoind
```
@@ -149,6 +149,15 @@ levels using the logger included in the test_framework, e.g.
fails, the `test_framework.log` and bitcoind `debug.log`s will all be dumped
to the console to help troubleshooting.
+These log files can be located under the test data directory (which is always
+printed in the first line of test output):
+ - `<test data directory>/test_framework.log`
+ - `<test data directory>/node<node number>/regtest/debug.log`.
+
+The node number identifies the relevant test node, starting from `node0`, which
+corresponds to its position in the nodes list of the specific test,
+e.g. `self.nodes[0]`.
+
To change the level of logs output to the console, use the `-l` command line
argument.
@@ -157,7 +166,7 @@ aggregate log by running the `combine_logs.py` script. The output can be plain
text, colorized text or html. For example:
```
-combine_logs.py -c <test data directory> | less -r
+test/functional/combine_logs.py -c <test data directory> | less -r
```
will pipe the colorized logs from the test into less.
diff --git a/test/functional/README.md b/test/functional/README.md
index 197c2afbe4..a9b83076eb 100644
--- a/test/functional/README.md
+++ b/test/functional/README.md
@@ -4,13 +4,13 @@
#### Example test
-The [example_test.py](example_test.py) is a heavily commented example of a test case that uses both
-the RPC and P2P interfaces. If you are writing your first test, copy that file
-and modify to fit your needs.
+The file [test/functional/example_test.py](example_test.py) is a heavily commented example
+of a test case that uses both the RPC and P2P interfaces. If you are writing your first test, copy
+that file and modify to fit your needs.
#### Coverage
-Running `test_runner.py` with the `--coverage` argument tracks which RPCs are
+Running `test/functional/test_runner.py` with the `--coverage` argument tracks which RPCs are
called by the tests and prints a report of uncovered RPCs in the summary. This
can be used (along with the `--extended` argument) to find out which RPCs we
don't have test cases for.
@@ -82,7 +82,7 @@ P2P messages. These can be found in the following source files:
#### Using the P2P interface
-- `messages.py` contains all the definitions for objects that pass
+- [messages.py](test_framework/messages.py) contains all the definitions for objects that pass
over the network (`CBlock`, `CTransaction`, etc, along with the network-level
wrappers for them, `msg_block`, `msg_tx`, etc).
@@ -96,32 +96,35 @@ the Bitcoin Core node application logic. For custom behaviour, subclass the
P2PInterface object and override the callback methods.
- Can be used to write tests where specific P2P protocol behavior is tested.
-Examples tests are `p2p_unrequested_blocks.py`, `p2p_compactblocks.py`.
+Examples tests are [p2p_unrequested_blocks.py](p2p_unrequested_blocks.py),
+[p2p_compactblocks.py](p2p_compactblocks.py).
-### test-framework modules
+### Test framework modules
+The following are useful modules for test developers. They are located in
+[test/functional/test_framework/](test_framework).
-#### [test_framework/authproxy.py](test_framework/authproxy.py)
+#### [authproxy.py](test_framework/authproxy.py)
Taken from the [python-bitcoinrpc repository](https://github.com/jgarzik/python-bitcoinrpc).
-#### [test_framework/test_framework.py](test_framework/test_framework.py)
+#### [test_framework.py](test_framework/test_framework.py)
Base class for functional tests.
-#### [test_framework/util.py](test_framework/util.py)
+#### [util.py](test_framework/util.py)
Generally useful functions.
-#### [test_framework/mininode.py](test_framework/mininode.py)
+#### [mininode.py](test_framework/mininode.py)
Basic code to support P2P connectivity to a bitcoind.
-#### [test_framework/script.py](test_framework/script.py)
+#### [script.py](test_framework/script.py)
Utilities for manipulating transaction scripts (originally from python-bitcoinlib)
-#### [test_framework/key.py](test_framework/key.py)
+#### [key.py](test_framework/key.py)
Test-only secp256k1 elliptic curve implementation
-#### [test_framework/bignum.py](test_framework/bignum.py)
+#### [bignum.py](test_framework/bignum.py)
Helpers for script.py
-#### [test_framework/blocktools.py](test_framework/blocktools.py)
+#### [blocktools.py](test_framework/blocktools.py)
Helper functions for creating blocks and transactions.
### Benchmarking with perf
diff --git a/test/functional/feature_loadblock.py b/test/functional/feature_loadblock.py
new file mode 100755
index 0000000000..bf2a4ff61f
--- /dev/null
+++ b/test/functional/feature_loadblock.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python3
+# Copyright (c) 2017-2019 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 loadblock option
+
+Test the option to start a node with the option loadblock which loads
+a serialized blockchain from a file (usually called bootstrap.dat).
+To generate that file this test uses the helper scripts available
+in contrib/linearize.
+"""
+
+import os
+import subprocess
+import sys
+import tempfile
+import urllib
+
+from test_framework.test_framework import (
+ BitcoinTestFramework,
+)
+from test_framework.util import assert_equal, wait_until
+
+
+class LoadblockTest(BitcoinTestFramework):
+ def set_test_params(self):
+ self.setup_clean_chain = True
+ self.num_nodes = 2
+
+ def run_test(self):
+ self.nodes[1].setnetworkactive(state=False)
+ self.nodes[0].generate(100)
+
+ # Parsing the url of our node to get settings for config file
+ data_dir = self.nodes[0].datadir
+ node_url = urllib.parse.urlparse(self.nodes[0].url)
+ cfg_file = os.path.join(data_dir, "linearize.cfg")
+ bootstrap_file = os.path.join(self.options.tmpdir, "bootstrap.dat")
+ genesis_block = self.nodes[0].getblockhash(0)
+ blocks_dir = os.path.join(data_dir, "regtest", "blocks")
+ hash_list = tempfile.NamedTemporaryFile(dir=data_dir,
+ mode='w',
+ delete=False,
+ encoding="utf-8")
+
+ self.log.info("Create linearization config file")
+ with open(cfg_file, "a", encoding="utf-8") as cfg:
+ cfg.write("datadir={}\n".format(data_dir))
+ cfg.write("rpcuser={}\n".format(node_url.username))
+ cfg.write("rpcpassword={}\n".format(node_url.password))
+ cfg.write("port={}\n".format(node_url.port))
+ cfg.write("host={}\n".format(node_url.hostname))
+ cfg.write("output_file={}\n".format(bootstrap_file))
+ cfg.write("max_height=100\n")
+ cfg.write("netmagic=fabfb5da\n")
+ cfg.write("input={}\n".format(blocks_dir))
+ cfg.write("genesis={}\n".format(genesis_block))
+ cfg.write("hashlist={}\n".format(hash_list.name))
+
+ base_dir = self.config["environment"]["SRCDIR"]
+ linearize_dir = os.path.join(base_dir, "contrib", "linearize")
+
+ self.log.info("Run linearization of block hashes")
+ linearize_hashes_file = os.path.join(linearize_dir, "linearize-hashes.py")
+ subprocess.run([sys.executable, linearize_hashes_file, cfg_file],
+ stdout=hash_list,
+ check=True)
+
+ self.log.info("Run linearization of block data")
+ linearize_data_file = os.path.join(linearize_dir, "linearize-data.py")
+ subprocess.run([sys.executable, linearize_data_file, cfg_file],
+ check=True)
+
+ self.log.info("Restart second, unsynced node with bootstrap file")
+ self.stop_node(1)
+ self.start_node(1, ["-loadblock=" + bootstrap_file])
+ wait_until(lambda: self.nodes[1].getblockcount() == 100)
+
+ assert_equal(self.nodes[1].getblockchaininfo()['blocks'], 100)
+ assert_equal(self.nodes[0].getbestblockhash(), self.nodes[1].getbestblockhash())
+
+
+if __name__ == '__main__':
+ LoadblockTest().main()
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py
index 9c92091f1d..e0b523b718 100755
--- a/test/functional/test_runner.py
+++ b/test/functional/test_runner.py
@@ -197,6 +197,7 @@ BASE_SCRIPTS = [
'feature_uacomment.py',
'wallet_coinbase_category.py',
'feature_filelock.py',
+ 'feature_loadblock.py',
'p2p_dos_header_tree.py',
'p2p_unrequested_blocks.py',
'feature_includeconf.py',
diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py
index 68bc45f986..ce0b7e8782 100755
--- a/test/functional/wallet_multiwallet.py
+++ b/test/functional/wallet_multiwallet.py
@@ -339,14 +339,10 @@ class MultiWalletTest(BitcoinTestFramework):
self.log.info("Fail -upgradewallet that results in downgrade")
assert_raises_rpc_error(
-4,
- "Wallet loading failed.",
+ 'Wallet loading failed: Error loading {}: Wallet requires newer version of {}'.format(
+ wallet_dir('high_minversion', 'wallet.dat'), self.config['environment']['PACKAGE_NAME']),
lambda: self.nodes[0].loadwallet(filename='high_minversion'),
)
- self.stop_node(
- i=0,
- expected_stderr='Error: Error loading {}: Wallet requires newer version of Bitcoin Core'.format(
- wallet_dir('high_minversion', 'wallet.dat')),
- )
if __name__ == '__main__':
diff --git a/test/lint/README.md b/test/lint/README.md
index 15974a3598..f415d619ee 100644
--- a/test/lint/README.md
+++ b/test/lint/README.md
@@ -7,6 +7,8 @@ Check for missing documentation of command line options.
commit-script-check.sh
======================
Verification of [scripted diffs](/doc/developer-notes.md#scripted-diffs).
+Scripted diffs are only assumed to run on the latest LTS release of Ubuntu. Running them on other operating systems
+might require installing GNU tools, such as GNU sed.
git-subtree-check.sh
====================
diff --git a/test/sanitizer_suppressions/ubsan b/test/sanitizer_suppressions/ubsan
index 643272de52..e7c690fabe 100644
--- a/test/sanitizer_suppressions/ubsan
+++ b/test/sanitizer_suppressions/ubsan
@@ -1,9 +1,19 @@
+# -fsanitize=undefined suppressions
+# =================================
alignment:move.h
alignment:prevector.h
-bool:wallet/wallet.cpp
float-divide-by-zero:policy/fees.cpp
float-divide-by-zero:validation.cpp
float-divide-by-zero:wallet/wallet.cpp
+
+# -fsanitize=integer suppressions
+# ===============================
+# Unsigned integer overflow occurs when the result of an unsigned integer
+# computation cannot be represented in its type. Unlike signed integer overflow,
+# this is not undefined behavior, but it is often unintentional. The list below
+# contains files in which we expect unsigned integer overflows to occur. The
+# list is used to suppress -fsanitize=integer warnings when running our CI UBSan
+# job.
unsigned-integer-overflow:arith_uint256.h
unsigned-integer-overflow:basic_string.h
unsigned-integer-overflow:bench/bench.h
@@ -32,4 +42,3 @@ unsigned-integer-overflow:stl_bvector.h
unsigned-integer-overflow:txmempool.cpp
unsigned-integer-overflow:util/strencodings.cpp
unsigned-integer-overflow:validation.cpp
-vptr:fs.cpp