Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests in //beacon-chain/rpc/beacon #5559

Merged
merged 7 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions beacon-chain/rpc/beacon/attestations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,8 @@ func TestServer_ListIndexedAttestations_NewStateManagnmentDisabled(t *testing.T)
func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) {
params.OverrideBeaconConfig(params.MainnetConfig())
defer params.OverrideBeaconConfig(params.MinimalSpecConfig())
cfg := assertNewStateMgmtIsEnabled()
defer featureconfig.Init(cfg)
db := dbTest.SetupDB(t)
defer dbTest.TeardownDB(t, db)
helpers.ClearCache()
Expand Down Expand Up @@ -745,6 +747,8 @@ func TestServer_ListIndexedAttestations_GenesisEpoch(t *testing.T) {
func TestServer_ListIndexedAttestations_OldEpoch(t *testing.T) {
params.OverrideBeaconConfig(params.MainnetConfig())
defer params.OverrideBeaconConfig(params.MinimalSpecConfig())
cfg := assertNewStateMgmtIsEnabled()
defer featureconfig.Init(cfg)
db := dbTest.SetupDB(t)
defer dbTest.TeardownDB(t, db)
helpers.ClearCache()
Expand Down Expand Up @@ -1226,3 +1230,14 @@ func TestServer_StreamAttestations_OnSlotTick(t *testing.T) {
}
<-exitRoutine
}

// assertNewStateMgmtIsEnabled asserts that state management feature is enabled.
func assertNewStateMgmtIsEnabled() *featureconfig.Flags {
cfg := featureconfig.Get()
if cfg.DisableNewStateMgmt {
cfgUpd := cfg.Copy()
cfgUpd.DisableNewStateMgmt = false
featureconfig.Init(cfgUpd)
}
return cfg
}
39 changes: 39 additions & 0 deletions shared/featureconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,45 @@ func Init(c *Flags) {
featureConfig = c
}

// Copy returns copy of the config object.
func (c *Flags) Copy() *Flags {
return &Flags{
MinimalConfig: c.MinimalConfig,
WriteSSZStateTransitions: c.WriteSSZStateTransitions,
InitSyncNoVerify: c.InitSyncNoVerify,
DisableDynamicCommitteeSubnets: c.DisableNewStateMgmt,
SkipBLSVerify: c.SkipBLSVerify,
EnableBackupWebhook: c.EnableStateRefCopy,
PruneEpochBoundaryStates: c.PruneEpochBoundaryStates,
EnableSnappyDBCompression: c.EnableSnappyDBCompression,
ProtectProposer: c.ProtectProposer,
ProtectAttester: c.ProtectAttester,
DisableStrictAttestationPubsubVerification: c.DisableStrictAttestationPubsubVerification,
DisableUpdateHeadPerAttestation: c.DisableUpdateHeadPerAttestation,
EnableByteMempool: c.EnableByteMempool,
EnableDomainDataCache: c.EnableDomainDataCache,
EnableStateGenSigVerify: c.EnableStateGenSigVerify,
CheckHeadState: c.CheckHeadState,
EnableNoise: c.EnableNoise,
DontPruneStateStartUp: c.DontPruneStateStartUp,
DisableNewStateMgmt: c.DisableNewStateMgmt,
DisableInitSyncQueue: c.DisableInitSyncQueue,
EnableFieldTrie: c.EnableFieldTrie,
EnableBlockHTR: c.EnableBlockHTR,
NoInitSyncBatchSaveBlocks: c.NoInitSyncBatchSaveBlocks,
EnableStateRefCopy: c.EnableStateRefCopy,
WaitForSynced: c.WaitForSynced,
DisableForkChoice: c.DisableForkChoice,
BroadcastSlashings: c.BroadcastSlashings,
EnableSSZCache: c.EnableSSZCache,
EnableEth1DataVoteCache: c.EnableEth1DataVoteCache,
EnableSlasherConnection: c.EnableSlasherConnection,
EnableBlockTreeCache: c.EnableBlockTreeCache,
KafkaBootstrapServers: c.KafkaBootstrapServers,
CustomGenesisDelay: c.CustomGenesisDelay,
}
}

// ConfigureBeaconChain sets the global config based
// on what flags are enabled for the beacon-chain client.
func ConfigureBeaconChain(ctx *cli.Context) {
Expand Down