From c27406b57988cb9f74b8176586160dfe1cb54054 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Thu, 28 May 2020 13:02:18 +0200 Subject: [PATCH] lnwallet/test: move test htlcs out of function --- lnwallet/transactions_test.go | 80 +++++++++++++++++------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/lnwallet/transactions_test.go b/lnwallet/transactions_test.go index e125eb76..f940dde1 100644 --- a/lnwallet/transactions_test.go +++ b/lnwallet/transactions_test.go @@ -222,46 +222,8 @@ func newTestContext() (tc *testContext, err error) { TxPosition: 0, } - htlcData := []struct { - incoming bool - amount lnwire.MilliSatoshi - expiry uint32 - preimage string - }{ - { - incoming: true, - amount: 1000000, - expiry: 500, - preimage: "0000000000000000000000000000000000000000000000000000000000000000", - }, - { - incoming: true, - amount: 2000000, - expiry: 501, - preimage: "0101010101010101010101010101010101010101010101010101010101010101", - }, - { - incoming: false, - amount: 2000000, - expiry: 502, - preimage: "0202020202020202020202020202020202020202020202020202020202020202", - }, - { - incoming: false, - amount: 3000000, - expiry: 503, - preimage: "0303030303030303030303030303030303030303030303030303030303030303", - }, - { - incoming: true, - amount: 4000000, - expiry: 504, - preimage: "0404040404040404040404040404040404040404040404040404040404040404", - }, - } - - tc.htlcs = make([]channeldb.HTLC, len(htlcData)) - for i, htlc := range htlcData { + tc.htlcs = make([]channeldb.HTLC, len(testHtlcs)) + for i, htlc := range testHtlcs { preimage, decodeErr := hex.DecodeString(htlc.preimage) if decodeErr != nil { err = fmt.Errorf("Failed to decode HTLC preimage: %v", decodeErr) @@ -341,6 +303,44 @@ func (tc *testContext) extractFundingInput() (*Utxo, *wire.TxOut, error) { return &block1Utxo, txout, nil } +var testHtlcs = []struct { + incoming bool + amount lnwire.MilliSatoshi + expiry uint32 + preimage string +}{ + { + incoming: true, + amount: 1000000, + expiry: 500, + preimage: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + incoming: true, + amount: 2000000, + expiry: 501, + preimage: "0101010101010101010101010101010101010101010101010101010101010101", + }, + { + incoming: false, + amount: 2000000, + expiry: 502, + preimage: "0202020202020202020202020202020202020202020202020202020202020202", + }, + { + incoming: false, + amount: 3000000, + expiry: 503, + preimage: "0303030303030303030303030303030303030303030303030303030303030303", + }, + { + incoming: true, + amount: 4000000, + expiry: 504, + preimage: "0404040404040404040404040404040404040404040404040404040404040404", + }, +} + // testCases encode the raw test vectors specified in Appendix C of BOLT 03. var testCases = []struct { commitment channeldb.ChannelCommitment