Skip to content

Commit

Permalink
test: add functional test for -startupnotify
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoerg committed Dec 24, 2021
1 parent 41a1b5f commit 1268532
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/functional/feature_startupnotify.py
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
'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',
Expand Down

0 comments on commit 1268532

Please sign in to comment.