Skip to content

Commit

Permalink
core/web/resolver: test config v2
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 committed Oct 26, 2022
1 parent cb59edb commit a52422b
Show file tree
Hide file tree
Showing 5 changed files with 1,249 additions and 0 deletions.
80 changes: 80 additions & 0 deletions core/web/resolver/config_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,94 @@
package resolver

import (
_ "embed"
"encoding/json"
"fmt"
"testing"

"github.com/stretchr/testify/require"
"go.uber.org/zap/zapcore"
"gopkg.in/guregu/null.v4"

"github.com/smartcontractkit/chainlink/core/internal/testutils/configtest"
"github.com/smartcontractkit/chainlink/core/logger"
"github.com/smartcontractkit/chainlink/core/services/chainlink"
)

var (
//go:embed testdata/config-empty-effective.toml
configEmptyEffective string
//go:embed testdata/config-full.toml
configFull string
//go:embed testdata/config-multi-chain.toml
configMulti string
//go:embed testdata/config-multi-chain-effective.toml
configMultiEffective string
)

func TestResolver_ConfigV2(t *testing.T) {
t.Parallel()

query := `
query FetchConfigV2 {
configv2 {
user
effective
}
}`

testCases := []GQLTestCase{
unauthorizedTestCase(GQLTestCase{query: query}, "configv2"),
{
name: "empty",
authenticated: true,
before: func(f *gqlTestFramework) {
var opts chainlink.GeneralConfigOpts
require.NoError(f.t, opts.ParseTOML("", ""))
cfg, err := opts.New(logger.TestLogger(f.t))
require.NoError(t, err)
f.App.On("GetConfig").Return(cfg)
},
query: query,
result: fmt.Sprintf(`{"configv2":{"user":"","effective":%s}}`, mustJSONMarshal(t, configEmptyEffective)),
},
{
name: "full",
authenticated: true,
before: func(f *gqlTestFramework) {
var opts chainlink.GeneralConfigOpts
require.NoError(f.t, opts.ParseTOML(configFull, ""))
cfg, err := opts.New(logger.TestLogger(f.t))
require.NoError(t, err)
f.App.On("GetConfig").Return(cfg)
},
query: query,
result: fmt.Sprintf(`{"configv2":{"user":%s,"effective":%s}}`, mustJSONMarshal(t, configFull), mustJSONMarshal(t, configFull)),
},
{
name: "partial",
authenticated: true,
before: func(f *gqlTestFramework) {
var opts chainlink.GeneralConfigOpts
require.NoError(f.t, opts.ParseTOML(configMulti, ""))
cfg, err := opts.New(logger.TestLogger(f.t))
require.NoError(t, err)
f.App.On("GetConfig").Return(cfg)
},
query: query,
result: fmt.Sprintf(`{"configv2":{"user":%s,"effective":%s}}`, mustJSONMarshal(t, configMulti), mustJSONMarshal(t, configMultiEffective)),
},
}

RunGQLTests(t, testCases)
}

func mustJSONMarshal(t *testing.T, s string) string {
b, err := json.Marshal(s)
require.NoError(t, err)
return string(b)
}

