mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
hsm: Stabilize the hsm encryption and decryption tests
We were using sleeps to hope we catch the password prompt. This makes the test flaky. So I added a help text followed by a `fflush` to make sure we catcht he right moment, instead of guessing. The `fflush` is also useful for debugging if a user ever pipes the output to a file it'd get buffered and the user would wait forever. The same applies for automated systems such as `expect` or `pexpect` based scripts that enter the password on prompt.
This commit is contained in:
@@ -331,7 +331,12 @@ static char *opt_set_hsm_password(struct lightningd *ld)
|
||||
temp_term.c_lflag &= ~ECHO;
|
||||
if (tcsetattr(fileno(stdin), TCSAFLUSH, &temp_term) != 0)
|
||||
return "Could not disable password echoing.";
|
||||
printf("Enter hsm_secret password : ");
|
||||
printf("The hsm_secret is encrypted with a password. In order to "
|
||||
"decrypt it and start the node you must provide the password.\n");
|
||||
printf("Enter hsm_secret password: ");
|
||||
/* If we don't flush we might end up being buffered and we might seem
|
||||
* to hang while we wait for the password. */
|
||||
fflush(stdout);
|
||||
if (getline(&passwd, &passwd_size, stdin) < 0)
|
||||
return "Could not read password from stdin.";
|
||||
if(passwd[strlen(passwd) - 1] == '\n')
|
||||
|
||||
Reference in New Issue
Block a user