lnwallet/test_utils: set up asymmetric commits

The remote and local commits are not symmetric, so we correctly set them
up pointing to the correct commitment tx.
This commit is contained in:
Johan T. Halseth 2020-11-18 22:45:35 +01:00
parent c58589db3b
commit 18f79e20d5
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -262,7 +262,7 @@ func CreateTestChannels(chanType channeldb.ChannelType) (
)
bobBalance := lnwire.NewMSatFromSatoshis(channelBal)
aliceCommit := channeldb.ChannelCommitment{
aliceLocalCommit := channeldb.ChannelCommitment{
CommitHeight: 0,
LocalBalance: aliceBalance,
RemoteBalance: bobBalance,
@ -271,7 +271,16 @@ func CreateTestChannels(chanType channeldb.ChannelType) (
CommitTx: aliceCommitTx,
CommitSig: testSigBytes,
}
bobCommit := channeldb.ChannelCommitment{
aliceRemoteCommit := channeldb.ChannelCommitment{
CommitHeight: 0,
LocalBalance: aliceBalance,
RemoteBalance: bobBalance,
CommitFee: commitFee,
FeePerKw: btcutil.Amount(feePerKw),
CommitTx: bobCommitTx,
CommitSig: testSigBytes,
}
bobLocalCommit := channeldb.ChannelCommitment{
CommitHeight: 0,
LocalBalance: bobBalance,
RemoteBalance: aliceBalance,
@ -280,6 +289,15 @@ func CreateTestChannels(chanType channeldb.ChannelType) (
CommitTx: bobCommitTx,
CommitSig: testSigBytes,
}
bobRemoteCommit := channeldb.ChannelCommitment{
CommitHeight: 0,
LocalBalance: bobBalance,
RemoteBalance: aliceBalance,
CommitFee: commitFee,
FeePerKw: btcutil.Amount(feePerKw),
CommitTx: aliceCommitTx,
CommitSig: testSigBytes,
}
var chanIDBytes [8]byte
if _, err := io.ReadFull(rand.Reader, chanIDBytes[:]); err != nil {
@ -302,8 +320,8 @@ func CreateTestChannels(chanType channeldb.ChannelType) (
RemoteCurrentRevocation: bobCommitPoint,
RevocationProducer: alicePreimageProducer,
RevocationStore: shachain.NewRevocationStore(),
LocalCommitment: aliceCommit,
RemoteCommitment: aliceCommit,
LocalCommitment: aliceLocalCommit,
RemoteCommitment: aliceRemoteCommit,
Db: dbAlice,
Packager: channeldb.NewChannelPackager(shortChanID),
FundingTxn: testTx,
@ -320,8 +338,8 @@ func CreateTestChannels(chanType channeldb.ChannelType) (
RemoteCurrentRevocation: aliceCommitPoint,
RevocationProducer: bobPreimageProducer,
RevocationStore: shachain.NewRevocationStore(),
LocalCommitment: bobCommit,
RemoteCommitment: bobCommit,
LocalCommitment: bobLocalCommit,
RemoteCommitment: bobRemoteCommit,
Db: dbBob,
Packager: channeldb.NewChannelPackager(shortChanID),
}