mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-27 02:01:59 +01:00
aaaa3aefbdfca1c9243057eeefdc19940e60bf18 test: Use TestNode *_path properties where possible (MarcoFalke)
dddd89962b26b5593860d016586ee8feb5aeea24 test: Allow pathlib.Path as RPC argument via authproxy (MarcoFalke)
fa41614a0abc05cbfbf76d6af3a186ab8d79c3f2 scripted-diff: Use wallets_path and chain_path where possible (MarcoFalke)
fa493fadfb0ac73b7c0ee308f6623213702ae6f4 test: Use wallet_dir lambda in wallet_multiwallet test where possible (MarcoFalke)
Pull request description:
It seems inconsistent, fragile and verbose to:
* Call `get_datadir_path` to recreate the path that already exists as field in TestNode
* Call `os.path.join` with the hardcoded chain name or `self.chain` to recreate the TestNode `chain_path` property
* Sometimes even use the hardcoded node dir name (`"node0"`)
Fix all issues by using the TestNode properties.
ACKs for top commit:
willcl-ark:
re-ACK aaaa3aefbdfca1c9243057eeefdc19940e60bf18
theStack:
Code-review ACK aaaa3aefbdfca1c9243057eeefdc19940e60bf18 🌊
Tree-SHA512: e4720278085beb8164e1fe6c1aa18f601558a9263494ce69a83764c1487007de63ebb51d1b1151862dc4d5b49ded6162a5c1553cd30ea1c28627d447db4d8e72
43 lines
1.3 KiB
Python
Executable File
43 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2020-2022 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."""
|
|
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
|
|
|
|
def run_test(self):
|
|
tmpdir_file = self.nodes[0].datadir_path / FILE_NAME
|
|
assert not tmpdir_file.exists()
|
|
|
|
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}"])
|
|
self.wait_until(lambda: tmpdir_file.exists())
|
|
|
|
self.log.info("Test -startupnotify is executed once")
|
|
|
|
def get_count():
|
|
with open(tmpdir_file, "r", encoding="utf8") as f:
|
|
file_content = f.read()
|
|
return file_content.count(FILE_NAME)
|
|
|
|
self.wait_until(lambda: get_count() > 0)
|
|
assert_equal(get_count(), 1)
|
|
|
|
self.log.info("Test node is fully started")
|
|
assert_equal(self.nodes[0].getblockcount(), 200)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
StartupNotifyTest().main()
|