Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
agparadiso committed Feb 10, 2025
1 parent 5dd51d6 commit 2b8f98c
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/workflows"
"github.com/smartcontractkit/chainlink/v2/core/services/workflows/ratelimiter"
"github.com/smartcontractkit/chainlink/v2/core/services/workflows/syncer"
"github.com/smartcontractkit/chainlink/v2/core/services/workflows/syncerlimiter"
"github.com/smartcontractkit/chainlink/v2/core/utils/crypto"

"github.com/stretchr/testify/require"
Expand All @@ -47,6 +48,11 @@ var rlConfig = ratelimiter.Config{
PerSenderBurst: 30,
}

var wlConfig = syncerlimiter.Config{
Global: 50,
PerOwner: 10,
}

type testEvtHandler struct {
events []syncer.Event
mux sync.Mutex
Expand Down Expand Up @@ -354,9 +360,13 @@ func Test_SecretsWorker(t *testing.T) {

rl, err := ratelimiter.NewRateLimiter(rlConfig)
require.NoError(t, err)

wl, err := syncerlimiter.NewWorkflowLimits(wlConfig)
require.NoError(t, err)

handler := &testSecretsWorkEventHandler{
wrappedHandler: syncer.NewEventHandler(lggr, orm, fetcherFn, nil, nil,
emitter, clockwork.NewFakeClock(), workflowkey.Key{}, rl),
emitter, clockwork.NewFakeClock(), workflowkey.Key{}, rl, wl),
registeredCh: make(chan syncer.Event, 1),
}

Expand Down Expand Up @@ -438,8 +448,12 @@ func Test_RegistrySyncer_WorkflowRegistered_InitiallyPaused(t *testing.T) {
er := syncer.NewEngineRegistry()
rl, err := ratelimiter.NewRateLimiter(rlConfig)
require.NoError(t, err)

wl, err := syncerlimiter.NewWorkflowLimits(wlConfig)
require.NoError(t, err)

handler := syncer.NewEventHandler(lggr, orm, fetcherFn, nil, nil,
emitter, clockwork.NewFakeClock(), workflowkey.Key{}, rl, syncer.WithEngineRegistry(er))
emitter, clockwork.NewFakeClock(), workflowkey.Key{}, rl, wl, syncer.WithEngineRegistry(er))

worker := syncer.NewWorkflowRegistry(
lggr,
Expand Down Expand Up @@ -538,6 +552,8 @@ func Test_RegistrySyncer_WorkflowRegistered_InitiallyActivated(t *testing.T) {
er := syncer.NewEngineRegistry()
rl, err := ratelimiter.NewRateLimiter(rlConfig)
require.NoError(t, err)
wl, err := syncerlimiter.NewWorkflowLimits(wlConfig)
require.NoError(t, err)
handler := syncer.NewEventHandler(
lggr,
orm,
Expand All @@ -548,6 +564,7 @@ func Test_RegistrySyncer_WorkflowRegistered_InitiallyActivated(t *testing.T) {
clockwork.NewFakeClock(),
workflowkey.Key{},
rl,
wl,
syncer.WithEngineRegistry(er),
syncer.WithEngineFactoryFn(mf.new),
)
Expand Down
3 changes: 2 additions & 1 deletion core/services/workflows/syncerlimiter/limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package syncerlimiter_test
import (
"testing"

"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink/v2/core/services/workflows/syncerlimiter"
"github.com/test-go/testify/require"
)

func TestWorkflowLimits(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions core/web/resolver/testdata/config-empty-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
4 changes: 4 additions & 0 deletions core/web/resolver/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

[Capabilities.GatewayConnector]
ChainIDForNodeKey = '11155111'
NodeAddress = '0x68902d681c28119f9b2531473a417088bf008e59'
Expand Down
4 changes: 4 additions & 0 deletions core/web/resolver/testdata/config-multi-chain-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ require (
github.com/supranational/blst v0.3.13 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/test-go/testify v1.1.4
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/config/merge_raw_configs.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ ChainID = '1'
MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

Expand Down
4 changes: 4 additions & 0 deletions testdata/scripts/node/validate/default.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
4 changes: 4 additions & 0 deletions testdata/scripts/node/validate/defaults-override.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
4 changes: 4 additions & 0 deletions testdata/scripts/node/validate/disk-based-logging.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
4 changes: 4 additions & 0 deletions testdata/scripts/node/validate/fallback-override.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
4 changes: 4 additions & 0 deletions testdata/scripts/node/validate/invalid-ocr-p2p.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
4 changes: 4 additions & 0 deletions testdata/scripts/node/validate/invalid.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
4 changes: 4 additions & 0 deletions testdata/scripts/node/validate/valid.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down
4 changes: 4 additions & 0 deletions testdata/scripts/node/validate/warnings.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ MaxBinarySize = '20.00mb'
MaxEncryptedSecretsSize = '26.40kb'
MaxConfigSize = '50.00kb'

[Capabilities.WorkflowRegistry.Limits]
WorkflowsGlobalLimit = 50
WorkflowsPerOwnerLimit = 5

[Capabilities.GatewayConnector]
ChainIDForNodeKey = ''
NodeAddress = ''
Expand Down

0 comments on commit 2b8f98c

Please sign in to comment.