github.com/prysmaticlabs/prysm@v1.4.4/beacon-chain/rpc/prysm/v1alpha1/beacon/config_test.go (about) 1 package beacon 2 3 import ( 4 "context" 5 "fmt" 6 "reflect" 7 "testing" 8 9 "github.com/prysmaticlabs/prysm/shared/params" 10 "github.com/prysmaticlabs/prysm/shared/testutil/assert" 11 "github.com/prysmaticlabs/prysm/shared/testutil/require" 12 "google.golang.org/protobuf/types/known/emptypb" 13 ) 14 15 func TestServer_GetBeaconConfig(t *testing.T) { 16 ctx := context.Background() 17 bs := &Server{} 18 res, err := bs.GetBeaconConfig(ctx, &emptypb.Empty{}) 19 require.NoError(t, err) 20 conf := params.BeaconConfig() 21 numFields := reflect.TypeOf(conf).Elem().NumField() 22 23 // Check if the result has the same number of items as our config struct. 24 assert.Equal(t, numFields, len(res.Config), "Unexpected number of items in config") 25 want := fmt.Sprintf("%d", conf.Eth1FollowDistance) 26 27 // Check that an element is properly populated from the config. 28 assert.Equal(t, want, res.Config["Eth1FollowDistance"], "Unexpected follow distance") 29 }