prysm-pulse/beacon-chain/rpc/beacon/config_test.go
Victor Farazdagi b5c4dc2a75
Refactor db teardown to testing.TB.Cleanup (#5725)
* init-sync updates
* slasher/db/kv tests
* beacon-chain/rpc/beacon tests
* update kv_test
* beacon-chain/rpc-validator tests updated
* slasher/db/kv - remove teardown method
* beacon-chain/sync tests updated
* beacon-chain/db/kv tests updated
* beacon-chain/blockchain tests updated
* beacon-chain/state/stategen tests updated
* beacon-chain/powchain updates
* updates rest of slasher tests
* validator/db tests
* rest of the tests
* minor comments update
* gazelle
* Merge refs/heads/master into teardowndb-to-cleanup
2020-05-04 01:14:34 +00:00

34 lines
896 B
Go

package beacon
import (
"context"
"fmt"
"reflect"
"testing"
ptypes "github.com/gogo/protobuf/types"
"github.com/prysmaticlabs/prysm/shared/params"
)
func TestServer_GetBeaconConfig(t *testing.T) {
ctx := context.Background()
bs := &Server{}
res, err := bs.GetBeaconConfig(ctx, &ptypes.Empty{})
if err != nil {
t.Fatal(err)
}
conf := params.BeaconConfig()
numFields := reflect.TypeOf(conf).Elem().NumField()
// Check if the result has the same number of items as our config struct.
if len(res.Config) != numFields {
t.Errorf("Expected %d items in config result, got %d", numFields, len(res.Config))
}
want := fmt.Sprintf("%d", conf.Eth1FollowDistance)
// Check that an element is properly populated from the config.
if res.Config["Eth1FollowDistance"] != want {
t.Errorf("Wanted %s for eth1 follow distance, received %s", want, res.Config["Eth1FollowDistance"])
}
}