mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
028506e7ed
* add recovery for initial sync * add recovery for rpc * adding to other services * remaining services and tests * fix test * remove changes to rpc * handle powchain * handle in powchain * abstract to shared package * gazelle * lint * remove for operations * add in more for operations * travis * fix lint
35 lines
805 B
Go
35 lines
805 B
Go
package messagehandler
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
|
|
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
|
)
|
|
|
|
func TestSafelyHandleMessage(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
|
|
SafelyHandleMessage(nil, func(_ proto.Message) {
|
|
panic("bad!")
|
|
}, &pb.BeaconBlock{})
|
|
|
|
testutil.AssertLogsContain(t, hook, "Panicked when handling p2p message!")
|
|
}
|
|
|
|
func TestSafelyHandleMessage_NoData(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
|
|
SafelyHandleMessage(nil, func(_ proto.Message) {
|
|
panic("bad!")
|
|
}, nil)
|
|
|
|
entry := hook.LastEntry()
|
|
if entry.Data["msg"] != "message contains no data" {
|
|
t.Errorf("Message logged was not what was expected: %s", entry.Data["msg"])
|
|
}
|
|
}
|