2021-06-25 11:02:11 +00:00
|
|
|
package gateway
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-03-17 18:52:56 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v4/api/gateway"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/testing/assert"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/testing/require"
|
2021-06-25 11:02:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestDefaultConfig(t *testing.T) {
|
|
|
|
t.Run("Without debug endpoints", func(t *testing.T) {
|
2021-09-24 09:25:42 +00:00
|
|
|
cfg := DefaultConfig(false, "eth,prysm")
|
2021-09-21 19:20:57 +00:00
|
|
|
assert.NotNil(t, cfg.EthPbMux.Mux)
|
|
|
|
require.Equal(t, 2, len(cfg.EthPbMux.Patterns))
|
|
|
|
assert.Equal(t, "/internal/eth/v1/", cfg.EthPbMux.Patterns[0])
|
|
|
|
assert.Equal(t, "/internal/eth/v2/", cfg.EthPbMux.Patterns[1])
|
|
|
|
assert.Equal(t, 4, len(cfg.EthPbMux.Registrations))
|
2021-10-12 15:13:52 +00:00
|
|
|
assert.NotNil(t, cfg.V1AlphaPbMux.Mux)
|
|
|
|
require.Equal(t, 2, len(cfg.V1AlphaPbMux.Patterns))
|
|
|
|
assert.Equal(t, "/eth/v1alpha1/", cfg.V1AlphaPbMux.Patterns[0])
|
|
|
|
assert.Equal(t, "/eth/v1alpha2/", cfg.V1AlphaPbMux.Patterns[1])
|
|
|
|
assert.Equal(t, 4, len(cfg.V1AlphaPbMux.Registrations))
|
2021-06-25 11:02:11 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("With debug endpoints", func(t *testing.T) {
|
2021-09-24 09:25:42 +00:00
|
|
|
cfg := DefaultConfig(true, "eth,prysm")
|
2021-09-21 19:20:57 +00:00
|
|
|
assert.NotNil(t, cfg.EthPbMux.Mux)
|
|
|
|
require.Equal(t, 2, len(cfg.EthPbMux.Patterns))
|
|
|
|
assert.Equal(t, "/internal/eth/v1/", cfg.EthPbMux.Patterns[0])
|
|
|
|
assert.Equal(t, "/internal/eth/v2/", cfg.EthPbMux.Patterns[1])
|
|
|
|
assert.Equal(t, 5, len(cfg.EthPbMux.Registrations))
|
2021-10-12 15:13:52 +00:00
|
|
|
assert.NotNil(t, cfg.V1AlphaPbMux.Mux)
|
|
|
|
require.Equal(t, 2, len(cfg.V1AlphaPbMux.Patterns))
|
|
|
|
assert.Equal(t, "/eth/v1alpha1/", cfg.V1AlphaPbMux.Patterns[0])
|
|
|
|
assert.Equal(t, "/eth/v1alpha2/", cfg.V1AlphaPbMux.Patterns[1])
|
|
|
|
assert.Equal(t, 5, len(cfg.V1AlphaPbMux.Registrations))
|
2021-06-25 11:02:11 +00:00
|
|
|
})
|
2021-09-24 09:25:42 +00:00
|
|
|
t.Run("Without Prysm API", func(t *testing.T) {
|
|
|
|
cfg := DefaultConfig(true, "eth")
|
|
|
|
assert.NotNil(t, cfg.EthPbMux.Mux)
|
|
|
|
require.Equal(t, 2, len(cfg.EthPbMux.Patterns))
|
|
|
|
assert.Equal(t, "/internal/eth/v1/", cfg.EthPbMux.Patterns[0])
|
|
|
|
assert.Equal(t, 5, len(cfg.EthPbMux.Registrations))
|
2021-10-12 15:13:52 +00:00
|
|
|
assert.Equal(t, (*gateway.PbMux)(nil), cfg.V1AlphaPbMux)
|
2021-09-24 09:25:42 +00:00
|
|
|
})
|
|
|
|
t.Run("Without Eth API", func(t *testing.T) {
|
|
|
|
cfg := DefaultConfig(true, "prysm")
|
|
|
|
assert.Equal(t, (*gateway.PbMux)(nil), cfg.EthPbMux)
|
2021-10-12 15:13:52 +00:00
|
|
|
assert.NotNil(t, cfg.V1AlphaPbMux.Mux)
|
|
|
|
require.Equal(t, 2, len(cfg.V1AlphaPbMux.Patterns))
|
|
|
|
assert.Equal(t, "/eth/v1alpha1/", cfg.V1AlphaPbMux.Patterns[0])
|
|
|
|
assert.Equal(t, "/eth/v1alpha2/", cfg.V1AlphaPbMux.Patterns[1])
|
|
|
|
assert.Equal(t, 5, len(cfg.V1AlphaPbMux.Registrations))
|
2021-09-24 09:25:42 +00:00
|
|
|
})
|
2021-06-25 11:02:11 +00:00
|
|
|
}
|