|
@ -731,11 +731,15 @@ func handleLightBlockRequests( |
|
|
if requests%10 >= failureRate { |
|
|
if requests%10 >= failureRate { |
|
|
lb, err := chain[int64(msg.Height)].ToProto() |
|
|
lb, err := chain[int64(msg.Height)].ToProto() |
|
|
require.NoError(t, err) |
|
|
require.NoError(t, err) |
|
|
sending <- p2p.Envelope{ |
|
|
|
|
|
|
|
|
select { |
|
|
|
|
|
case sending <- p2p.Envelope{ |
|
|
From: envelope.To, |
|
|
From: envelope.To, |
|
|
Message: &ssproto.LightBlockResponse{ |
|
|
Message: &ssproto.LightBlockResponse{ |
|
|
LightBlock: lb, |
|
|
LightBlock: lb, |
|
|
}, |
|
|
}, |
|
|
|
|
|
}: |
|
|
|
|
|
case <-ctx.Done(): |
|
|
|
|
|
return |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
switch errorCount % 3 { |
|
|
switch errorCount % 3 { |
|
@ -744,18 +748,26 @@ func handleLightBlockRequests( |
|
|
_, _, lb := mockLB(ctx, t, int64(msg.Height), factory.DefaultTestTime, factory.MakeBlockID(), vals, pv) |
|
|
_, _, lb := mockLB(ctx, t, int64(msg.Height), factory.DefaultTestTime, factory.MakeBlockID(), vals, pv) |
|
|
differntLB, err := lb.ToProto() |
|
|
differntLB, err := lb.ToProto() |
|
|
require.NoError(t, err) |
|
|
require.NoError(t, err) |
|
|
sending <- p2p.Envelope{ |
|
|
|
|
|
|
|
|
select { |
|
|
|
|
|
case sending <- p2p.Envelope{ |
|
|
From: envelope.To, |
|
|
From: envelope.To, |
|
|
Message: &ssproto.LightBlockResponse{ |
|
|
Message: &ssproto.LightBlockResponse{ |
|
|
LightBlock: differntLB, |
|
|
LightBlock: differntLB, |
|
|
}, |
|
|
}, |
|
|
|
|
|
}: |
|
|
|
|
|
case <-ctx.Done(): |
|
|
|
|
|
return |
|
|
} |
|
|
} |
|
|
case 1: // send nil block i.e. pretend we don't have it
|
|
|
case 1: // send nil block i.e. pretend we don't have it
|
|
|
sending <- p2p.Envelope{ |
|
|
|
|
|
|
|
|
select { |
|
|
|
|
|
case sending <- p2p.Envelope{ |
|
|
From: envelope.To, |
|
|
From: envelope.To, |
|
|
Message: &ssproto.LightBlockResponse{ |
|
|
Message: &ssproto.LightBlockResponse{ |
|
|
LightBlock: nil, |
|
|
LightBlock: nil, |
|
|
}, |
|
|
}, |
|
|
|
|
|
}: |
|
|
|
|
|
case <-ctx.Done(): |
|
|
|
|
|
return |
|
|
} |
|
|
} |
|
|
case 2: // don't do anything
|
|
|
case 2: // don't do anything
|
|
|
} |
|
|
} |
|
@ -783,19 +795,23 @@ func handleConsensusParamsRequest( |
|
|
case <-ctx.Done(): |
|
|
case <-ctx.Done(): |
|
|
return |
|
|
return |
|
|
case envelope := <-receiving: |
|
|
case envelope := <-receiving: |
|
|
if ctx.Err() != nil { |
|
|
|
|
|
|
|
|
msg, ok := envelope.Message.(*ssproto.ParamsRequest) |
|
|
|
|
|
if !ok { |
|
|
|
|
|
t.Errorf("message was %T which is not a params request", envelope.Message) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
t.Log("received consensus params request") |
|
|
|
|
|
msg, ok := envelope.Message.(*ssproto.ParamsRequest) |
|
|
|
|
|
require.True(t, ok) |
|
|
|
|
|
sending <- p2p.Envelope{ |
|
|
|
|
|
|
|
|
select { |
|
|
|
|
|
case sending <- p2p.Envelope{ |
|
|
From: envelope.To, |
|
|
From: envelope.To, |
|
|
Message: &ssproto.ParamsResponse{ |
|
|
Message: &ssproto.ParamsResponse{ |
|
|
Height: msg.Height, |
|
|
Height: msg.Height, |
|
|
ConsensusParams: paramsProto, |
|
|
ConsensusParams: paramsProto, |
|
|
}, |
|
|
}, |
|
|
|
|
|
}: |
|
|
|
|
|
case <-ctx.Done(): |
|
|
|
|
|
return |
|
|
|
|
|
case <-closeCh: |
|
|
|
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
case <-closeCh: |
|
|
case <-closeCh: |
|
|