@@ -3232,7 +3232,9 @@ func restartChannel(channelOld *LightningChannel) (*LightningChannel, error) {
3232
3232
// he receives Alice's CommitSig message, then Alice concludes that she needs
3233
3233
// to re-send the CommitDiff. After the diff has been sent, both nodes should
3234
3234
// resynchronize and be able to complete the dangling commit.
3235
- func testChanSyncOweCommitment (t * testing.T , chanType channeldb.ChannelType ) {
3235
+ func testChanSyncOweCommitment (t * testing.T ,
3236
+ chanType channeldb.ChannelType , noop bool ) {
3237
+
3236
3238
// Create a test channel which will be used for the duration of this
3237
3239
// unittest. The channel will be funded evenly with Alice having 5 BTC,
3238
3240
// and Bob having 5 BTC.
@@ -3242,6 +3244,17 @@ func testChanSyncOweCommitment(t *testing.T, chanType channeldb.ChannelType) {
3242
3244
var fakeOnionBlob [lnwire .OnionPacketSize ]byte
3243
3245
copy (fakeOnionBlob [:], bytes .Repeat ([]byte {0x05 }, lnwire .OnionPacketSize ))
3244
3246
3247
+ // Let's create the noop add TLV record. This will only be
3248
+ // effective for channels that have a tapscript root.
3249
+ noopRecord := tlv.NewPrimitiveRecord [NoopAddHtlcType , bool ](true )
3250
+ records , err := tlv .RecordsToMap ([]tlv.Record {noopRecord .Record ()})
3251
+ require .NoError (t , err )
3252
+
3253
+ // If the noop flag is not set for this test, nullify the records.
3254
+ if ! noop {
3255
+ records = nil
3256
+ }
3257
+
3245
3258
// We'll start off the scenario with Bob sending 3 HTLC's to Alice in a
3246
3259
// single state update.
3247
3260
htlcAmt := lnwire .NewMSatFromSatoshis (20000 )
@@ -3251,10 +3264,11 @@ func testChanSyncOweCommitment(t *testing.T, chanType channeldb.ChannelType) {
3251
3264
for i := 0 ; i < 3 ; i ++ {
3252
3265
rHash := sha256 .Sum256 (bobPreimage [:])
3253
3266
h := & lnwire.UpdateAddHTLC {
3254
- PaymentHash : rHash ,
3255
- Amount : htlcAmt ,
3256
- Expiry : uint32 (10 ),
3257
- OnionBlob : fakeOnionBlob ,
3267
+ PaymentHash : rHash ,
3268
+ Amount : htlcAmt ,
3269
+ Expiry : uint32 (10 ),
3270
+ OnionBlob : fakeOnionBlob ,
3271
+ CustomRecords : records ,
3258
3272
}
3259
3273
3260
3274
htlcIndex , err := bobChannel .AddHTLC (h , nil )
@@ -3290,15 +3304,17 @@ func testChanSyncOweCommitment(t *testing.T, chanType channeldb.ChannelType) {
3290
3304
t .Fatalf ("unable to settle htlc: %v" , err )
3291
3305
}
3292
3306
}
3307
+
3293
3308
var alicePreimage [32 ]byte
3294
3309
copy (alicePreimage [:], bytes .Repeat ([]byte {0xaa }, 32 ))
3295
3310
rHash := sha256 .Sum256 (alicePreimage [:])
3296
3311
aliceHtlc := & lnwire.UpdateAddHTLC {
3297
- ChanID : chanID ,
3298
- PaymentHash : rHash ,
3299
- Amount : htlcAmt ,
3300
- Expiry : uint32 (10 ),
3301
- OnionBlob : fakeOnionBlob ,
3312
+ ChanID : chanID ,
3313
+ PaymentHash : rHash ,
3314
+ Amount : htlcAmt ,
3315
+ Expiry : uint32 (10 ),
3316
+ OnionBlob : fakeOnionBlob ,
3317
+ CustomRecords : records ,
3302
3318
}
3303
3319
aliceHtlcIndex , err := aliceChannel .AddHTLC (aliceHtlc , nil )
3304
3320
require .NoError (t , err , "unable to add alice's htlc" )
@@ -3548,6 +3564,7 @@ func TestChanSyncOweCommitment(t *testing.T) {
3548
3564
testCases := []struct {
3549
3565
name string
3550
3566
chanType channeldb.ChannelType
3567
+ noop bool
3551
3568
}{
3552
3569
{
3553
3570
name : "tweakless" ,
@@ -3571,10 +3588,18 @@ func TestChanSyncOweCommitment(t *testing.T) {
3571
3588
channeldb .SimpleTaprootFeatureBit |
3572
3589
channeldb .TapscriptRootBit ,
3573
3590
},
3591
+ {
3592
+ name : "tapscript root with noop" ,
3593
+ chanType : channeldb .SingleFunderTweaklessBit |
3594
+ channeldb .AnchorOutputsBit |
3595
+ channeldb .SimpleTaprootFeatureBit |
3596
+ channeldb .TapscriptRootBit ,
3597
+ noop : true ,
3598
+ },
3574
3599
}
3575
3600
for _ , tc := range testCases {
3576
3601
t .Run (tc .name , func (t * testing.T ) {
3577
- testChanSyncOweCommitment (t , tc .chanType )
3602
+ testChanSyncOweCommitment (t , tc .chanType , tc . noop )
3578
3603
})
3579
3604
}
3580
3605
}
0 commit comments