@ -609,10 +609,9 @@ func TestGossipSyncerQueryChannelRangeWrongChainHash(t *testing.T) {
t . Fatalf ( "expected lnwire.ReplyChannelRange, got %T" , msg )
}
if msg . QueryChannelRange != * query {
t . Fatalf ( "wrong query channel range in reply: " +
"expected: %v\ngot: %v" , spew . Sdump ( * query ) ,
spew . Sdump ( msg . QueryChannelRange ) )
if msg . ChainHash != query . ChainHash {
t . Fatalf ( "wrong chain hash: expected %v got %v" ,
query . ChainHash , msg . ChainHash )
}
if msg . Complete != 0 {
t . Fatalf ( "expected complete set to 0, got %v" ,
@ -1227,34 +1226,13 @@ func testGossipSyncerProcessChanRangeReply(t *testing.T, legacy bool) {
t . Fatalf ( "unable to generate channel range query: %v" , err )
}
var replyQueries [ ] * lnwire . QueryChannelRange
if legacy {
// Each reply query is the same as the original query in the
// legacy mode.
replyQueries = [ ] * lnwire . QueryChannelRange { query , query , query }
} else {
// When interpreting block ranges, the first reply should start
// from our requested first block, and the last should end at
// our requested last block.
replyQueries = [ ] * lnwire . QueryChannelRange {
{
FirstBlockHeight : 0 ,
NumBlocks : 11 ,
} ,
{
FirstBlockHeight : 11 ,
NumBlocks : 1 ,
} ,
{
FirstBlockHeight : 12 ,
NumBlocks : query . NumBlocks - 12 ,
} ,
}
}
// When interpreting block ranges, the first reply should start from
// our requested first block, and the last should end at our requested
// last block.
replies := [ ] * lnwire . ReplyChannelRange {
{
QueryChannelRange : * replyQueries [ 0 ] ,
FirstBlockHeight : 0 ,
NumBlocks : 11 ,
ShortChanIDs : [ ] lnwire . ShortChannelID {
{
BlockHeight : 10 ,
@ -1262,7 +1240,8 @@ func testGossipSyncerProcessChanRangeReply(t *testing.T, legacy bool) {
} ,
} ,
{
QueryChannelRange : * replyQueries [ 1 ] ,
FirstBlockHeight : 11 ,
NumBlocks : 1 ,
ShortChanIDs : [ ] lnwire . ShortChannelID {
{
BlockHeight : 11 ,
@ -1270,8 +1249,9 @@ func testGossipSyncerProcessChanRangeReply(t *testing.T, legacy bool) {
} ,
} ,
{
QueryChannelRange : * replyQueries [ 2 ] ,
Complete : 1 ,
FirstBlockHeight : 12 ,
NumBlocks : query . NumBlocks - 12 ,
Complete : 1 ,
ShortChanIDs : [ ] lnwire . ShortChannelID {
{
BlockHeight : 12 ,
@ -1280,6 +1260,19 @@ func testGossipSyncerProcessChanRangeReply(t *testing.T, legacy bool) {
} ,
}
// Each reply query is the same as the original query in the legacy
// mode.
if legacy {
replies [ 0 ] . FirstBlockHeight = query . FirstBlockHeight
replies [ 0 ] . NumBlocks = query . NumBlocks
replies [ 1 ] . FirstBlockHeight = query . FirstBlockHeight
replies [ 1 ] . NumBlocks = query . NumBlocks
replies [ 2 ] . FirstBlockHeight = query . FirstBlockHeight
replies [ 2 ] . NumBlocks = query . NumBlocks
}
// We'll begin by sending the syncer a set of non-complete channel
// range replies.
if err := syncer . processChanRangeReply ( replies [ 0 ] ) ; err != nil {
@ -2377,7 +2370,9 @@ func TestGossipSyncerMaxChannelRangeReplies(t *testing.T) {
// order to transition the syncer's state.
for i := uint32 ( 0 ) ; i < syncer . cfg . maxQueryChanRangeReplies ; i ++ {
reply := & lnwire . ReplyChannelRange {
QueryChannelRange : * query ,
ChainHash : query . ChainHash ,
FirstBlockHeight : query . FirstBlockHeight ,
NumBlocks : query . NumBlocks ,
ShortChanIDs : [ ] lnwire . ShortChannelID {
{
BlockHeight : query . FirstBlockHeight + i ,
@ -2408,7 +2403,9 @@ func TestGossipSyncerMaxChannelRangeReplies(t *testing.T) {
// Finally, attempting to process another reply for the same query
// should result in an error.
require . Error ( t , syncer . ProcessQueryMsg ( & lnwire . ReplyChannelRange {
QueryChannelRange : * query ,
ChainHash : query . ChainHash ,
FirstBlockHeight : query . FirstBlockHeight ,
NumBlocks : query . NumBlocks ,
ShortChanIDs : [ ] lnwire . ShortChannelID {
{
BlockHeight : query . LastBlockHeight ( ) + 1 ,