func TestResolver_Config(t *testing.T) {
t.Parallel()

Expand Down
191 changes: 191 additions & 0 deletions core/web/resolver/testdata/config-empty-effective.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
ExplorerURL = ''
InsecureFastScrypt = false
RootDir = '~/.chainlink'
ShutdownGracePeriod = '5s'

[Feature]
FeedsManager = false
LogPoller = false
UICSAKeys = false

[Database]
DefaultIdleInTxSessionTimeout = '1h0m0s'
DefaultLockTimeout = '15s'
DefaultQueryTimeout = '10s'
LogQueries = false
MaxIdleConns = 10
MaxOpenConns = 20
MigrateOnStartup = true

[Database.Backup]
Dir = ''
Frequency = '1h0m0s'
Mode = 'none'
OnVersionUpgrade = true

[Database.Listener]
MaxReconnectDuration = '10m0s'
MinReconnectInterval = '1m0s'
FallbackPollInterval = '30s'

[Database.Lock]
LeaseDuration = '10s'
LeaseRefreshInterval = '1s'

[TelemetryIngress]
UniConn = true
Logging = false
ServerPubKey = ''
URL = ''
BufferSize = 100
MaxBatchSize = 50
SendInterval = '500ms'
SendTimeout = '10s'
UseBatchSend = true

[AuditLogger]
Enabled = false
ForwardToUrl = ''
JsonWrapperKey = ''
Headers = []

[Log]
Level = 'info'
JSONConsole = false
UnixTS = false

[Log.File]
Dir = ''
MaxSize = '5.12gb'
MaxAgeDays = 0
MaxBackups = 1

[WebServer]
AllowOrigins = 'http://localhost:3000,http://localhost:6688'
BridgeResponseURL = ''
HTTPWriteTimeout = '10s'
HTTPPort = 6688
SecureCookies = true
SessionTimeout = '15m0s'
SessionReaperExpiration = '240h0m0s'

[WebServer.MFA]
RPID = ''
RPOrigin = ''

[WebServer.RateLimit]
Authenticated = 1000
AuthenticatedPeriod = '1m0s'
Unauthenticated = 5
UnauthenticatedPeriod = '20s'

[WebServer.TLS]
CertPath = ''
ForceRedirect = false
Host = ''
HTTPSPort = 6689
KeyPath = ''

[JobPipeline]
ExternalInitiatorsEnabled = false
MaxRunDuration = '10m0s'
ReaperInterval = '1h0m0s'
ReaperThreshold = '24h0m0s'
ResultWriteQueueDepth = 100

[JobPipeline.HTTPRequest]
DefaultTimeout = '15s'
MaxSize = '32.77kb'

[FluxMonitor]
DefaultTransactionQueueDepth = 1
SimulateTransactions = false

[OCR2]
Enabled = false
ContractConfirmations = 3
BlockchainTimeout = '20s'
ContractPollInterval = '1m0s'
ContractSubscribeInterval = '2m0s'
ContractTransmitterTransmitTimeout = '10s'
DatabaseTimeout = '10s'
KeyBundleID = '0000000000000000000000000000000000000000000000000000000000000000'

[OCR]
Enabled = false
ObservationTimeout = '5s'
BlockchainTimeout = '20s'
ContractPollInterval = '1m0s'
ContractSubscribeInterval = '2m0s'
DefaultTransactionQueueDepth = 1
KeyBundleID = '0000000000000000000000000000000000000000000000000000000000000000'
SimulateTransactions = false
TransmitterAddress = ''

[P2P]
IncomingMessageBufferSize = 10
OutgoingMessageBufferSize = 10
PeerID = ''
TraceLogging = false

[P2P.V1]
Enabled = true
AnnounceIP = ''
AnnouncePort = 0
BootstrapCheckInterval = '20s'
DefaultBootstrapPeers = []
DHTAnnouncementCounterUserPrefix = 0
DHTLookupInterval = 10
ListenIP = '0.0.0.0'
ListenPort = 0
NewStreamTimeout = '10s'
PeerstoreWriteInterval = '5m0s'

[P2P.V2]
Enabled = false
AnnounceAddresses = []
DefaultBootstrappers = []
DeltaDial = '15s'
DeltaReconcile = '1m0s'
ListenAddresses = []

[Keeper]
DefaultTransactionQueueDepth = 1
GasPriceBufferPercent = 20
GasTipCapBufferPercent = 20
BaseFeeBufferPercent = 20
MaxGracePeriod = 100
TurnLookBack = 1000
TurnFlagEnabled = false
UpkeepCheckGasPriceEnabled = false

[Keeper.Registry]
CheckGasOverhead = 200000
PerformGasOverhead = 300000
MaxPerformDataSize = 5000
SyncInterval = '30m0s'
SyncUpkeepQueueSize = 10

[AutoPprof]
Enabled = false
ProfileRoot = ''
PollInterval = '10s'
GatherDuration = '10s'
GatherTraceDuration = '5s'
MaxProfileSize = '100.00mb'
CPUProfileRate = 1
MemProfileRate = 1
BlockProfileRate = 1
MutexProfileFraction = 1
MemThreshold = '4.00gb'
GoroutineThreshold = 5000

[Pyroscope]
ServerAddress = ''
Environment = 'mainnet'

[Sentry]
Debug = false
DSN = ''
Environment = ''
Release = ''
Loading

0 comments on commit a52422b

Please sign in to comment.