From e44b2b91fc3853ab54d2798f5432350ca17d7017 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 16 Nov 2016 12:46:37 -0800 Subject: [PATCH] netharness: remove test for the node restart method This commit removes the prior test for the node restart method as it can be very flaky due to process not always relinquishing ports they were blinded to. The solution for this problem is to have the lnd processes obtain ports to listen on based on their process ID. --- networktest_test.go | 74 --------------------------------------------- 1 file changed, 74 deletions(-) diff --git a/networktest_test.go b/networktest_test.go index b5285f46c..06ab7d0f9 100644 --- a/networktest_test.go +++ b/networktest_test.go @@ -1,75 +1 @@ package main - -import ( - "context" - "testing" - - "github.com/lightningnetwork/lnd/lnrpc" - "github.com/roasbeef/btcd/rpctest" - "github.com/roasbeef/btcrpcclient" -) - -// TODO(roasbeef): randomize ports so can start multiple instance with each -// other, will need to catch up to rpctest upstream. - -func TestNodeRestart(t *testing.T) { - // Create a new instance of the network harness in order to initialize the - // necessary state. We'll also need to create a temporary instance of - // rpctest due to initialization dependancies. - lndHarness, err := newNetworkHarness() - if err != nil { - t.Fatalf("unable to create lightning network harness: %v", err) - } - defer lndHarness.TearDownAll() - - handlers := &btcrpcclient.NotificationHandlers{ - OnTxAccepted: lndHarness.OnTxAccepted, - } - - btcdHarness, err := rpctest.New(harnessNetParams, handlers, nil) - if err != nil { - t.Fatalf("unable to create mining node: %v", err) - } - defer btcdHarness.TearDown() - if err := btcdHarness.SetUp(true, 50); err != nil { - t.Fatalf("unable to set up mining node: %v", err) - } - if err := btcdHarness.Node.NotifyNewTransactions(false); err != nil { - t.Fatalf("unable to request transaction notifications: %v", err) - } - - if err := lndHarness.InitializeSeedNodes(btcdHarness, nil); err != nil { - t.Fatalf("unable to initialize seed nodes: %v", err) - } - if err = lndHarness.SetUp(); err != nil { - t.Fatalf("unable to set up test lightning network: %v", err) - } - - // With the harness set up, we can test the node restart method, - // asserting all data is properly persisted and recovered. - ctx := context.Background() - - // First, we'll test restarting one of the initial seed nodes: Alice. - alice := lndHarness.Alice - aliceInfo, err := alice.GetInfo(ctx, &lnrpc.GetInfoRequest{}) - if err != nil { - t.Fatalf("unable to query for alice's info: %v", err) - } - - // With alice's node information stored, attempt to restart the node. - if lndHarness.RestartNode(alice); err != nil { - t.Fatalf("unable to resart node: %v", err) - } - - // Query for alice's current information, it should be identical to - // what we received above. - aliceInfoRestart, err := alice.GetInfo(ctx, &lnrpc.GetInfoRequest{}) - if err != nil { - t.Fatalf("unable to query for alice's info: %v", err) - } - - if aliceInfo.IdentityPubkey != aliceInfoRestart.IdentityPubkey { - t.Fatalf("node info after restart doesn't match: %v vs %v", - aliceInfo.IdentityPubkey, aliceInfoRestart.IdentityPubkey) - } -}