From ea6ed7b8d20877d214aae1b04c51a4bdd778a013 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 11 Mar 2019 16:24:45 -0700 Subject: [PATCH] test: update to new getChanPointFundingTxid In this commit, we update all uses of the `getChanPointFundingTxid` to match the new function signature. We no longer need to convert to a chainhash.Hash, as the method does so underneath now. --- lnd_test.go | 288 +++++++++++----------------------------------------- 1 file changed, 60 insertions(+), 228 deletions(-) diff --git a/lnd_test.go b/lnd_test.go index 3dd83c77..916dc234 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -122,6 +122,18 @@ func assertTxInBlock(t *harnessTest, block *wire.MsgBlock, txid *chainhash.Hash) t.Fatalf("tx was not included in block") } +func rpcPointToWirePoint(t *harnessTest, chanPoint *lnrpc.ChannelPoint) wire.OutPoint { + txid, err := getChanPointFundingTxid(chanPoint) + if err != nil { + t.Fatalf("unable to get txid: %v", err) + } + + return wire.OutPoint{ + Hash: *txid, + Index: chanPoint.OutputIndex, + } +} + // mineBlocks mine 'num' of blocks and check that blocks are present in // node blockchain. numTxs should be set to the number of transactions // (excluding the coinbase) we expect to be included in the first mined block. @@ -192,14 +204,10 @@ func openChannelAndAssert(ctx context.Context, t *harnessTest, if err != nil { t.Fatalf("error while waiting for channel open: %v", err) } - txidHash, err := getChanPointFundingTxid(fundingChanPoint) + fundingTxID, err := getChanPointFundingTxid(fundingChanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - fundingTxID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } assertTxInBlock(t, block, fundingTxID) // The channel should be listed in the peer information returned by @@ -297,14 +305,10 @@ func assertChannelClosed(ctx context.Context, t *harnessTest, fundingChanPoint *lnrpc.ChannelPoint, closeUpdates lnrpc.Lightning_CloseChannelClient) *chainhash.Hash { - txidHash, err := getChanPointFundingTxid(fundingChanPoint) + txid, err := getChanPointFundingTxid(fundingChanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - txid, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to convert to chainhash: %v", err) - } chanPointStr := fmt.Sprintf("%v:%v", txid, fundingChanPoint.OutputIndex) // At this point, the channel should now be marked as being in the @@ -369,12 +373,7 @@ func assertChannelClosed(ctx context.Context, t *harnessTest, func waitForChannelPendingForceClose(ctx context.Context, node *lntest.HarnessNode, fundingChanPoint *lnrpc.ChannelPoint) error { - txidHash, err := getChanPointFundingTxid(fundingChanPoint) - if err != nil { - return err - } - - txid, err := chainhash.NewHash(txidHash) + txid, err := getChanPointFundingTxid(fundingChanPoint) if err != nil { return err } @@ -584,7 +583,9 @@ func completePaymentRequests(ctx context.Context, client lnrpc.LightningClient, } for _, payReq := range paymentRequests { - sendReq := &lnrpc.SendRequest{PaymentRequest: payReq} + sendReq := &lnrpc.SendRequest{ + PaymentRequest: payReq, + } err := payStream.Send(sendReq) if err != nil { return err @@ -1020,11 +1021,7 @@ func testUnconfirmedChannelFunding(net *lntest.NetworkHarness, t *harnessTest) { // txStr returns the string representation of the channel's funding transaction. func txStr(chanPoint *lnrpc.ChannelPoint) string { - txidHash, err := getChanPointFundingTxid(chanPoint) - if err != nil { - return "" - } - fundingTxID, err := chainhash.NewHash(txidHash) + fundingTxID, err := getChanPointFundingTxid(chanPoint) if err != nil { return "" } @@ -2693,14 +2690,10 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) { // Compute the outpoint of the channel, which we will use repeatedly to // locate the pending channel information in the rpc responses. - txidHash, err := getChanPointFundingTxid(chanPoint) + txid, err := getChanPointFundingTxid(chanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - txid, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } op := wire.OutPoint{ Hash: *txid, Index: chanPoint.OutputIndex, @@ -3920,14 +3913,10 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) { ) networkChans = append(networkChans, chanPointAlice) - txidHash, err := getChanPointFundingTxid(chanPointAlice) + aliceChanTXID, err := getChanPointFundingTxid(chanPointAlice) if err != nil { t.Fatalf("unable to get txid: %v", err) } - aliceChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } aliceFundPoint := wire.OutPoint{ Hash: *aliceChanTXID, Index: chanPointAlice.OutputIndex, @@ -3963,14 +3952,10 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) { }, ) networkChans = append(networkChans, chanPointDave) - txidHash, err = getChanPointFundingTxid(chanPointDave) + daveChanTXID, err := getChanPointFundingTxid(chanPointDave) if err != nil { t.Fatalf("unable to get txid: %v", err) } - daveChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } daveFundPoint := wire.OutPoint{ Hash: *daveChanTXID, Index: chanPointDave.OutputIndex, @@ -4002,14 +3987,10 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) { ) networkChans = append(networkChans, chanPointCarol) - txidHash, err = getChanPointFundingTxid(chanPointCarol) + carolChanTXID, err := getChanPointFundingTxid(chanPointCarol) if err != nil { t.Fatalf("unable to get txid: %v", err) } - carolChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } carolFundPoint := wire.OutPoint{ Hash: *carolChanTXID, Index: chanPointCarol.OutputIndex, @@ -4020,14 +4001,10 @@ func testMultiHopPayments(net *lntest.NetworkHarness, t *harnessTest) { nodeNames := []string{"Alice", "Bob", "Carol", "Dave"} for _, chanPoint := range networkChans { for i, node := range nodes { - txidHash, err := getChanPointFundingTxid(chanPoint) + txid, err := getChanPointFundingTxid(chanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - txid, e := chainhash.NewHash(txidHash) - if e != nil { - t.Fatalf("unable to create sha hash: %v", e) - } point := wire.OutPoint{ Hash: *txid, Index: chanPoint.OutputIndex, @@ -4214,14 +4191,10 @@ func testSingleHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) { ) networkChans = append(networkChans, chanPointAlice) - txidHash, err := getChanPointFundingTxid(chanPointAlice) + aliceChanTXID, err := getChanPointFundingTxid(chanPointAlice) if err != nil { t.Fatalf("unable to get txid: %v", err) } - aliceChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } aliceFundPoint := wire.OutPoint{ Hash: *aliceChanTXID, Index: chanPointAlice.OutputIndex, @@ -4232,14 +4205,10 @@ func testSingleHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) { nodeNames := []string{"Alice", "Bob"} for _, chanPoint := range networkChans { for i, node := range nodes { - txidHash, err := getChanPointFundingTxid(chanPoint) + txid, err := getChanPointFundingTxid(chanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - txid, e := chainhash.NewHash(txidHash) - if e != nil { - t.Fatalf("unable to create sha hash: %v", e) - } point := wire.OutPoint{ Hash: *txid, Index: chanPoint.OutputIndex, @@ -4359,14 +4328,10 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) { ) networkChans = append(networkChans, chanPointAlice) - txidHash, err := getChanPointFundingTxid(chanPointAlice) + aliceChanTXID, err := getChanPointFundingTxid(chanPointAlice) if err != nil { t.Fatalf("unable to get txid: %v", err) } - aliceChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } aliceFundPoint := wire.OutPoint{ Hash: *aliceChanTXID, Index: chanPointAlice.OutputIndex, @@ -4398,14 +4363,10 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) { }, ) networkChans = append(networkChans, chanPointBob) - txidHash, err = getChanPointFundingTxid(chanPointBob) + bobChanTXID, err := getChanPointFundingTxid(chanPointBob) if err != nil { t.Fatalf("unable to get txid: %v", err) } - bobChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } bobFundPoint := wire.OutPoint{ Hash: *bobChanTXID, Index: chanPointBob.OutputIndex, @@ -4416,14 +4377,10 @@ func testMultiHopSendToRoute(net *lntest.NetworkHarness, t *harnessTest) { nodeNames := []string{"Alice", "Bob", "Carol"} for _, chanPoint := range networkChans { for i, node := range nodes { - txidHash, err := getChanPointFundingTxid(chanPoint) + txid, err := getChanPointFundingTxid(chanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - txid, e := chainhash.NewHash(txidHash) - if e != nil { - t.Fatalf("unable to create sha hash: %v", e) - } point := wire.OutPoint{ Hash: *txid, Index: chanPoint.OutputIndex, @@ -4805,14 +4762,10 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) { ) networkChans = append(networkChans, chanPointAlice) - txidHash, err := getChanPointFundingTxid(chanPointAlice) + aliceChanTXID, err := getChanPointFundingTxid(chanPointAlice) if err != nil { t.Fatalf("unable to get txid: %v", err) } - aliceChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } aliceFundPoint := wire.OutPoint{ Hash: *aliceChanTXID, Index: chanPointAlice.OutputIndex, @@ -4842,14 +4795,10 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) { }, ) networkChans = append(networkChans, chanPointDave) - txidHash, err = getChanPointFundingTxid(chanPointDave) + daveChanTXID, err := getChanPointFundingTxid(chanPointDave) if err != nil { t.Fatalf("unable to get txid: %v", err) } - daveChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } daveFundPoint := wire.OutPoint{ Hash: *daveChanTXID, Index: chanPointDave.OutputIndex, @@ -4881,14 +4830,10 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) { ) networkChans = append(networkChans, chanPointCarol) - txidHash, err = getChanPointFundingTxid(chanPointCarol) + carolChanTXID, err := getChanPointFundingTxid(chanPointCarol) if err != nil { t.Fatalf("unable to get txid: %v", err) } - carolChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } carolFundPoint := wire.OutPoint{ Hash: *carolChanTXID, Index: chanPointCarol.OutputIndex, @@ -4900,14 +4845,10 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) { nodeNames := []string{"Alice", "Bob", "Carol", "Dave"} for _, chanPoint := range networkChans { for i, node := range nodes { - txidHash, err := getChanPointFundingTxid(chanPoint) + txid, err := getChanPointFundingTxid(chanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - txid, e := chainhash.NewHash(txidHash) - if e != nil { - t.Fatalf("unable to create sha hash: %v", e) - } point := wire.OutPoint{ Hash: *txid, Index: chanPoint.OutputIndex, @@ -4949,14 +4890,10 @@ func testPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) { if err != nil { t.Fatalf("error while waiting for channel open: %v", err) } - txidHash, err = getChanPointFundingTxid(chanPointPrivate) + fundingTxID, err := getChanPointFundingTxid(chanPointPrivate) if err != nil { t.Fatalf("unable to get txid: %v", err) } - fundingTxID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } assertTxInBlock(t, block, fundingTxID) // The channel should be listed in the peer information returned by @@ -5392,14 +5329,10 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) } // Retrieve Alice's funding outpoint. - txidHash, err := getChanPointFundingTxid(chanPointAlice) + aliceChanTXID, err := getChanPointFundingTxid(chanPointAlice) if err != nil { t.Fatalf("unable to get txid: %v", err) } - aliceChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } aliceFundPoint := wire.OutPoint{ Hash: *aliceChanTXID, Index: chanPointAlice.OutputIndex, @@ -5445,14 +5378,10 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) } // Retrieve Bob's funding outpoint. - txidHash, err = getChanPointFundingTxid(chanPointBob) + bobChanTXID, err := getChanPointFundingTxid(chanPointBob) if err != nil { t.Fatalf("unable to get txid: %v", err) } - bobChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } bobFundPoint := wire.OutPoint{ Hash: *bobChanTXID, Index: chanPointBob.OutputIndex, @@ -5504,14 +5433,10 @@ func testMultiHopOverPrivateChannels(net *lntest.NetworkHarness, t *harnessTest) } // Retrieve Carol's funding point. - txidHash, err = getChanPointFundingTxid(chanPointCarol) + carolChanTXID, err := getChanPointFundingTxid(chanPointCarol) if err != nil { t.Fatalf("unable to get txid: %v", err) } - carolChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } carolFundPoint := wire.OutPoint{ Hash: *carolChanTXID, Index: chanPointCarol.OutputIndex, @@ -6123,14 +6048,10 @@ func testMaxPendingChannels(net *lntest.NetworkHarness, t *harnessTest) { t.Fatalf("error while waiting for channel open: %v", err) } - txidHash, err := getChanPointFundingTxid(fundingChanPoint) + fundingTxID, err := getChanPointFundingTxid(fundingChanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - fundingTxID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } // Ensure that the funding transaction enters a block, and is // properly advertised by Alice. @@ -9471,14 +9392,10 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest) { } // Bob's force close transaction should now be found in the mempool. - txidHash, err := getChanPointFundingTxid(bobChanPoint) + bobFundingTxid, err := getChanPointFundingTxid(bobChanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - bobFundingTxid, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } assertSpendingTxInMempool( t, net.Miner.Node, minerMempoolTimeout, wire.OutPoint{ Hash: *bobFundingTxid, @@ -9702,16 +9619,11 @@ func testMultiHopReceiverChainClaim(net *lntest.NetworkHarness, t *harnessTest) t.Fatalf("expected transaction not found in mempool: %v", err) } - txidHash, err := getChanPointFundingTxid(bobChanPoint) + bobFundingTxid, err := getChanPointFundingTxid(bobChanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - bobFundingTxid, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } - carolFundingPoint := wire.OutPoint{ Hash: *bobFundingTxid, Index: bobChanPoint.OutputIndex, @@ -10440,14 +10352,10 @@ func testMultiHopHtlcLocalChainClaim(net *lntest.NetworkHarness, t *harnessTest) if err != nil { t.Fatalf("transactions not found in mempool: %v", err) } - txidHash, err := getChanPointFundingTxid(bobChanPoint) + bobFundingTxid, err := getChanPointFundingTxid(bobChanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - bobFundingTxid, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } carolFundingPoint := wire.OutPoint{ Hash: *bobFundingTxid, Index: bobChanPoint.OutputIndex, @@ -10795,14 +10703,10 @@ func testMultiHopHtlcRemoteChainClaim(net *lntest.NetworkHarness, t *harnessTest if err != nil { t.Fatalf("transactions not found in mempool: %v", err) } - txidHash, err := getChanPointFundingTxid(bobChanPoint) + bobFundingTxid, err := getChanPointFundingTxid(bobChanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - bobFundingTxid, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } carolFundingPoint := wire.OutPoint{ Hash: *bobFundingTxid, Index: bobChanPoint.OutputIndex, @@ -11005,14 +10909,10 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) { ) networkChans = append(networkChans, chanPointAlice) - txidHash, err := getChanPointFundingTxid(chanPointAlice) + aliceChanTXID, err := getChanPointFundingTxid(chanPointAlice) if err != nil { t.Fatalf("unable to get txid: %v", err) } - aliceChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } aliceFundPoint := wire.OutPoint{ Hash: *aliceChanTXID, Index: chanPointAlice.OutputIndex, @@ -11049,14 +10949,10 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) { }, ) networkChans = append(networkChans, chanPointDave) - txidHash, err = getChanPointFundingTxid(chanPointDave) + daveChanTXID, err := getChanPointFundingTxid(chanPointDave) if err != nil { t.Fatalf("unable to get txid: %v", err) } - daveChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } daveFundPoint := wire.OutPoint{ Hash: *daveChanTXID, Index: chanPointDave.OutputIndex, @@ -11090,14 +10986,10 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) { ) networkChans = append(networkChans, chanPointCarol) - txidHash, err = getChanPointFundingTxid(chanPointCarol) + carolChanTXID, err := getChanPointFundingTxid(chanPointCarol) if err != nil { t.Fatalf("unable to get txid: %v", err) } - carolChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } carolFundPoint := wire.OutPoint{ Hash: *carolChanTXID, Index: chanPointCarol.OutputIndex, @@ -11108,14 +11000,10 @@ func testSwitchCircuitPersistence(net *lntest.NetworkHarness, t *harnessTest) { nodeNames := []string{"Alice", "Bob", "Carol", "Dave"} for _, chanPoint := range networkChans { for i, node := range nodes { - txidHash, err := getChanPointFundingTxid(chanPoint) + txid, err := getChanPointFundingTxid(chanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - txid, e := chainhash.NewHash(txidHash) - if e != nil { - t.Fatalf("unable to create sha hash: %v", e) - } point := wire.OutPoint{ Hash: *txid, Index: chanPoint.OutputIndex, @@ -11344,14 +11232,10 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) { ) networkChans = append(networkChans, chanPointAlice) - txidHash, err := getChanPointFundingTxid(chanPointAlice) + aliceChanTXID, err := getChanPointFundingTxid(chanPointAlice) if err != nil { t.Fatalf("unable to get txid: %v", err) } - aliceChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } aliceFundPoint := wire.OutPoint{ Hash: *aliceChanTXID, Index: chanPointAlice.OutputIndex, @@ -11388,14 +11272,10 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) { }, ) networkChans = append(networkChans, chanPointDave) - txidHash, err = getChanPointFundingTxid(chanPointDave) + daveChanTXID, err := getChanPointFundingTxid(chanPointDave) if err != nil { t.Fatalf("unable to get txid: %v", err) } - daveChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } daveFundPoint := wire.OutPoint{ Hash: *daveChanTXID, Index: chanPointDave.OutputIndex, @@ -11429,14 +11309,10 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) { ) networkChans = append(networkChans, chanPointCarol) - txidHash, err = getChanPointFundingTxid(chanPointCarol) + carolChanTXID, err := getChanPointFundingTxid(chanPointCarol) if err != nil { t.Fatalf("unable to get txid: %v", err) } - carolChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } carolFundPoint := wire.OutPoint{ Hash: *carolChanTXID, Index: chanPointCarol.OutputIndex, @@ -11447,14 +11323,10 @@ func testSwitchOfflineDelivery(net *lntest.NetworkHarness, t *harnessTest) { nodeNames := []string{"Alice", "Bob", "Carol", "Dave"} for _, chanPoint := range networkChans { for i, node := range nodes { - txidHash, err := getChanPointFundingTxid(chanPoint) + txid, err := getChanPointFundingTxid(chanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - txid, e := chainhash.NewHash(txidHash) - if e != nil { - t.Fatalf("unable to create sha hash: %v", e) - } point := wire.OutPoint{ Hash: *txid, Index: chanPoint.OutputIndex, @@ -11690,14 +11562,10 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness ) networkChans = append(networkChans, chanPointAlice) - txidHash, err := getChanPointFundingTxid(chanPointAlice) + aliceChanTXID, err := getChanPointFundingTxid(chanPointAlice) if err != nil { t.Fatalf("unable to get txid: %v", err) } - aliceChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } aliceFundPoint := wire.OutPoint{ Hash: *aliceChanTXID, Index: chanPointAlice.OutputIndex, @@ -11735,14 +11603,10 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness ) networkChans = append(networkChans, chanPointDave) - txidHash, err = getChanPointFundingTxid(chanPointDave) + daveChanTXID, err := getChanPointFundingTxid(chanPointDave) if err != nil { t.Fatalf("unable to get txid: %v", err) } - daveChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } daveFundPoint := wire.OutPoint{ Hash: *daveChanTXID, Index: chanPointDave.OutputIndex, @@ -11776,14 +11640,10 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness ) networkChans = append(networkChans, chanPointCarol) - txidHash, err = getChanPointFundingTxid(chanPointCarol) + carolChanTXID, err := getChanPointFundingTxid(chanPointCarol) if err != nil { t.Fatalf("unable to get txid: %v", err) } - carolChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } carolFundPoint := wire.OutPoint{ Hash: *carolChanTXID, Index: chanPointCarol.OutputIndex, @@ -11794,14 +11654,10 @@ func testSwitchOfflineDeliveryPersistence(net *lntest.NetworkHarness, t *harness nodeNames := []string{"Alice", "Bob", "Carol", "Dave"} for _, chanPoint := range networkChans { for i, node := range nodes { - txidHash, err := getChanPointFundingTxid(chanPoint) + txid, err := getChanPointFundingTxid(chanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - txid, e := chainhash.NewHash(txidHash) - if e != nil { - t.Fatalf("unable to create sha hash: %v", e) - } point := wire.OutPoint{ Hash: *txid, Index: chanPoint.OutputIndex, @@ -12043,14 +11899,10 @@ func testSwitchOfflineDeliveryOutgoingOffline( ) networkChans = append(networkChans, chanPointAlice) - txidHash, err := getChanPointFundingTxid(chanPointAlice) + aliceChanTXID, err := getChanPointFundingTxid(chanPointAlice) if err != nil { t.Fatalf("unable to get txid: %v", err) } - aliceChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } aliceFundPoint := wire.OutPoint{ Hash: *aliceChanTXID, Index: chanPointAlice.OutputIndex, @@ -12087,14 +11939,10 @@ func testSwitchOfflineDeliveryOutgoingOffline( }, ) networkChans = append(networkChans, chanPointDave) - txidHash, err = getChanPointFundingTxid(chanPointDave) + daveChanTXID, err := getChanPointFundingTxid(chanPointDave) if err != nil { t.Fatalf("unable to get txid: %v", err) } - daveChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } daveFundPoint := wire.OutPoint{ Hash: *daveChanTXID, Index: chanPointDave.OutputIndex, @@ -12126,14 +11974,10 @@ func testSwitchOfflineDeliveryOutgoingOffline( ) networkChans = append(networkChans, chanPointCarol) - txidHash, err = getChanPointFundingTxid(chanPointCarol) + carolChanTXID, err := getChanPointFundingTxid(chanPointCarol) if err != nil { t.Fatalf("unable to get txid: %v", err) } - carolChanTXID, err := chainhash.NewHash(txidHash) - if err != nil { - t.Fatalf("unable to create sha hash: %v", err) - } carolFundPoint := wire.OutPoint{ Hash: *carolChanTXID, Index: chanPointCarol.OutputIndex, @@ -12144,14 +11988,10 @@ func testSwitchOfflineDeliveryOutgoingOffline( nodeNames := []string{"Alice", "Bob", "Carol", "Dave"} for _, chanPoint := range networkChans { for i, node := range nodes { - txidHash, err := getChanPointFundingTxid(chanPoint) + txid, err := getChanPointFundingTxid(chanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - txid, e := chainhash.NewHash(txidHash) - if e != nil { - t.Fatalf("unable to create sha hash: %v", e) - } point := wire.OutPoint{ Hash: *txid, Index: chanPoint.OutputIndex, @@ -12396,14 +12236,10 @@ func testQueryRoutes(net *lntest.NetworkHarness, t *harnessTest) { nodeNames := []string{"Alice", "Bob", "Carol", "Dave"} for _, chanPoint := range networkChans { for i, node := range nodes { - txidHash, err := getChanPointFundingTxid(chanPoint) + txid, err := getChanPointFundingTxid(chanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - txid, e := chainhash.NewHash(txidHash) - if e != nil { - t.Fatalf("unable to create sha hash: %v", e) - } point := wire.OutPoint{ Hash: *txid, Index: chanPoint.OutputIndex, @@ -12613,14 +12449,10 @@ func testRouteFeeCutoff(net *lntest.NetworkHarness, t *harnessTest) { } for _, chanPoint := range networkChans { for i, node := range nodes { - txidHash, err := getChanPointFundingTxid(chanPoint) + txid, err := getChanPointFundingTxid(chanPoint) if err != nil { t.Fatalf("unable to get txid: %v", err) } - txid, e := chainhash.NewHash(txidHash) - if e != nil { - t.Fatalf("unable to create sha hash: %v", e) - } outpoint := wire.OutPoint{ Hash: *txid, Index: chanPoint.OutputIndex,