aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2022-01-03 08:46:57 +0100
committerMarcoFalke <falke.marco@gmail.com>2022-01-03 08:47:02 +0100
commit31f385c1380bef5079ad4161bbad8dadf578b4d0 (patch)
tree48314f372da90ea71eead29525ceb5b6dc20135d
parentbcf2b25eec8a8712a614d8b268aeb6fb8d8ae43d (diff)
parent126853214a490ee840e83ca17c717c40cfbe6837 (diff)
Merge bitcoin/bitcoin#23532: test: add functional test for -startupnotify
126853214a490ee840e83ca17c717c40cfbe6837 test: add functional test for -startupnotify (Bruno Garcia) Pull request description: This PR adds a functional test for -startupnotify. It basically starts the node passing a command on -startupnotify to create a file on tmp and then, we check if the file has been successfully created. ACKs for top commit: theStack: Tested ACK 126853214a490ee840e83ca17c717c40cfbe6837 kristapsk: re-ACK 126853214a490ee840e83ca17c717c40cfbe6837 Tree-SHA512: 5bf3e46124ee5c9d609c9993e6465d5a71a8d2275dcf07c8ce0549f013f7f8863d483b46b7164152f566468a689371ccb87f01cf118c3c9cac5b2be673b61a5c
-rwxr-xr-xtest/functional/feature_startupnotify.py41
-rwxr-xr-xtest/functional/test_runner.py1
2 files changed, 42 insertions, 0 deletions
diff --git a/test/functional/feature_startupnotify.py b/test/functional/feature_startupnotify.py
new file mode 100755
index 0000000000..71135dcd3b
--- /dev/null
+++ b/test/functional/feature_startupnotify.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+# Copyright (c) 2020 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 -startupnotify."""
+
+import os
+
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import (
+ assert_equal,
+)
+
+NODE_DIR = "node0"
+FILE_NAME = "test.txt"
+
+
+class StartupNotifyTest(BitcoinTestFramework):
+ def set_test_params(self):
+ self.num_nodes = 1
+ self.disable_syscall_sandbox = True
+
+ def run_test(self):
+ tmpdir_file = os.path.join(self.options.tmpdir, NODE_DIR, FILE_NAME)
+ assert not os.path.exists(tmpdir_file)
+
+ self.log.info("Test -startupnotify command is run when node starts")
+ self.restart_node(0, extra_args=[f"-startupnotify=echo '{FILE_NAME}' >> {NODE_DIR}/{FILE_NAME}"])
+ assert os.path.exists(tmpdir_file)
+
+ self.log.info("Test -startupnotify is executed once")
+ with open(tmpdir_file, "r", encoding="utf8") as f:
+ file_content = f.read()
+ assert_equal(file_content.count(FILE_NAME), 1)
+
+ self.log.info("Test node is fully started")
+ assert_equal(self.nodes[0].getblockcount(), 200)
+
+
+if __name__ == '__main__':
+ StartupNotifyTest().main()
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py
index 675f9aa8ff..df9aec6281 100755
--- a/test/functional/test_runner.py
+++ b/test/functional/test_runner.py
@@ -257,6 +257,7 @@ BASE_SCRIPTS = [
'wallet_bumpfee.py --descriptors',
'wallet_implicitsegwit.py --legacy-wallet',
'rpc_named_arguments.py',
+ 'feature_startupnotify.py',
'wallet_listsinceblock.py --legacy-wallet',
'wallet_listsinceblock.py --descriptors',
'wallet_listdescriptors.py --descriptors',