walletunlocker/service_test: check recovery window is threaded

This commit is contained in:
Conner Fromknecht 2018-04-02 16:58:28 -07:00
parent f8c0357770
commit 3cb87f377f
No known key found for this signature in database
GPG Key ID: 39DE78FBE6ACB0EF

View File

@ -33,6 +33,8 @@ var (
}
testNetParams = &chaincfg.MainNetParams
testRecoveryWindow uint32 = 150
)
func createTestWallet(t *testing.T, dir string, netParams *chaincfg.Params) {
@ -209,6 +211,7 @@ func TestInitWallet(t *testing.T) {
WalletPassword: testPassword,
CipherSeedMnemonic: []string(mnemonic[:]),
AezeedPassphrase: pass,
RecoveryWindow: int32(testRecoveryWindow),
}
_, err = service.InitWallet(ctx, req)
if err != nil {
@ -238,6 +241,11 @@ func TestInitWallet(t *testing.T) {
"got %x", cipherSeed.Entropy[:],
msg.WalletSeed.Entropy[:])
}
if msg.RecoveryWindow != testRecoveryWindow {
t.Fatalf("mismatched recovery window: expected %v,"+
"got %v", testRecoveryWindow,
msg.RecoveryWindow)
}
case <-time.After(3 * time.Second):
t.Fatalf("password not received")
@ -314,6 +322,7 @@ func TestUnlockWallet(t *testing.T) {
ctx := context.Background()
req := &lnrpc.UnlockWalletRequest{
WalletPassword: testPassword,
RecoveryWindow: int32(testRecoveryWindow),
}
// Should fail to unlock non-existing wallet.
@ -340,13 +349,18 @@ func TestUnlockWallet(t *testing.T) {
t.Fatalf("unable to unlock wallet: %v", err)
}
// Password should be sent over the channel.
// Password and recovery window should be sent over the channel.
select {
case unlockMsg := <-service.UnlockMsgs:
if !bytes.Equal(unlockMsg.Passphrase, testPassword) {
t.Fatalf("expected to receive password %x, got %x",
testPassword, unlockMsg.Passphrase)
}
if unlockMsg.RecoveryWindow != testRecoveryWindow {
t.Fatalf("expected to receive recovery window %d, "+
"got %d", testRecoveryWindow,
unlockMsg.RecoveryWindow)
}
case <-time.After(3 * time.Second):
t.Fatalf("password not received")
}