Skip to content

Commit 1ca8bfa

Browse files
committed
Some of the tests work!
1 parent 73606f8 commit 1ca8bfa

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

tests/test_wallet.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,16 +1532,17 @@ def test_hsmtool_checkhsm_with_passphrase(node_factory):
15321532
hsmtool = HsmTool(node_factory.directory, "checkhsm", hsm_path)
15331533
master_fd, slave_fd = os.openpty()
15341534
hsmtool.start(stdin=slave_fd)
1535-
hsmtool.wait_for_log(r"Enter hsm_secret password:") # Unlock file
1535+
hsmtool.wait_for_log(r"Enter hsm_secret password:") # Decrypt file
15361536
write_all(master_fd, "secret_passphrase\n".encode("utf-8"))
1537-
hsmtool.wait_for_log(r"Enter your passphrase:") # Verification passphrase
1537+
hsmtool.wait_for_log(r"Enter your passphrase:") # Backup verification
15381538
write_all(master_fd, "secret_passphrase\n".encode("utf-8"))
15391539
hsmtool.wait_for_log(r"Introduce your BIP39 word list")
15401540
write_all(master_fd, "ritual idle hat sunny universe pluck key alpha wing cake have wedding\n".encode("utf-8"))
15411541
assert hsmtool.proc.wait(WAIT_TIMEOUT) == 0
15421542
hsmtool.is_in_log(r"OK")
15431543

15441544

1545+
15451546
def test_hsmtool_checkhsm_no_passphrase(node_factory):
15461547
"""Test checkhsm with mnemonic that has no passphrase"""
15471548
l1 = node_factory.get_node(start=False)
@@ -2059,8 +2060,6 @@ def test_hsmtool_makerune(node_factory):
20592060
hsmtool = HsmTool(node_factory.directory, "generatehsm", hsm_path)
20602061
master_fd, slave_fd = os.openpty()
20612062
hsmtool.start(stdin=slave_fd)
2062-
hsmtool.wait_for_log(r"Select your language:")
2063-
write_all(master_fd, "0\n".encode("utf-8"))
20642063
hsmtool.wait_for_log(r"Introduce your BIP39 word list")
20652064
write_all(master_fd, "ritual idle hat sunny universe pluck key alpha wing "
20662065
"cake have wedding\n".encode("utf-8"))
@@ -2069,8 +2068,14 @@ def test_hsmtool_makerune(node_factory):
20692068
assert hsmtool.proc.wait(WAIT_TIMEOUT) == 0
20702069
hsmtool.is_in_log(r"New hsm_secret file created")
20712070

2072-
cmd_line = ["tools/hsmtool", "makerune", hsm_path]
2073-
out = subprocess.check_output(cmd_line).decode("utf8").split("\n")[0]
2071+
# Test makerune with the passphrase
2072+
hsmtool = HsmTool(node_factory.directory, "makerune", hsm_path)
2073+
master_fd, slave_fd = os.openpty()
2074+
hsmtool.start(stdin=slave_fd)
2075+
hsmtool.wait_for_log(r"Enter hsm_secret password:")
2076+
write_all(master_fd, "This is actually not a passphrase\n".encode("utf-8"))
2077+
assert hsmtool.proc.wait(WAIT_TIMEOUT) == 0
2078+
out = hsmtool.logs.split("\n")[-2] # Get the rune output (last line before empty line)
20742079

20752080
l1.start()
20762081

tools/hsmtool.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,6 @@ static int check_hsm(const char *hsm_secret_path)
532532
errx(EXITCODE_ERROR_HSM_FILE, "Reading hsm_secret");
533533
tal_resize(&contents, tal_bytelen(contents) - 1);
534534

535-
enum hsm_secret_type type = detect_hsm_secret_type(contents, tal_bytelen(contents));
536-
537535
/* Get the actual seed from the file */
538536
struct hsm_secret *hsms = load_hsm_secret(tmpctx, hsm_secret_path);
539537
file_secret = hsms->secret;

0 commit comments

Comments
 (0)