@@ -14,22 +14,25 @@ import (
14
14
)
15
15
16
16
var (
17
- testOnionHash = [OnionPacketSize ]byte {}
18
- testAmount = MilliSatoshi (1 )
19
- testCtlvExpiry = uint32 (2 )
20
- testFlags = uint16 (2 )
21
- testType = uint64 (3 )
22
- testOffset = uint16 (24 )
23
- sig , _ = NewSigFromSignature (testSig )
24
- testChannelUpdate = ChannelUpdate1 {
17
+ testOnionHash = [OnionPacketSize ]byte {}
18
+ testAmount = MilliSatoshi (1 )
19
+ testCtlvExpiry = uint32 (2 )
20
+ testFlags = uint16 (2 )
21
+ testType = uint64 (3 )
22
+ testOffset = uint16 (24 )
23
+ sig , _ = NewSigFromSignature (testSig )
24
+ )
25
+
26
+ func makeTestChannelUpdate () * ChannelUpdate1 {
27
+ return & ChannelUpdate1 {
25
28
Signature : sig ,
26
29
ShortChannelID : NewShortChanIDFromInt (1 ),
27
30
Timestamp : 1 ,
28
31
MessageFlags : 0 ,
29
32
ChannelFlags : 1 ,
30
33
ExtraOpaqueData : make ([]byte , 0 ),
31
34
}
32
- )
35
+ }
33
36
34
37
var onionFailures = []FailureMessage {
35
38
& FailInvalidRealm {},
@@ -47,13 +50,13 @@ var onionFailures = []FailureMessage{
47
50
NewInvalidOnionVersion (testOnionHash [:]),
48
51
NewInvalidOnionHmac (testOnionHash [:]),
49
52
NewInvalidOnionKey (testOnionHash [:]),
50
- NewTemporaryChannelFailure (& testChannelUpdate ),
53
+ NewTemporaryChannelFailure (makeTestChannelUpdate () ),
51
54
NewTemporaryChannelFailure (nil ),
52
- NewAmountBelowMinimum (testAmount , testChannelUpdate ),
53
- NewFeeInsufficient (testAmount , testChannelUpdate ),
54
- NewIncorrectCltvExpiry (testCtlvExpiry , testChannelUpdate ),
55
- NewExpiryTooSoon (testChannelUpdate ),
56
- NewChannelDisabled (testFlags , testChannelUpdate ),
55
+ NewAmountBelowMinimum (testAmount , * makeTestChannelUpdate () ),
56
+ NewFeeInsufficient (testAmount , * makeTestChannelUpdate () ),
57
+ NewIncorrectCltvExpiry (testCtlvExpiry , * makeTestChannelUpdate () ),
58
+ NewExpiryTooSoon (* makeTestChannelUpdate () ),
59
+ NewChannelDisabled (testFlags , * makeTestChannelUpdate () ),
57
60
NewFinalIncorrectCltvExpiry (testCtlvExpiry ),
58
61
NewFinalIncorrectHtlcAmount (testAmount ),
59
62
NewInvalidOnionPayload (testType , testOffset ),
@@ -128,6 +131,8 @@ func testEncodeDecodeTlv(t *testing.T, testFailure FailureMessage) {
128
131
func TestChannelUpdateCompatibilityParsing (t * testing.T ) {
129
132
t .Parallel ()
130
133
134
+ testChannelUpdate := * makeTestChannelUpdate ()
135
+
131
136
// We'll start by taking out test channel update, and encoding it into
132
137
// a set of raw bytes.
133
138
var b bytes.Buffer
@@ -146,9 +151,7 @@ func TestChannelUpdateCompatibilityParsing(t *testing.T) {
146
151
147
152
// At this point, we'll ensure that we get the exact same failure out
148
153
// on the other side.
149
- if ! reflect .DeepEqual (testChannelUpdate , newChanUpdate ) {
150
- t .Fatalf ("mismatched channel updates: %v" , err )
151
- }
154
+ require .Equal (t , testChannelUpdate , newChanUpdate )
152
155
153
156
// We'll now reset then re-encoded the same channel update to try it in
154
157
// the proper compatible mode.
@@ -185,7 +188,7 @@ func TestWriteOnionErrorChanUpdate(t *testing.T) {
185
188
// First, we'll write out the raw channel update so we can obtain the
186
189
// raw serialized length.
187
190
var b bytes.Buffer
188
- update := testChannelUpdate
191
+ update := * makeTestChannelUpdate ()
189
192
trueUpdateLength , err := WriteMessage (& b , & update , 0 )
190
193
if err != nil {
191
194
t .Fatalf ("unable to write update: %v" , err )
0 commit comments