mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
1df173e701
* backfill service * fix bug where origin state is never unlocked * support mvslice states * use renamed interface * refactor db code to skip block cache for backfill * lint * add test for verifier.verify * enable service in service init test * cancellation cleanup * adding nil checks to configset juggling * assume blocks are available by default As long as we're sure the AvailableBlocker is initialized correctly during node startup, defaulting to assuming we aren't in a checkpoint sync simplifies things greatly for tests. * block saving path refactor and bugfix * fix fillback test * fix BackfillStatus init tests --------- Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
41 lines
958 B
Go
41 lines
958 B
Go
package params
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// SetupTestConfigCleanup preserves configurations allowing to modify them within tests without any
|
|
// restrictions, everything is restored after the test.
|
|
func SetupTestConfigCleanup(t testing.TB) {
|
|
prevDefaultBeaconConfig := mainnetBeaconConfig.Copy()
|
|
temp := configs.getActive().Copy()
|
|
undo, err := SetActiveWithUndo(temp)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
prevNetworkCfg := networkConfig.Copy()
|
|
t.Cleanup(func() {
|
|
mainnetBeaconConfig = prevDefaultBeaconConfig
|
|
err = undo()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
networkConfig = prevNetworkCfg
|
|
})
|
|
}
|
|
|
|
// SetActiveTestCleanup sets an active config,
|
|
// and adds a test cleanup hook to revert to the default config after the test completes.
|
|
func SetActiveTestCleanup(t *testing.T, cfg *BeaconChainConfig) {
|
|
undo, err := SetActiveWithUndo(cfg)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Cleanup(func() {
|
|
err = undo()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
})
|
|
}
|