lnwallet/channel_test: init open channels with Packager

This commit is contained in:
Conner Fromknecht 2018-02-23 19:28:18 -08:00
parent 53e4422a2e
commit 6e542d5dfa
No known key found for this signature in database
GPG Key ID: 39DE78FBE6ACB0EF
1 changed files with 16 additions and 1 deletions

View File

@ -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}