mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 15:04:22 +00:00
add allocate in Receive calls (#9667)
This commit is contained in:
+1
-1
@@ -93,7 +93,7 @@ func (evR *Reactor) ReceiveEnvelope(e p2p.Envelope) {
|
||||
}
|
||||
|
||||
func (evR *Reactor) Receive(chID byte, peer p2p.Peer, msgBytes []byte) {
|
||||
var msg *tmproto.EvidenceList
|
||||
msg := &tmproto.EvidenceList{}
|
||||
err := proto.Unmarshal(msgBytes, msg)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/fortytw2/leaktest"
|
||||
"github.com/go-kit/log/term"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -369,6 +370,33 @@ func exampleVote(t byte) *types.Vote {
|
||||
ValidatorIndex: 56789,
|
||||
}
|
||||
}
|
||||
func TestLegacyReactorReceiveBasic(t *testing.T) {
|
||||
config := cfg.TestConfig()
|
||||
N := 1
|
||||
|
||||
stateDBs := make([]sm.Store, N)
|
||||
val := types.NewMockPV()
|
||||
stateDBs[0] = initializeValidatorState(val, 1)
|
||||
|
||||
reactors, _ := makeAndConnectReactorsAndPools(config, stateDBs)
|
||||
|
||||
var (
|
||||
reactor = reactors[0]
|
||||
peer = &p2pmocks.Peer{}
|
||||
)
|
||||
quitChan := make(<-chan struct{})
|
||||
peer.On("Quit").Return(quitChan)
|
||||
|
||||
reactor.InitPeer(peer)
|
||||
reactor.AddPeer(peer)
|
||||
e := &tmproto.EvidenceList{}
|
||||
msg, err := proto.Marshal(e)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.NotPanics(t, func() {
|
||||
reactor.Receive(evidence.EvidenceChannel, peer, msg)
|
||||
})
|
||||
}
|
||||
|
||||
//nolint:lll //ignore line length for tests
|
||||
func TestEvidenceVectors(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user