mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
4d02329cd5
* add in initial changes * add test method * raul's review * Update beacon-chain/p2p/gossip_scoring_params.go Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * Update beacon-chain/p2p/gossip_scoring_params.go Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> * preston's review * kasey's review * only 1 Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package p2p
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
eth2types "github.com/prysmaticlabs/eth2-types"
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
|
"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)
|
|
}
|