@@ -1229,6 +1229,12 @@ func testGossipSyncerProcessChanRangeReply(t *testing.T, legacy bool) {
12291229 query , err := syncer .genChanRangeQuery (true )
12301230 require .NoError (t , err , "unable to generate channel range query" )
12311231
1232+ currentTimestamp := time .Now ().Unix ()
1233+ // Timestamp more than 2 weeks in the past hence expired.
1234+ expiredTimestamp := time .Unix (0 , 0 ).Unix ()
1235+ // Timestamp three weeks in the future.
1236+ skewedTimestamp := time .Now ().Add (time .Hour * 24 * 18 ).Unix ()
1237+
12321238 // When interpreting block ranges, the first reply should start from
12331239 // our requested first block, and the last should end at our requested
12341240 // last block.
@@ -1253,14 +1259,78 @@ func testGossipSyncerProcessChanRangeReply(t *testing.T, legacy bool) {
12531259 },
12541260 {
12551261 FirstBlockHeight : 12 ,
1256- NumBlocks : query .NumBlocks - 12 ,
1257- Complete : 1 ,
1262+ NumBlocks : 1 ,
12581263 ShortChanIDs : []lnwire.ShortChannelID {
12591264 {
12601265 BlockHeight : 12 ,
12611266 },
12621267 },
12631268 },
1269+ {
1270+ FirstBlockHeight : 13 ,
1271+ NumBlocks : query .NumBlocks - 13 ,
1272+ Complete : 1 ,
1273+ ShortChanIDs : []lnwire.ShortChannelID {
1274+ {
1275+ BlockHeight : 13 ,
1276+ TxIndex : 1 ,
1277+ },
1278+ {
1279+ BlockHeight : 13 ,
1280+ TxIndex : 2 ,
1281+ },
1282+ {
1283+ BlockHeight : 13 ,
1284+ TxIndex : 3 ,
1285+ },
1286+ {
1287+ BlockHeight : 13 ,
1288+ TxIndex : 4 ,
1289+ },
1290+ {
1291+ BlockHeight : 13 ,
1292+ TxIndex : 5 ,
1293+ },
1294+ {
1295+ BlockHeight : 13 ,
1296+ TxIndex : 6 ,
1297+ },
1298+ },
1299+ Timestamps : []lnwire.ChanUpdateTimestamps {
1300+ {
1301+ // Both timestamps are valid.
1302+ Timestamp1 : uint32 (currentTimestamp ),
1303+ Timestamp2 : uint32 (currentTimestamp ),
1304+ },
1305+ {
1306+ // One of the timestamps is valid.
1307+ Timestamp1 : uint32 (currentTimestamp ),
1308+ Timestamp2 : uint32 (expiredTimestamp ),
1309+ },
1310+ {
1311+ // Both timestamps are expired.
1312+ Timestamp1 : uint32 (expiredTimestamp ),
1313+ Timestamp2 : uint32 (expiredTimestamp ),
1314+ },
1315+ {
1316+ // Both timestamps are skewed.
1317+ Timestamp1 : uint32 (skewedTimestamp ),
1318+ Timestamp2 : uint32 (skewedTimestamp ),
1319+ },
1320+ {
1321+ // One timestamp is skewed the other
1322+ // expired.
1323+ Timestamp1 : uint32 (expiredTimestamp ),
1324+ Timestamp2 : uint32 (skewedTimestamp ),
1325+ },
1326+ {
1327+ // One timestamp is skewed the other
1328+ // expired.
1329+ Timestamp1 : uint32 (skewedTimestamp ),
1330+ Timestamp2 : uint32 (expiredTimestamp ),
1331+ },
1332+ },
1333+ },
12641334 }
12651335
12661336 // Each reply query is the same as the original query in the legacy
@@ -1274,6 +1344,9 @@ func testGossipSyncerProcessChanRangeReply(t *testing.T, legacy bool) {
12741344
12751345 replies [2 ].FirstBlockHeight = query .FirstBlockHeight
12761346 replies [2 ].NumBlocks = query .NumBlocks
1347+
1348+ replies [3 ].FirstBlockHeight = query .FirstBlockHeight
1349+ replies [3 ].NumBlocks = query .NumBlocks
12771350 }
12781351
12791352 // We'll begin by sending the syncer a set of non-complete channel
@@ -1284,6 +1357,9 @@ func testGossipSyncerProcessChanRangeReply(t *testing.T, legacy bool) {
12841357 if err := syncer .processChanRangeReply (replies [1 ]); err != nil {
12851358 t .Fatalf ("unable to process reply: %v" , err )
12861359 }
1360+ if err := syncer .processChanRangeReply (replies [2 ]); err != nil {
1361+ t .Fatalf ("unable to process reply: %v" , err )
1362+ }
12871363
12881364 // At this point, we should still be in our starting state as the query
12891365 // hasn't finished.
@@ -1301,6 +1377,14 @@ func testGossipSyncerProcessChanRangeReply(t *testing.T, legacy bool) {
13011377 {
13021378 BlockHeight : 12 ,
13031379 },
1380+ {
1381+ BlockHeight : 13 ,
1382+ TxIndex : 1 ,
1383+ },
1384+ {
1385+ BlockHeight : 13 ,
1386+ TxIndex : 2 ,
1387+ },
13041388 }
13051389
13061390 // As we're about to send the final response, we'll launch a goroutine
@@ -1335,7 +1419,7 @@ func testGossipSyncerProcessChanRangeReply(t *testing.T, legacy bool) {
13351419
13361420 // If we send the final message, then we should transition to
13371421 // queryNewChannels as we've sent a non-empty set of new channels.
1338- if err := syncer .processChanRangeReply (replies [2 ]); err != nil {
1422+ if err := syncer .processChanRangeReply (replies [3 ]); err != nil {
13391423 t .Fatalf ("unable to process reply: %v" , err )
13401424 }
13411425
0 commit comments