lnwallet/channel_test: init open channels with Packager
This commit is contained in:
parent
53e4422a2e
commit
6e542d5dfa
@ -2,9 +2,11 @@ package lnwallet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"crypto/rand"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
"encoding/binary"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -280,11 +282,21 @@ func createTestChannels(revocationWindow int) (*LightningChannel,
|
|||||||
CommitSig: bytes.Repeat([]byte{1}, 71),
|
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{
|
aliceChannelState := &channeldb.OpenChannel{
|
||||||
LocalChanCfg: aliceCfg,
|
LocalChanCfg: aliceCfg,
|
||||||
RemoteChanCfg: bobCfg,
|
RemoteChanCfg: bobCfg,
|
||||||
IdentityPub: aliceKeys[0].PubKey(),
|
IdentityPub: aliceKeys[0].PubKey(),
|
||||||
FundingOutpoint: *prevOut,
|
FundingOutpoint: *prevOut,
|
||||||
|
ShortChanID: shortChanID,
|
||||||
ChanType: channeldb.SingleFunder,
|
ChanType: channeldb.SingleFunder,
|
||||||
IsInitiator: true,
|
IsInitiator: true,
|
||||||
Capacity: channelCapacity,
|
Capacity: channelCapacity,
|
||||||
@ -294,12 +306,14 @@ func createTestChannels(revocationWindow int) (*LightningChannel,
|
|||||||
LocalCommitment: aliceCommit,
|
LocalCommitment: aliceCommit,
|
||||||
RemoteCommitment: aliceCommit,
|
RemoteCommitment: aliceCommit,
|
||||||
Db: dbAlice,
|
Db: dbAlice,
|
||||||
|
Packager: channeldb.NewChannelPackager(shortChanID),
|
||||||
}
|
}
|
||||||
bobChannelState := &channeldb.OpenChannel{
|
bobChannelState := &channeldb.OpenChannel{
|
||||||
LocalChanCfg: bobCfg,
|
LocalChanCfg: bobCfg,
|
||||||
RemoteChanCfg: aliceCfg,
|
RemoteChanCfg: aliceCfg,
|
||||||
IdentityPub: bobKeys[0].PubKey(),
|
IdentityPub: bobKeys[0].PubKey(),
|
||||||
FundingOutpoint: *prevOut,
|
FundingOutpoint: *prevOut,
|
||||||
|
ShortChanID: shortChanID,
|
||||||
ChanType: channeldb.SingleFunder,
|
ChanType: channeldb.SingleFunder,
|
||||||
IsInitiator: false,
|
IsInitiator: false,
|
||||||
Capacity: channelCapacity,
|
Capacity: channelCapacity,
|
||||||
@ -309,6 +323,7 @@ func createTestChannels(revocationWindow int) (*LightningChannel,
|
|||||||
LocalCommitment: bobCommit,
|
LocalCommitment: bobCommit,
|
||||||
RemoteCommitment: bobCommit,
|
RemoteCommitment: bobCommit,
|
||||||
Db: dbBob,
|
Db: dbBob,
|
||||||
|
Packager: channeldb.NewChannelPackager(shortChanID),
|
||||||
}
|
}
|
||||||
|
|
||||||
aliceSigner := &mockSigner{privkeys: aliceKeys}
|
aliceSigner := &mockSigner{privkeys: aliceKeys}
|
||||||
|
Loading…
Reference in New Issue
Block a user