mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 06:54:41 +00:00
add allocate in Receive calls (#9667)
This commit is contained in:
@@ -226,7 +226,7 @@ func (r *Reactor) ReceiveEnvelope(e p2p.Envelope) {
|
||||
}
|
||||
|
||||
func (r *Reactor) Receive(chID byte, peer p2p.Peer, msgBytes []byte) {
|
||||
var msg *ssproto.Message
|
||||
msg := &ssproto.Message{}
|
||||
err := proto.Unmarshal(msgBytes, msg)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -183,3 +183,21 @@ func TestReactor_Receive_SnapshotsRequest(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLegacyReactorReceiveBasic(t *testing.T) {
|
||||
cfg := config.DefaultStateSyncConfig()
|
||||
conn := &proxymocks.AppConnSnapshot{}
|
||||
reactor := NewReactor(*cfg, conn, nil, "")
|
||||
peer := p2p.CreateRandomPeer(false)
|
||||
|
||||
reactor.InitPeer(peer)
|
||||
reactor.AddPeer(peer)
|
||||
m := &ssproto.ChunkRequest{Height: 1, Format: 1, Index: 1}
|
||||
wm := m.Wrap()
|
||||
msg, err := proto.Marshal(wm)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.NotPanics(t, func() {
|
||||
reactor.Receive(ChunkChannel, peer, msg)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user