mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
pytest: Give each run of the hsmtool its own pty
This commit is contained in:
committed by
Rusty Russell
parent
1463797c61
commit
5ecaff65ee
@@ -1024,6 +1024,7 @@ def test_hsmtool_secret_decryption(node_factory):
|
|||||||
l1.stop()
|
l1.stop()
|
||||||
|
|
||||||
# We can't use a wrong password !
|
# We can't use a wrong password !
|
||||||
|
master_fd, slave_fd = os.openpty()
|
||||||
hsmtool = HsmTool("decrypt", hsm_path)
|
hsmtool = HsmTool("decrypt", hsm_path)
|
||||||
hsmtool.start(stdin=slave_fd,
|
hsmtool.start(stdin=slave_fd,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
@@ -1033,6 +1034,7 @@ def test_hsmtool_secret_decryption(node_factory):
|
|||||||
hsmtool.is_in_log(r"Wrong password")
|
hsmtool.is_in_log(r"Wrong password")
|
||||||
|
|
||||||
# Decrypt it with hsmtool
|
# Decrypt it with hsmtool
|
||||||
|
master_fd, slave_fd = os.openpty()
|
||||||
hsmtool.start(stdin=slave_fd,
|
hsmtool.start(stdin=slave_fd,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
hsmtool.wait_for_log(r"Enter hsm_secret password:")
|
hsmtool.wait_for_log(r"Enter hsm_secret password:")
|
||||||
@@ -1045,6 +1047,7 @@ def test_hsmtool_secret_decryption(node_factory):
|
|||||||
l1.stop()
|
l1.stop()
|
||||||
|
|
||||||
# Test we can encrypt it offline
|
# Test we can encrypt it offline
|
||||||
|
master_fd, slave_fd = os.openpty()
|
||||||
hsmtool = HsmTool("encrypt", hsm_path)
|
hsmtool = HsmTool("encrypt", hsm_path)
|
||||||
hsmtool.start(stdin=slave_fd,
|
hsmtool.start(stdin=slave_fd,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
@@ -1073,6 +1076,7 @@ def test_hsmtool_secret_decryption(node_factory):
|
|||||||
l1.stop()
|
l1.stop()
|
||||||
|
|
||||||
# And finally test that we can also decrypt if encrypted with hsmtool
|
# And finally test that we can also decrypt if encrypted with hsmtool
|
||||||
|
master_fd, slave_fd = os.openpty()
|
||||||
hsmtool = HsmTool("decrypt", hsm_path)
|
hsmtool = HsmTool("decrypt", hsm_path)
|
||||||
hsmtool.start(stdin=slave_fd,
|
hsmtool.start(stdin=slave_fd,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
@@ -1119,16 +1123,18 @@ def test_hsmtool_generatehsm(node_factory):
|
|||||||
l1.stop()
|
l1.stop()
|
||||||
hsm_path = os.path.join(l1.daemon.lightning_dir, TEST_NETWORK,
|
hsm_path = os.path.join(l1.daemon.lightning_dir, TEST_NETWORK,
|
||||||
"hsm_secret")
|
"hsm_secret")
|
||||||
master_fd, slave_fd = os.openpty()
|
|
||||||
|
|
||||||
hsmtool = HsmTool("generatehsm", hsm_path)
|
hsmtool = HsmTool("generatehsm", hsm_path)
|
||||||
|
|
||||||
# You cannot re-generate an already existing hsm_secret
|
# You cannot re-generate an already existing hsm_secret
|
||||||
|
master_fd, slave_fd = os.openpty()
|
||||||
hsmtool.start(stdin=slave_fd, stdout=subprocess.PIPE,
|
hsmtool.start(stdin=slave_fd, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
assert hsmtool.proc.wait(WAIT_TIMEOUT) == 2
|
assert hsmtool.proc.wait(WAIT_TIMEOUT) == 2
|
||||||
os.remove(hsm_path)
|
os.remove(hsm_path)
|
||||||
|
|
||||||
# We can generate a valid hsm_secret from a wordlist and a "passphrase"
|
# 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,
|
hsmtool.start(stdin=slave_fd, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
hsmtool.wait_for_log(r"Select your language:")
|
hsmtool.wait_for_log(r"Select your language:")
|
||||||
|
|||||||
Reference in New Issue
Block a user