2020-12-17 16:26:32 +00:00
|
|
|
package rpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2024-02-15 05:46:47 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v5/testing/assert"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
2021-01-28 14:58:32 +00:00
|
|
|
"google.golang.org/grpc/metadata"
|
2020-12-17 16:26:32 +00:00
|
|
|
)
|
|
|
|
|
2021-01-28 14:58:32 +00:00
|
|
|
func TestGrpcHeaders(t *testing.T) {
|
|
|
|
s := &Server{
|
|
|
|
ctx: context.Background(),
|
|
|
|
clientGrpcHeaders: []string{"first=value1", "second=value2"},
|
|
|
|
}
|
|
|
|
err := s.registerBeaconClient()
|
|
|
|
require.NoError(t, err)
|
|
|
|
md, _ := metadata.FromOutgoingContext(s.ctx)
|
2021-06-02 05:44:34 +00:00
|
|
|
require.Equal(t, 2, md.Len(), "MetadataV0 contains wrong number of values")
|
2021-01-28 14:58:32 +00:00
|
|
|
assert.Equal(t, "value1", md.Get("first")[0])
|
|
|
|
assert.Equal(t, "value2", md.Get("second")[0])
|
|
|
|
}
|