aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/test_node.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2018-10-28 06:43:52 -0400
committerMarcoFalke <falke.marco@gmail.com>2018-10-28 06:44:08 -0400
commit76dd5257f9b5705734481569c39bf115d4cb973d (patch)
treef39e9f1b9df4435483cc25684a28fba7b98c8016 /test/functional/test_framework/test_node.py
parent1476554d3b1db5352c0de1de7524864d4bce3aac (diff)
parent9461f98c534ab64ae404085ffb309ec276e3c902 (diff)
downloadbitcoin-76dd5257f9b5705734481569c39bf115d4cb973d.tar.xz
Merge #14566: 0.17: qa backports
9461f98c53 Disable wallet and address book Qt tests on macOS minimal platform (Russell Yanofsky) 703a24418c descriptors.md: Refer to descriptors as describing instead of matching (Russell Yanofsky) 5f51fd6d59 doc/descriptors.md tweaks (Russell Yanofsky) 29899ecd36 Import CInv from correct module (Chun Kuan Lee) f7adb32e38 qa: Run all tests even if wallet is not compiled (MarcoFalke) 86fadee990 qa: Premine to deterministic address with -disablewallet (MarcoFalke) 8bc1badada Test rpc_help.py failed: Check whether ZMQ is enabled or not. (Kvaciral) 24d796a6cc test: Add tests for RPC help (João Barbosa) 168efeaca6 qa: Use named args in some tests (MarcoFalke) 73e538cf6a scripted-diff: Use named arguments in feature_block (MarcoFalke) 96dc936862 scripted-diff: Pass node into p2p_segwit acceptance tests (MarcoFalke) 7ff32a6b98 qa: Add some actual witness in rpc_rawtransaction (MarcoFalke) b72fbabe17 [qa] Use correct python index slices in example test (Suhas Daftuar) 06544faff0 qa: Add TestNode::assert_debug_log (MarcoFalke) Pull request description: Just the test and doc changes from #14328 to prevent that one from piling up. Tree-SHA512: 51c1e66d346cbf51bc67b2f365448620dd9992ba4ef70592c5eb489cd50a047dab8179c86db2cafe161d8b2aa04498cc760fb5deb7eef49b39272911c74227a9
Diffstat (limited to 'test/functional/test_framework/test_node.py')
-rwxr-xr-xtest/functional/test_framework/test_node.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 0d00cc2082..908dda94c5 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -4,6 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Class for bitcoind node under test"""
+import contextlib
import decimal
import errno
from enum import Enum
@@ -96,6 +97,22 @@ class TestNode():
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:
"""Return a modified msg that identifies this node by its index as a debugging aid."""
return "[node %d] %s" % (self.index, msg)
@@ -229,6 +246,23 @@ class TestNode():
def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT):
wait_until(self.is_node_stopped, timeout=timeout)
+ @contextlib.contextmanager
+ def assert_debug_log(self, expected_msgs):
+ debug_log = os.path.join(self.datadir, 'regtest', 'debug.log')
+ with open(debug_log, encoding='utf-8') as dl:
+ dl.seek(0, 2)
+ prev_size = dl.tell()
+ try:
+ yield
+ finally:
+ with open(debug_log, encoding='utf-8') as dl:
+ dl.seek(prev_size)
+ log = dl.read()
+ print_log = " - " + "\n - ".join(log.splitlines())
+ for expected_msg in expected_msgs:
+ if re.search(re.escape(expected_msg), log, flags=re.MULTILINE) is None:
+ self._raise_assertion_error('Expected message "{}" does not partially match log:\n\n{}\n\n'.format(expected_msg, print_log))
+
def assert_start_raises_init_error(self, extra_args=None, expected_msg=None, match=ErrorMatch.FULL_TEXT, *args, **kwargs):
"""Attempt to start the node and expect it to raise an error.