prysm-pulse/config/params/config_test.go
kasey 588dea83b7
Config registry (#10683)
* test coverage and updates to config twiddlers

* LoadChainConfigFile error if SetActive conflicts

* lint

* wip working around test issues

* more fixes, mass test updates

* lint

* linting

* thanks deepsource!

* fix undeclared vars

* fixing more undefined

* fix a bug, make a bug, repeat

* gaz

* use stock mainnet in case fork schedule matters

* remove unused KnownConfigs

* post-merge cleanup

* eliminating OverrideBeaconConfig outside tests

* more cleanup of OverrideBeaconConfig outside tests

* config for interop w/ genesis gen support

* improve var name

* API on package instead of exported value

* cleanup remainders of "registry" naming

* Nishant feedback

* add ropstein to configset

* lint

* lint #2

* ✂️

* revert accidental commented line

* check if active is nil (replace called on empty)

* Nishant feedback

* replace OverrideBeaconConfig call

* update interop instructions w/ new flag

* don't let interop replace config set via cli flags

Co-authored-by: kasey <kasey@users.noreply.github.com>
2022-05-20 07:16:53 +00:00

48 lines
1.4 KiB
Go

package params_test
import (
"testing"
"github.com/prysmaticlabs/prysm/config/params"
)
// Test cases can be executed in an arbitrary order. TestOverrideBeaconConfigTestTeardown checks
// that there's no state mutation leak from the previous test, therefore we need a sentinel flag,
// to make sure that previous test case has already been completed and check can be run.
var testOverrideBeaconConfigExecuted bool
func TestConfig_OverrideBeaconConfig(t *testing.T) {
// Ensure that param modifications are safe.
params.SetupTestConfigCleanup(t)
cfg := params.BeaconConfig()
cfg.SlotsPerEpoch = 5
params.OverrideBeaconConfig(cfg)
if c := params.BeaconConfig(); c.SlotsPerEpoch != 5 {
t.Errorf("Shardcount in BeaconConfig incorrect. Wanted %d, got %d", 5, c.SlotsPerEpoch)
}
testOverrideBeaconConfigExecuted = true
}
func TestConfig_OverrideBeaconConfigTestTeardown(t *testing.T) {
if !testOverrideBeaconConfigExecuted {
t.Skip("State leak can occur only if state mutating test has already completed")
}
cfg := params.BeaconConfig()
if cfg.SlotsPerEpoch == 5 {
t.Fatal("Parameter update has been leaked out of previous test")
}
}
func TestConfig_DataRace(t *testing.T) {
params.SetupTestConfigCleanup(t)
for i := 0; i < 10; i++ {
go func() {
cfg := params.BeaconConfig()
params.OverrideBeaconConfig(cfg)
}()
go func() uint64 {
return params.BeaconConfig().MaxDeposits
}()
}
}