From 5ecaff65ee136b8e80c991919c98976628c6a746 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Thu, 21 Jan 2021 14:54:44 +0100 Subject: [PATCH] pytest: Give each run of the hsmtool its own pty --- tests/test_wallet.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_wallet.py b/tests/test_wallet.py index 9d81e62e9..1bab3ddf1 100644 --- a/tests/test_wallet.py +++ b/tests/test_wallet.py @@ -1024,6 +1024,7 @@ def test_hsmtool_secret_decryption(node_factory): l1.stop() # We can't use a wrong password ! + master_fd, slave_fd = os.openpty() hsmtool = HsmTool("decrypt", hsm_path) hsmtool.start(stdin=slave_fd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -1033,6 +1034,7 @@ def test_hsmtool_secret_decryption(node_factory): hsmtool.is_in_log(r"Wrong password") # Decrypt it with hsmtool + master_fd, slave_fd = os.openpty() hsmtool.start(stdin=slave_fd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) hsmtool.wait_for_log(r"Enter hsm_secret password:") @@ -1045,6 +1047,7 @@ def test_hsmtool_secret_decryption(node_factory): l1.stop() # Test we can encrypt it offline + master_fd, slave_fd = os.openpty() hsmtool = HsmTool("encrypt", hsm_path) hsmtool.start(stdin=slave_fd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -1073,6 +1076,7 @@ def test_hsmtool_secret_decryption(node_factory): l1.stop() # And finally test that we can also decrypt if encrypted with hsmtool + master_fd, slave_fd = os.openpty() hsmtool = HsmTool("decrypt", hsm_path) hsmtool.start(stdin=slave_fd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -1119,16 +1123,18 @@ def test_hsmtool_generatehsm(node_factory): l1.stop() hsm_path = os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, "hsm_secret") - master_fd, slave_fd = os.openpty() hsmtool = HsmTool("generatehsm", hsm_path) + # You cannot re-generate an already existing hsm_secret + master_fd, slave_fd = os.openpty() hsmtool.start(stdin=slave_fd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) assert hsmtool.proc.wait(WAIT_TIMEOUT) == 2 os.remove(hsm_path) # We can generate a valid hsm_secret from a wordlist and a "passphrase" + master_fd, slave_fd = os.openpty() hsmtool.start(stdin=slave_fd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) hsmtool.wait_for_log(r"Select your language:")