mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
29513c804c
* bytesutil * gaz Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package p2p
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
eth2types "github.com/prysmaticlabs/eth2-types"
|
|
"github.com/prysmaticlabs/prysm/config/params"
|
|
"github.com/prysmaticlabs/prysm/encoding/bytesutil"
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
|
)
|
|
|
|
func TestMappingHasNoDuplicates(t *testing.T) {
|
|
m := make(map[reflect.Type]bool)
|
|
for _, v := range gossipTopicMappings {
|
|
if _, ok := m[reflect.TypeOf(v)]; ok {
|
|
t.Errorf("%T is duplicated in the topic mapping", v)
|
|
}
|
|
m[reflect.TypeOf(v)] = true
|
|
}
|
|
}
|
|
|
|
func TestGossipTopicMappings_CorrectBlockType(t *testing.T) {
|
|
params.SetupTestConfigCleanup(t)
|
|
bCfg := params.BeaconConfig()
|
|
forkEpoch := eth2types.Epoch(100)
|
|
bCfg.AltairForkEpoch = forkEpoch
|
|
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.AltairForkVersion)] = eth2types.Epoch(100)
|
|
params.OverrideBeaconConfig(bCfg)
|
|
|
|
// Before Fork
|
|
pMessage := GossipTopicMappings(BlockSubnetTopicFormat, 0)
|
|
_, ok := pMessage.(*ethpb.SignedBeaconBlock)
|
|
assert.Equal(t, true, ok)
|
|
|
|
// After Fork
|
|
pMessage = GossipTopicMappings(BlockSubnetTopicFormat, forkEpoch)
|
|
_, ok = pMessage.(*ethpb.SignedBeaconBlockAltair)
|
|
assert.Equal(t, true, ok)
|
|
}
|