Skip to content

Commit f6f81be

Browse files
committed
temp: demo nil pointer deref in mc migration
This commit is temporary and demonstrates a panic.
1 parent bc4229b commit f6f81be

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

channeldb/migration32/migration_test.go

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,32 @@ var (
118118
},
119119
}
120120

121+
resultOld3 = paymentResultOld{
122+
id: 3,
123+
timeFwd: time.Unix(0, 4),
124+
timeReply: time.Unix(0, 7),
125+
success: false,
126+
failure: nil,
127+
failureSourceIdx: &failureIndex,
128+
route: &Route{
129+
TotalTimeLock: 101,
130+
TotalAmount: 401,
131+
SourcePubKey: testPub2,
132+
Hops: []*Hop{
133+
{
134+
PubKeyBytes: testPub,
135+
ChannelID: 800,
136+
OutgoingTimeLock: 4,
137+
AmtToForward: 4,
138+
BlindingPoint: pubkey,
139+
EncryptedData: []byte{1, 2, 3},
140+
CustomRecords: customRecord,
141+
TotalAmtMsat: 600,
142+
},
143+
},
144+
},
145+
}
146+
121147
//nolint:ll
122148
resultNew1Hop1 = &mcHop{
123149
channelID: tlv.NewPrimitiveRecord[tlv.TlvType0, uint64](100),
@@ -217,6 +243,31 @@ var (
217243
}),
218244
}),
219245
}
246+
247+
//nolint:ll
248+
resultNew3 = paymentResultNew{
249+
id: 3,
250+
timeFwd: tlv.NewPrimitiveRecord[tlv.TlvType0, uint64](
251+
uint64(time.Unix(0, 4).UnixNano()),
252+
),
253+
timeReply: tlv.NewPrimitiveRecord[tlv.TlvType1, uint64](
254+
uint64(time.Unix(0, 7).UnixNano()),
255+
),
256+
failure: tlv.SomeRecordT(
257+
tlv.NewRecordT[tlv.TlvType3](
258+
*newPaymentFailure(
259+
&failureIndex, nil,
260+
),
261+
),
262+
),
263+
route: tlv.NewRecordT[tlv.TlvType2](mcRoute{
264+
sourcePubKey: tlv.NewRecordT[tlv.TlvType0](testPub2),
265+
totalAmount: tlv.NewRecordT[tlv.TlvType1, lnwire.MilliSatoshi](401),
266+
hops: tlv.NewRecordT[tlv.TlvType2](mcHops{
267+
resultNew2Hop1,
268+
}),
269+
}),
270+
}
220271
)
221272

222273
// TestMigrateMCRouteSerialisation tests that the MigrateMCRouteSerialisation
@@ -225,10 +276,10 @@ var (
225276
func TestMigrateMCRouteSerialisation(t *testing.T) {
226277
var (
227278
resultsOld = []*paymentResultOld{
228-
&resultOld1, &resultOld2,
279+
&resultOld1, &resultOld2, &resultOld3,
229280
}
230281
expectedResultsNew = []*paymentResultNew{
231-
&resultNew1, &resultNew2,
282+
&resultNew1, &resultNew2, &resultNew3,
232283
}
233284
)
234285

0 commit comments

Comments
 (0)