@@ -23,6 +23,7 @@ import (
23
23
"github.com/lightningnetwork/lnd/lntest/channels"
24
24
"github.com/lightningnetwork/lnd/lnwire"
25
25
"github.com/lightningnetwork/lnd/shachain"
26
+ "github.com/lightningnetwork/lnd/tlv"
26
27
"github.com/stretchr/testify/require"
27
28
)
28
29
@@ -651,8 +652,7 @@ func TestChannelStateTransition(t *testing.T) {
651
652
{
652
653
LogIndex : 2 ,
653
654
UpdateMsg : & lnwire.UpdateAddHTLC {
654
- ChanID : lnwire.ChannelID {1 , 2 , 3 },
655
- ExtraData : make ([]byte , 0 ),
655
+ ChanID : lnwire.ChannelID {1 , 2 , 3 },
656
656
},
657
657
},
658
658
}
@@ -710,25 +710,22 @@ func TestChannelStateTransition(t *testing.T) {
710
710
wireSig ,
711
711
wireSig ,
712
712
},
713
- ExtraData : make ([]byte , 0 ),
714
713
},
715
714
LogUpdates : []LogUpdate {
716
715
{
717
716
LogIndex : 1 ,
718
717
UpdateMsg : & lnwire.UpdateAddHTLC {
719
- ID : 1 ,
720
- Amount : lnwire .NewMSatFromSatoshis (100 ),
721
- Expiry : 25 ,
722
- ExtraData : make ([]byte , 0 ),
718
+ ID : 1 ,
719
+ Amount : lnwire .NewMSatFromSatoshis (100 ),
720
+ Expiry : 25 ,
723
721
},
724
722
},
725
723
{
726
724
LogIndex : 2 ,
727
725
UpdateMsg : & lnwire.UpdateAddHTLC {
728
- ID : 2 ,
729
- Amount : lnwire .NewMSatFromSatoshis (200 ),
730
- Expiry : 50 ,
731
- ExtraData : make ([]byte , 0 ),
726
+ ID : 2 ,
727
+ Amount : lnwire .NewMSatFromSatoshis (200 ),
728
+ Expiry : 50 ,
732
729
},
733
730
},
734
731
},
@@ -1610,9 +1607,25 @@ func TestHTLCsExtraData(t *testing.T) {
1610
1607
OnionBlob : lnmock .MockOnion (),
1611
1608
}
1612
1609
1610
+ // Add a blinding point to a htlc.
1611
+ blindingPointHTLC := HTLC {
1612
+ Signature : testSig .Serialize (),
1613
+ Incoming : false ,
1614
+ Amt : 10 ,
1615
+ RHash : key ,
1616
+ RefundTimeout : 1 ,
1617
+ OnionBlob : lnmock .MockOnion (),
1618
+ BlindingPoint : tlv .SomeRecordT (
1619
+ tlv.NewPrimitiveRecord [lnwire.BlindingPointTlvType ](
1620
+ pubKey ,
1621
+ ),
1622
+ ),
1623
+ }
1624
+
1613
1625
testCases := []struct {
1614
- name string
1615
- htlcs []HTLC
1626
+ name string
1627
+ htlcs []HTLC
1628
+ blindingIdx int
1616
1629
}{
1617
1630
{
1618
1631
// Serialize multiple HLTCs with no extra data to
@@ -1624,30 +1637,12 @@ func TestHTLCsExtraData(t *testing.T) {
1624
1637
},
1625
1638
},
1626
1639
{
1640
+ // Some HTLCs with extra data, some without.
1627
1641
name : "mixed extra data" ,
1628
1642
htlcs : []HTLC {
1629
1643
mockHtlc ,
1630
- {
1631
- Signature : testSig .Serialize (),
1632
- Incoming : false ,
1633
- Amt : 10 ,
1634
- RHash : key ,
1635
- RefundTimeout : 1 ,
1636
- OnionBlob : lnmock .MockOnion (),
1637
- ExtraData : []byte {1 , 2 , 3 },
1638
- },
1644
+ blindingPointHTLC ,
1639
1645
mockHtlc ,
1640
- {
1641
- Signature : testSig .Serialize (),
1642
- Incoming : false ,
1643
- Amt : 10 ,
1644
- RHash : key ,
1645
- RefundTimeout : 1 ,
1646
- OnionBlob : lnmock .MockOnion (),
1647
- ExtraData : bytes .Repeat (
1648
- []byte {9 }, 999 ,
1649
- ),
1650
- },
1651
1646
},
1652
1647
},
1653
1648
}
@@ -1665,7 +1660,15 @@ func TestHTLCsExtraData(t *testing.T) {
1665
1660
r := bytes .NewReader (b .Bytes ())
1666
1661
htlcs , err := DeserializeHtlcs (r )
1667
1662
require .NoError (t , err )
1668
- require .Equal (t , testCase .htlcs , htlcs )
1663
+
1664
+ require .EqualValues (t , len (testCase .htlcs ), len (htlcs ))
1665
+ for i , htlc := range htlcs {
1666
+ // We use the extra data field when we
1667
+ // serialize, so we set to nil to be able to
1668
+ // assert on equal for the test.
1669
+ htlc .ExtraData = nil
1670
+ require .Equal (t , testCase .htlcs [i ], htlc )
1671
+ }
1669
1672
})
1670
1673
}
1671
1674
}
0 commit comments