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
set 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 electrum_mnemonic "month pet slice know amused leave now vague palm guess cattle element cross truly auto put among craft repeat van sample nephew sad family"
2021-04-18 10:06:04 -04:00
test_label "Should 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-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 {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-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} {
2021-04-18 10:06:04 -04:00
test_send "$bip39_mnemonic\r"
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\)} {
test_send "$bip39_mnemonic\r"
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-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} {
2021-04-18 10:06:04 -04:00
test_send "$electrum_mnemonic\r"
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\)} {
test_send "$electrum_mnemonic\r"
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
}
}