2021-04-18 19:07:35 -04:00

105 lines
1.9 KiB
Plaintext

#!/usr/bin/expect
source ./test.exp
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"
test_label "Should create BIP39 mnemonic"
spawn qr-backup.sh --create-bip39-mnemonic
expect {
-re {Format USB flash drive \(y or n\)\?} {
test_send "n\r"
}
}
expect {
-re {\[sudo\] password for pi:} {
test_send "$env(password)\r"
}
}
expect {
-re {Creating BIP39 mnemonic…}
}
expect {
-re {([a-z]+ ?){24}} {
test_ok true
}
}
test_label "Should validate valid BIP39 mnemonic"
spawn qr-backup.sh --validate-bip39-mnemonic
expect {
-re {Format USB flash drive \(y or n\)\?} {
test_send "n\r"
}
}
expect {
-re {\[sudo\] password for pi:} {
test_send "$env(password)\r"
}
}
expect {
-re {Please type secret and press enter, then ctrl\+d} {
test_send "$bip39_mnemonic\r"
test_send "\x04"
}
}
expect {
-re {Please type secret and press enter, then ctrl\+d \(again\)} {
test_send "$bip39_mnemonic\r"
test_send "\x04"
}
}
expect {
-re {Please type passphrase and press enter} {
test_ok true
}
}
test_label "Should fail to validate invalid BIP39 mnemonic"
spawn qr-backup.sh --validate-bip39-mnemonic
expect {
-re {Format USB flash drive \(y or n\)\?} {
test_send "n\r"
}
}
expect {
-re {\[sudo\] password for pi:} {
test_send "$env(password)\r"
}
}
expect {
-re {Please type secret and press enter, then ctrl\+d} {
test_send "$electrum_mnemonic\r"
test_send "\x04"
}
}
expect {
-re {Please type secret and press enter, then ctrl\+d \(again\)} {
test_send "$electrum_mnemonic\r"
test_send "\x04"
}
}
expect {
-re {Invalid BIP39 mnemonic} {
test_ok true
}
}