Skip to content

Commit 1268532

Browse files
committed
test: add functional test for -startupnotify
1 parent 41a1b5f commit 1268532

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2020 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Test -startupnotify."""
6+
7+
import os
8+
9+
from test_framework.test_framework import BitcoinTestFramework
10+
from test_framework.util import (
11+
assert_equal,
12+
)
13+
14+
NODE_DIR = "node0"
15+
FILE_NAME = "test.txt"
16+
17+
18+
class StartupNotifyTest(BitcoinTestFramework):
19+
def set_test_params(self):
20+
self.num_nodes = 1
21+
self.disable_syscall_sandbox = True
22+
23+
def run_test(self):
24+
tmpdir_file = os.path.join(self.options.tmpdir, NODE_DIR, FILE_NAME)
25+
assert not os.path.exists(tmpdir_file)
26+
27+
self.log.info("Test -startupnotify command is run when node starts")
28+
self.restart_node(0, extra_args=[f"-startupnotify=echo '{FILE_NAME}' >> {NODE_DIR}/{FILE_NAME}"])
29+
assert os.path.exists(tmpdir_file)
30+
31+
self.log.info("Test -startupnotify is executed once")
32+
with open(tmpdir_file, "r", encoding="utf8") as f:
33+
file_content = f.read()
34+
assert_equal(file_content.count(FILE_NAME), 1)
35+
36+
self.log.info("Test node is fully started")
37+
assert_equal(self.nodes[0].getblockcount(), 200)
38+
39+
40+
if __name__ == '__main__':
41+
StartupNotifyTest().main()

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@
253253
'wallet_bumpfee.py --descriptors',
254254
'wallet_implicitsegwit.py --legacy-wallet',
255255
'rpc_named_arguments.py',
256+
'feature_startupnotify.py',
256257
'wallet_listsinceblock.py --legacy-wallet',
257258
'wallet_listsinceblock.py --descriptors',
258259
'wallet_listdescriptors.py --descriptors',

0 commit comments

Comments
 (0)