2021-04-17 16:31:44 -04:00
|
|
|
#!/usr/bin/expect
|
|
|
|
|
2021-04-18 10:06:04 -04:00
|
|
|
source ./test.exp
|
2021-04-17 16:31:44 -04:00
|
|
|
|
2022-01-10 08:16:25 -05:00
|
|
|
set valid_bip39_mnemonic "online pipe enough dutch decorate want moment scheme rigid enlist blast boat purse sick chalk shop brush all return betray jacket salon abandon retire"
|
|
|
|
set invalid_bip39_mnemonic "online pipe enough dutch decorate want moment scheme rigid enlist blast boat purse sick chalk shop brush all return betray jacket salon abandon check"
|
2021-04-17 16:31:44 -04:00
|
|
|
|
2021-04-19 13:43:55 -04:00
|
|
|
test_label "Should format flash drive and create BIP39 mnemonic"
|
2021-04-17 16:31:44 -04:00
|
|
|
|
|
|
|
spawn qr-backup.sh --create-bip39-mnemonic
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {Format USB flash drive \(y or n\)\?} {
|
2021-04-19 13:43:55 -04:00
|
|
|
test_send "y\r"
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {\[sudo\] password for pi:} {
|
2021-04-18 10:06:04 -04:00
|
|
|
test_send "$env(password)\r"
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-19 13:43:55 -04:00
|
|
|
expect {
|
2022-01-10 08:16:25 -05:00
|
|
|
-re {mkfs\.fat 4\.2 \(2021-01-31\)}
|
2021-04-19 13:43:55 -04:00
|
|
|
}
|
|
|
|
|
2021-04-17 16:31:44 -04:00
|
|
|
expect {
|
|
|
|
-re {Creating BIP39 mnemonic…}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
2021-04-18 10:06:04 -04:00
|
|
|
-re {([a-z]+ ?){24}} {
|
|
|
|
test_ok true
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
2021-05-21 14:02:00 -04:00
|
|
|
eof {
|
|
|
|
test_failed
|
|
|
|
}
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
|
|
|
|
2021-04-18 10:06:04 -04:00
|
|
|
test_label "Should validate valid BIP39 mnemonic"
|
2021-04-17 16:31:44 -04:00
|
|
|
|
|
|
|
spawn qr-backup.sh --validate-bip39-mnemonic
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {Format USB flash drive \(y or n\)\?} {
|
2021-04-18 10:06:04 -04:00
|
|
|
test_send "n\r"
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {\[sudo\] password for pi:} {
|
2021-04-18 10:06:04 -04:00
|
|
|
test_send "$env(password)\r"
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {Please type secret and press enter, then ctrl\+d} {
|
2022-01-10 08:16:25 -05:00
|
|
|
test_send "$valid_bip39_mnemonic\r"
|
2021-04-18 10:06:04 -04:00
|
|
|
test_send "\x04"
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
2021-04-18 10:06:04 -04:00
|
|
|
-re {Please type secret and press enter, then ctrl\+d \(again\)} {
|
2022-01-10 08:16:25 -05:00
|
|
|
test_send "$valid_bip39_mnemonic\r"
|
2021-04-18 10:06:04 -04:00
|
|
|
test_send "\x04"
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {Please type passphrase and press enter} {
|
2021-04-18 10:06:04 -04:00
|
|
|
test_ok true
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
2021-05-21 14:02:00 -04:00
|
|
|
eof {
|
|
|
|
test_failed
|
|
|
|
}
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
|
|
|
|
2021-04-18 10:06:04 -04:00
|
|
|
test_label "Should fail to validate invalid BIP39 mnemonic"
|
2021-04-17 16:31:44 -04:00
|
|
|
|
|
|
|
spawn qr-backup.sh --validate-bip39-mnemonic
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {Format USB flash drive \(y or n\)\?} {
|
2021-04-18 10:06:04 -04:00
|
|
|
test_send "n\r"
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {\[sudo\] password for pi:} {
|
2021-04-18 10:06:04 -04:00
|
|
|
test_send "$env(password)\r"
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {Please type secret and press enter, then ctrl\+d} {
|
2022-01-10 08:16:25 -05:00
|
|
|
test_send "$invalid_bip39_mnemonic\r"
|
2021-04-18 10:06:04 -04:00
|
|
|
test_send "\x04"
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
2021-04-18 10:06:04 -04:00
|
|
|
-re {Please type secret and press enter, then ctrl\+d \(again\)} {
|
2022-01-10 08:16:25 -05:00
|
|
|
test_send "$invalid_bip39_mnemonic\r"
|
2021-04-18 10:06:04 -04:00
|
|
|
test_send "\x04"
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expect {
|
|
|
|
-re {Invalid BIP39 mnemonic} {
|
2021-04-18 10:06:04 -04:00
|
|
|
test_ok true
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|
2021-05-21 14:02:00 -04:00
|
|
|
eof {
|
|
|
|
test_failed
|
|
|
|
}
|
2021-04-17 16:31:44 -04:00
|
|
|
}
|