github.com/prysmaticlabs/prysm@v1.4.4/shared/featureconfig/config_test.go (about) 1 package featureconfig 2 3 import ( 4 "flag" 5 "testing" 6 7 "github.com/prysmaticlabs/prysm/shared/testutil/assert" 8 "github.com/urfave/cli/v2" 9 ) 10 11 func TestInitFeatureConfig(t *testing.T) { 12 defer Init(&Flags{}) 13 cfg := &Flags{ 14 PyrmontTestnet: true, 15 } 16 Init(cfg) 17 c := Get() 18 assert.Equal(t, true, c.PyrmontTestnet) 19 20 // Reset back to false for the follow up tests. 21 cfg = &Flags{PyrmontTestnet: false} 22 Init(cfg) 23 } 24 25 func TestInitWithReset(t *testing.T) { 26 defer Init(&Flags{}) 27 Init(&Flags{ 28 PyrmontTestnet: true, 29 }) 30 assert.Equal(t, false, Get().ToledoTestnet) 31 assert.Equal(t, true, Get().PyrmontTestnet) 32 33 // Overwrite previously set value (value that didn't come by default). 34 resetCfg := InitWithReset(&Flags{ 35 PyrmontTestnet: false, 36 }) 37 assert.Equal(t, false, Get().ToledoTestnet) 38 assert.Equal(t, false, Get().PyrmontTestnet) 39 40 // Reset must get to previously set configuration (not to default config values). 41 resetCfg() 42 assert.Equal(t, false, Get().ToledoTestnet) 43 assert.Equal(t, true, Get().PyrmontTestnet) 44 } 45 46 func TestConfigureBeaconConfig(t *testing.T) { 47 app := cli.App{} 48 set := flag.NewFlagSet("test", 0) 49 set.Bool(PyrmontTestnet.Name, true, "test") 50 context := cli.NewContext(&app, set, nil) 51 ConfigureBeaconChain(context) 52 c := Get() 53 assert.Equal(t, true, c.PyrmontTestnet) 54 }