mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
lnwallet: update transactions_test.go due to recent API changes
This commit is contained in:
parent
916b83a6ee
commit
20098e8cb3
@ -416,15 +416,15 @@ func TestCommitmentAndHTLCTransactions(t *testing.T) {
|
|||||||
// The commitmentPoint is technically hidden in the spec, but we need it to
|
// The commitmentPoint is technically hidden in the spec, but we need it to
|
||||||
// generate the correct tweak.
|
// generate the correct tweak.
|
||||||
tweak := SingleTweakBytes(tc.commitmentPoint, tc.localPaymentBasePoint)
|
tweak := SingleTweakBytes(tc.commitmentPoint, tc.localPaymentBasePoint)
|
||||||
keys := &commitmentKeyRing{
|
keys := &CommitmentKeyRing{
|
||||||
commitPoint: tc.commitmentPoint,
|
CommitPoint: tc.commitmentPoint,
|
||||||
localCommitKeyTweak: tweak,
|
LocalCommitKeyTweak: tweak,
|
||||||
localHtlcKeyTweak: tweak,
|
LocalHtlcKeyTweak: tweak,
|
||||||
localHtlcKey: tc.localPaymentPubKey,
|
LocalHtlcKey: tc.localPaymentPubKey,
|
||||||
remoteHtlcKey: tc.remotePaymentPubKey,
|
RemoteHtlcKey: tc.remotePaymentPubKey,
|
||||||
delayKey: tc.localDelayPubKey,
|
DelayKey: tc.localDelayPubKey,
|
||||||
noDelayKey: tc.remotePaymentPubKey,
|
NoDelayKey: tc.remotePaymentPubKey,
|
||||||
revocationKey: tc.localRevocationPubKey,
|
RevocationKey: tc.localRevocationPubKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
// testCases encode the raw test vectors specified in Appendix C of BOLT 03.
|
// testCases encode the raw test vectors specified in Appendix C of BOLT 03.
|
||||||
@ -761,6 +761,11 @@ func TestCommitmentAndHTLCTransactions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pCache := &mockPreimageCache{
|
||||||
|
// hash -> preimage
|
||||||
|
preimageMap: make(map[[32]byte][]byte),
|
||||||
|
}
|
||||||
|
|
||||||
for i, test := range testCases {
|
for i, test := range testCases {
|
||||||
expectedCommitmentTx, err := txFromHex(test.expectedCommitmentTxHex)
|
expectedCommitmentTx, err := txFromHex(test.expectedCommitmentTxHex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -798,8 +803,9 @@ func TestCommitmentAndHTLCTransactions(t *testing.T) {
|
|||||||
channelState.LocalCommitment.Htlcs = htlcs
|
channelState.LocalCommitment.Htlcs = htlcs
|
||||||
channelState.LocalCommitment.CommitTx = commitmentView.txn
|
channelState.LocalCommitment.CommitTx = commitmentView.txn
|
||||||
|
|
||||||
// This is the remote party's signature over the commitment transaction
|
// This is the remote party's signature over the commitment
|
||||||
// which is included in the commitment tx's witness data.
|
// transaction which is included in the commitment tx's witness
|
||||||
|
// data.
|
||||||
channelState.LocalCommitment.CommitSig, err = hex.DecodeString(test.remoteSigHex)
|
channelState.LocalCommitment.CommitSig, err = hex.DecodeString(test.remoteSigHex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Case %d: Failed to parse serialized signature: %v",
|
t.Fatalf("Case %d: Failed to parse serialized signature: %v",
|
||||||
@ -820,10 +826,13 @@ func TestCommitmentAndHTLCTransactions(t *testing.T) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate second-level HTLC transactions for HTLCs in commitment tx.
|
// Generate second-level HTLC transactions for HTLCs in
|
||||||
|
// commitment tx.
|
||||||
htlcResolutions, err := extractHtlcResolutions(
|
htlcResolutions, err := extractHtlcResolutions(
|
||||||
test.commitment.FeePerKw, true, signer, htlcs, keys,
|
test.commitment.FeePerKw, true, signer, htlcs, keys,
|
||||||
channel.localChanCfg, channel.remoteChanCfg, commitTx.TxHash())
|
channel.localChanCfg, channel.remoteChanCfg,
|
||||||
|
commitTx.TxHash(), pCache,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Case %d: Failed to extract HTLC resolutions: %v", i, err)
|
t.Errorf("Case %d: Failed to extract HTLC resolutions: %v", i, err)
|
||||||
continue
|
continue
|
||||||
@ -842,13 +851,14 @@ func TestCommitmentAndHTLCTransactions(t *testing.T) {
|
|||||||
t.Fatalf("Failed to parse serialized tx: %v", err)
|
t.Fatalf("Failed to parse serialized tx: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
htlcResolution := htlcResolutions[resolutionIdx]
|
htlcResolution := htlcResolutions.OutgoingHTLCs[resolutionIdx]
|
||||||
resolutionIdx++
|
resolutionIdx++
|
||||||
|
|
||||||
actualTx := htlcResolution.SignedTimeoutTx
|
actualTx := htlcResolution.SignedTimeoutTx
|
||||||
if actualTx == nil {
|
if actualTx == nil {
|
||||||
t.Errorf("Case %d: Failed to generate second level tx: "+
|
t.Errorf("Case %d: Failed to generate second level tx: "+
|
||||||
"output %d, %v", i, j, htlcResolutions[j])
|
"output %d, %v", i, j,
|
||||||
|
htlcResolutions.OutgoingHTLCs[j])
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user