2020-02-04 05:28:35 +00:00
|
|
|
package beacon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
2020-07-20 02:15:51 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
2021-05-17 18:32:04 +00:00
|
|
|
"google.golang.org/protobuf/types/known/emptypb"
|
2020-02-04 05:28:35 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestServer_GetBeaconConfig(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
|
|
|
bs := &Server{}
|
2021-05-17 18:32:04 +00:00
|
|
|
res, err := bs.GetBeaconConfig(ctx, &emptypb.Empty{})
|
2020-07-20 02:15:51 +00:00
|
|
|
require.NoError(t, err)
|
2020-02-04 05:28:35 +00:00
|
|
|
conf := params.BeaconConfig()
|
|
|
|
numFields := reflect.TypeOf(conf).Elem().NumField()
|
|
|
|
|
|
|
|
// Check if the result has the same number of items as our config struct.
|
2020-07-20 02:15:51 +00:00
|
|
|
assert.Equal(t, numFields, len(res.Config), "Unexpected number of items in config")
|
2020-02-04 05:28:35 +00:00
|
|
|
want := fmt.Sprintf("%d", conf.Eth1FollowDistance)
|
|
|
|
|
|
|
|
// Check that an element is properly populated from the config.
|
2020-07-20 02:15:51 +00:00
|
|
|
assert.Equal(t, want, res.Config["Eth1FollowDistance"], "Unexpected follow distance")
|
2020-02-04 05:28:35 +00:00
|
|
|
}
|