mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +00:00
d17996f8b0
* Update V3 from V4 * Fix build v3 -> v4 * Update ssz * Update beacon_chain.pb.go * Fix formatter import * Update update-mockgen.sh comment to v4 * Fix conflicts. Pass build and tests * Fix test
60 lines
2.0 KiB
Go
60 lines
2.0 KiB
Go
package p2p
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/config/params"
|
|
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
|
|
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
|
)
|
|
|
|
func TestMappingHasNoDuplicates(t *testing.T) {
|
|
params.SetupTestConfigCleanup(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().Copy()
|
|
altairForkEpoch := primitives.Epoch(100)
|
|
BellatrixForkEpoch := primitives.Epoch(200)
|
|
CapellaForkEpoch := primitives.Epoch(300)
|
|
|
|
bCfg.AltairForkEpoch = altairForkEpoch
|
|
bCfg.BellatrixForkEpoch = BellatrixForkEpoch
|
|
bCfg.CapellaForkEpoch = CapellaForkEpoch
|
|
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.AltairForkVersion)] = primitives.Epoch(100)
|
|
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.BellatrixForkVersion)] = primitives.Epoch(200)
|
|
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.CapellaForkVersion)] = primitives.Epoch(300)
|
|
params.OverrideBeaconConfig(bCfg)
|
|
|
|
// Phase 0
|
|
pMessage := GossipTopicMappings(BlockSubnetTopicFormat, 0)
|
|
_, ok := pMessage.(*ethpb.SignedBeaconBlock)
|
|
assert.Equal(t, true, ok)
|
|
|
|
// Altair Fork
|
|
pMessage = GossipTopicMappings(BlockSubnetTopicFormat, altairForkEpoch)
|
|
_, ok = pMessage.(*ethpb.SignedBeaconBlockAltair)
|
|
assert.Equal(t, true, ok)
|
|
|
|
// Bellatrix Fork
|
|
pMessage = GossipTopicMappings(BlockSubnetTopicFormat, BellatrixForkEpoch)
|
|
_, ok = pMessage.(*ethpb.SignedBeaconBlockBellatrix)
|
|
assert.Equal(t, true, ok)
|
|
|
|
// Capella Fork
|
|
pMessage = GossipTopicMappings(BlockSubnetTopicFormat, CapellaForkEpoch)
|
|
_, ok = pMessage.(*ethpb.SignedBeaconBlockCapella)
|
|
assert.Equal(t, true, ok)
|
|
}
|