From 2c8914e7bc13adb9bb0a56ed6ee01d9b215b47a6 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 4 Sep 2018 18:52:16 -0700 Subject: [PATCH] lnwallet: ensure that each backend uses a distinct seed in integration tests In this commit, we add an additional degree of isolation to the set of integration tests. A bug was recently fixed to ensure that the wallet always starts rescans from _after_ it's birthday. In the past it would miss some funds that were deposited _right_ before the birthday of the wallet. Fixing this bug exposed a test flake wherein the btcd node would itself rescan back and collect some of the funds that were last sent to the bitcoind node. In order to fix this, we now ensure that each backend will use a unique HD seed such that the tests are still deterministic for each backend and role. --- lnwallet/interface_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lnwallet/interface_test.go b/lnwallet/interface_test.go index d71025a8c..eb2be23e3 100644 --- a/lnwallet/interface_test.go +++ b/lnwallet/interface_test.go @@ -2,6 +2,7 @@ package lnwallet_test import ( "bytes" + "crypto/sha256" "encoding/hex" "fmt" "io/ioutil" @@ -2104,6 +2105,7 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver, backEnd string, miningNode *rpctest.Harness, rpcConfig rpcclient.ConnConfig, chainNotifier *btcdnotify.BtcdNotifier) { + var ( bio lnwallet.BlockChainIO @@ -2282,9 +2284,14 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver, t.Fatalf("unknown chain driver: %v", backEnd) } + aliceSeed := sha256.New() + aliceSeed.Write([]byte(backEnd)) + aliceSeed.Write(aliceHDSeed[:]) + aliceSeedBytes := aliceSeed.Sum(nil) + aliceWalletConfig := &btcwallet.Config{ PrivatePass: []byte("alice-pass"), - HdSeed: aliceHDSeed[:], + HdSeed: aliceSeedBytes, DataDir: tempTestDirAlice, NetParams: netParams, ChainSource: aliceClient, @@ -2301,9 +2308,14 @@ func runTests(t *testing.T, walletDriver *lnwallet.WalletDriver, keychain.CoinTypeTestnet, ) + bobSeed := sha256.New() + bobSeed.Write([]byte(backEnd)) + bobSeed.Write(bobHDSeed[:]) + bobSeedBytes := bobSeed.Sum(nil) + bobWalletConfig := &btcwallet.Config{ PrivatePass: []byte("bob-pass"), - HdSeed: bobHDSeed[:], + HdSeed: bobSeedBytes, DataDir: tempTestDirBob, NetParams: netParams, ChainSource: bobClient,