@@ -7,9 +7,14 @@ import (
77 "log"
88 "os"
99 "testing"
10+ "time"
1011
1112 "github.com/pelletier/go-toml/v2"
13+ "github.com/stretchr/testify/assert"
1214 "github.com/stretchr/testify/require"
15+ "golang.org/x/time/rate"
16+
17+ "github.com/smartcontractkit/chainlink-common/pkg/config"
1318)
1419
1520var update = flag .Bool ("update" , false , "update the golden files of this test" )
@@ -52,3 +57,54 @@ func TestDefault(t *testing.T) {
5257 }
5358 })
5459}
60+
61+ func TestSchema_Unmarshal (t * testing.T ) {
62+ cfg := Default
63+ require .NoError (t , json .Unmarshal ([]byte (`{
64+ "WorkflowLimit": "500",
65+ "HTTPTrigger": {
66+ "AuthRateLimit": "200rps:50"
67+ },
68+ "PerOrg": {
69+ "ZeroBalancePruningTimeout": "48h"
70+ },
71+ "PerOwner": {
72+ "WorkflowExecutionConcurrencyLimit": "99"
73+ },
74+ "PerWorkflow": {
75+ "WASMMemoryLimit": "250mb",
76+ "CRONTrigger": {
77+ "RateLimit": "every10s:5"
78+ },
79+ "HTTPTrigger": {
80+ "IncomingPayloadSizeLimit": "14kb"
81+ },
82+ "LogTrigger": {
83+ "EventRateLimit": "every13s:6"
84+ },
85+ "HTTPAction": {
86+ "RateLimit": "every3s:5"
87+ },
88+ "ChainWrite": {
89+ "EVM": {
90+ "TransactionGasLimit": "500000"
91+ }
92+ },
93+ "ChainRead": {
94+ "CallLimit": "3"
95+ }
96+ }
97+ }` ), & cfg ))
98+
99+ assert .Equal (t , 500 , cfg .WorkflowLimit .DefaultValue )
100+ assert .Equal (t , config.Rate {Limit : 200 , Burst : 50 }, cfg .HTTPTrigger .AuthRateLimit .DefaultValue )
101+ assert .Equal (t , 48 * time .Hour , cfg .PerOrg .ZeroBalancePruningTimeout .DefaultValue )
102+ assert .Equal (t , 99 , cfg .PerOwner .WorkflowExecutionConcurrencyLimit .DefaultValue )
103+ assert .Equal (t , 250 * config .MByte , cfg .PerWorkflow .WASMMemoryLimit .DefaultValue )
104+ assert .Equal (t , config.Rate {Limit : rate .Every (10 * time .Second ), Burst : 5 }, cfg .PerWorkflow .CRONTrigger .RateLimit .DefaultValue )
105+ assert .Equal (t , 14 * config .KByte , cfg .PerWorkflow .HTTPTrigger .IncomingPayloadSizeLimit .DefaultValue )
106+ assert .Equal (t , config.Rate {Limit : rate .Every (13 * time .Second ), Burst : 6 }, cfg .PerWorkflow .LogTrigger .EventRateLimit .DefaultValue )
107+ assert .Equal (t , config.Rate {Limit : rate .Every (3 * time .Second ), Burst : 5 }, cfg .PerWorkflow .HTTPAction .RateLimit .DefaultValue )
108+ assert .Equal (t , 500000 , cfg .PerWorkflow .ChainWrite .EVM .TransactionGasLimit .DefaultValue )
109+ assert .Equal (t , 3 , cfg .PerWorkflow .ChainRead .CallLimit .DefaultValue )
110+ }
0 commit comments