diff --git a/walletunlocker/service_test.go b/walletunlocker/service_test.go index 01b413ca..55e58784 100644 --- a/walletunlocker/service_test.go +++ b/walletunlocker/service_test.go @@ -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") }