2019-10-04 22:46:49 +00:00
|
|
|
package params_test
|
2018-10-06 15:30:15 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2019-10-04 22:46:49 +00:00
|
|
|
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
2018-10-06 15:30:15 +00:00
|
|
|
)
|
|
|
|
|
2020-05-05 08:39:38 +00:00
|
|
|
// 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
|
|
|
|
|
2018-11-18 16:39:35 +00:00
|
|
|
func TestOverrideBeaconConfig(t *testing.T) {
|
2020-05-05 08:39:38 +00:00
|
|
|
// Ensure that param modifications are safe.
|
|
|
|
params.SetupTestConfigCleanup(t)
|
2019-10-04 22:46:49 +00:00
|
|
|
cfg := params.BeaconConfig()
|
2019-11-11 22:03:44 +00:00
|
|
|
cfg.SlotsPerEpoch = 5
|
2019-10-04 22:46:49 +00:00
|
|
|
params.OverrideBeaconConfig(cfg)
|
2019-11-11 22:03:44 +00:00
|
|
|
if c := params.BeaconConfig(); c.SlotsPerEpoch != 5 {
|
|
|
|
t.Errorf("Shardcount in BeaconConfig incorrect. Wanted %d, got %d", 5, c.SlotsPerEpoch)
|
2018-11-18 16:39:35 +00:00
|
|
|
}
|
2020-05-05 08:39:38 +00:00
|
|
|
testOverrideBeaconConfigExecuted = true
|
2018-11-18 16:39:35 +00:00
|
|
|
}
|
2020-05-02 04:03:50 +00:00
|
|
|
|
2020-05-05 08:39:38 +00:00
|
|
|
func TestOverrideBeaconConfigTestTeardown(t *testing.T) {
|
|
|
|
if !testOverrideBeaconConfigExecuted {
|
|
|
|
t.Skip("State leak can occur only if state mutating test has already completed")
|
2020-05-02 04:03:50 +00:00
|
|
|
}
|
2020-05-05 08:39:38 +00:00
|
|
|
cfg := params.BeaconConfig()
|
|
|
|
if cfg.SlotsPerEpoch == 5 {
|
|
|
|
t.Fatal("Parameter update has been leaked out of previous test")
|
2020-05-02 04:03:50 +00:00
|
|
|
}
|
|
|
|
}
|