walletunlocker/service_test: check recovery window is threaded
This commit is contained in:
parent
f8c0357770
commit
3cb87f377f
@ -33,6 +33,8 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
testNetParams = &chaincfg.MainNetParams
|
testNetParams = &chaincfg.MainNetParams
|
||||||
|
|
||||||
|
testRecoveryWindow uint32 = 150
|
||||||
)
|
)
|
||||||
|
|
||||||
func createTestWallet(t *testing.T, dir string, netParams *chaincfg.Params) {
|
func createTestWallet(t *testing.T, dir string, netParams *chaincfg.Params) {
|
||||||
@ -209,6 +211,7 @@ func TestInitWallet(t *testing.T) {
|
|||||||
WalletPassword: testPassword,
|
WalletPassword: testPassword,
|
||||||
CipherSeedMnemonic: []string(mnemonic[:]),
|
CipherSeedMnemonic: []string(mnemonic[:]),
|
||||||
AezeedPassphrase: pass,
|
AezeedPassphrase: pass,
|
||||||
|
RecoveryWindow: int32(testRecoveryWindow),
|
||||||
}
|
}
|
||||||
_, err = service.InitWallet(ctx, req)
|
_, err = service.InitWallet(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -238,6 +241,11 @@ func TestInitWallet(t *testing.T) {
|
|||||||
"got %x", cipherSeed.Entropy[:],
|
"got %x", cipherSeed.Entropy[:],
|
||||||
msg.WalletSeed.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):
|
case <-time.After(3 * time.Second):
|
||||||
t.Fatalf("password not received")
|
t.Fatalf("password not received")
|
||||||
@ -314,6 +322,7 @@ func TestUnlockWallet(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
req := &lnrpc.UnlockWalletRequest{
|
req := &lnrpc.UnlockWalletRequest{
|
||||||
WalletPassword: testPassword,
|
WalletPassword: testPassword,
|
||||||
|
RecoveryWindow: int32(testRecoveryWindow),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should fail to unlock non-existing wallet.
|
// Should fail to unlock non-existing wallet.
|
||||||
@ -340,13 +349,18 @@ func TestUnlockWallet(t *testing.T) {
|
|||||||
t.Fatalf("unable to unlock wallet: %v", err)
|
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 {
|
select {
|
||||||
case unlockMsg := <-service.UnlockMsgs:
|
case unlockMsg := <-service.UnlockMsgs:
|
||||||
if !bytes.Equal(unlockMsg.Passphrase, testPassword) {
|
if !bytes.Equal(unlockMsg.Passphrase, testPassword) {
|
||||||
t.Fatalf("expected to receive password %x, got %x",
|
t.Fatalf("expected to receive password %x, got %x",
|
||||||
testPassword, unlockMsg.Passphrase)
|
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):
|
case <-time.After(3 * time.Second):
|
||||||
t.Fatalf("password not received")
|
t.Fatalf("password not received")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user