From 6e542d5dfa6ed77c252918ac594d1289937d3313 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Fri, 23 Feb 2018 19:28:18 -0800 Subject: [PATCH] lnwallet/channel_test: init open channels with Packager --- lnwallet/channel_test.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lnwallet/channel_test.go b/lnwallet/channel_test.go index 29895f6f..d67d0981 100644 --- a/lnwallet/channel_test.go +++ b/lnwallet/channel_test.go @@ -2,9 +2,11 @@ package lnwallet import ( "bytes" + "crypto/rand" "crypto/sha256" + "encoding/binary" + "io" "io/ioutil" - "os" "reflect" "runtime" @@ -280,11 +282,21 @@ func createTestChannels(revocationWindow int) (*LightningChannel, CommitSig: bytes.Repeat([]byte{1}, 71), } + var chanIDBytes [8]byte + if _, err := io.ReadFull(rand.Reader, chanIDBytes[:]); err != nil { + return nil, nil, nil, err + } + + shortChanID := lnwire.NewShortChanIDFromInt( + binary.BigEndian.Uint64(chanIDBytes[:]), + ) + aliceChannelState := &channeldb.OpenChannel{ LocalChanCfg: aliceCfg, RemoteChanCfg: bobCfg, IdentityPub: aliceKeys[0].PubKey(), FundingOutpoint: *prevOut, + ShortChanID: shortChanID, ChanType: channeldb.SingleFunder, IsInitiator: true, Capacity: channelCapacity, @@ -294,12 +306,14 @@ func createTestChannels(revocationWindow int) (*LightningChannel, LocalCommitment: aliceCommit, RemoteCommitment: aliceCommit, Db: dbAlice, + Packager: channeldb.NewChannelPackager(shortChanID), } bobChannelState := &channeldb.OpenChannel{ LocalChanCfg: bobCfg, RemoteChanCfg: aliceCfg, IdentityPub: bobKeys[0].PubKey(), FundingOutpoint: *prevOut, + ShortChanID: shortChanID, ChanType: channeldb.SingleFunder, IsInitiator: false, Capacity: channelCapacity, @@ -309,6 +323,7 @@ func createTestChannels(revocationWindow int) (*LightningChannel, LocalCommitment: bobCommit, RemoteCommitment: bobCommit, Db: dbBob, + Packager: channeldb.NewChannelPackager(shortChanID), } aliceSigner := &mockSigner{privkeys: aliceKeys}