@@ -12,6 +12,8 @@ import (
12
12
13
13
chain_selectors "github.com/smartcontractkit/chain-selectors"
14
14
"github.com/smartcontractkit/chainlink-deployments-framework/datastore"
15
+ "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
16
+ capabilities_registry "github.com/smartcontractkit/chainlink-evm/gethwrappers/keystone/generated/capabilities_registry_1_1_0"
15
17
16
18
"github.com/smartcontractkit/chainlink/deployment/keystone/changeset"
17
19
"github.com/smartcontractkit/chainlink/deployment/keystone/changeset/internal"
@@ -53,16 +55,16 @@ func TestKeystoneView(t *testing.T) {
53
55
WriterDonConfig : test.DonConfig {N : 4 , Name : "writerDon" },
54
56
NumChains : 1 ,
55
57
})
56
- registryChain := env .Env .AllChainSelectors ()[ 0 ]
58
+ originalAddressBook := env .Env .ExistingAddresses
57
59
oracleConfig .TransmissionSchedule = []int {len (env .Env .NodeIDs )}
58
60
59
61
addrs := env .Env .DataStore .Addresses ().Filter (
60
- datastore .AddressRefByChainSelector (registryChain ),
62
+ datastore .AddressRefByChainSelector (env . RegistrySelector ),
61
63
)
62
64
63
65
var newOCR3Addr , newForwarderAddr , newWorkflowRegistryAddr , newCapabilityRegistryAddr string
64
66
for _ , addr := range addrs {
65
- if newForwarderAddr != "" && newOCR3Addr != "" {
67
+ if newForwarderAddr != "" && newOCR3Addr != "" && newWorkflowRegistryAddr != "" && newCapabilityRegistryAddr != "" {
66
68
break
67
69
}
68
70
switch addr .Type {
@@ -108,7 +110,7 @@ func TestKeystoneView(t *testing.T) {
108
110
var outView changeset.KeystoneView
109
111
require .NoError (t , json .Unmarshal (b , & outView ))
110
112
111
- chainID , err := chain_selectors .ChainIdFromSelector (registryChain )
113
+ chainID , err := chain_selectors .ChainIdFromSelector (env . RegistrySelector )
112
114
require .NoError (t , err )
113
115
chainName , err := chain_selectors .NameFromChainId (chainID )
114
116
require .NoError (t , err )
@@ -131,48 +133,54 @@ func TestKeystoneView(t *testing.T) {
131
133
t .Run ("successfully generates a view of the keystone state with multiple contracts of the same type per chain" ,
132
134
func (t * testing.T ) {
133
135
oracleConfigCopy := oracleConfig
136
+ var localAddrsBook deployment.AddressBook
134
137
135
138
// Deploy a new forwarder contract
136
- resp , err := changeset .DeployForwarderV2 (env .Env , & changeset.DeployRequestV2 {ChainSel : registryChain })
139
+ resp , err := changeset .DeployForwarderV2 (env .Env , & changeset.DeployRequestV2 {ChainSel : env . RegistrySelector })
137
140
require .NoError (t , err )
138
141
require .NotNil (t , resp )
139
142
require .NoError (t , resp .DataStore .Merge (env .Env .DataStore ))
140
143
//nolint:staticcheck // Temporarily using deprecated AddressBook until migration is complete
141
- require . NoError ( t , env . Env . ExistingAddresses . Merge ( resp .AddressBook ))
144
+ localAddrsBook = resp .AddressBook
142
145
env .Env .DataStore = resp .DataStore .Seal ()
143
146
144
147
// Deploy a new workflow registry contract
145
- resp , err = workflowregistry .DeployV2 (env .Env , & changeset.DeployRequestV2 {ChainSel : registryChain })
148
+ resp , err = workflowregistry .DeployV2 (env .Env , & changeset.DeployRequestV2 {ChainSel : env . RegistrySelector })
146
149
require .NoError (t , err )
147
150
require .NotNil (t , resp )
148
151
require .NoError (t , resp .DataStore .Merge (env .Env .DataStore ))
149
152
//nolint:staticcheck // Temporarily using deprecated AddressBook until migration is complete
150
- require .NoError (t , env . Env . ExistingAddresses .Merge (resp .AddressBook ))
153
+ require .NoError (t , localAddrsBook .Merge (resp .AddressBook ))
151
154
env .Env .DataStore = resp .DataStore .Seal ()
152
155
153
156
// Deploy a new OCR3 contract
154
- resp , err = changeset .DeployOCR3V2 (env .Env , & changeset.DeployRequestV2 {ChainSel : registryChain })
157
+ resp , err = changeset .DeployOCR3V2 (env .Env , & changeset.DeployRequestV2 {ChainSel : env . RegistrySelector })
155
158
require .NoError (t , err )
156
159
require .NotNil (t , resp )
157
160
require .NoError (t , resp .DataStore .Merge (env .Env .DataStore ))
158
161
//nolint:staticcheck // Temporarily using deprecated AddressBook until migration is complete
159
- require .NoError (t , env . Env . ExistingAddresses .Merge (resp .AddressBook ))
162
+ require .NoError (t , localAddrsBook .Merge (resp .AddressBook ))
160
163
env .Env .DataStore = resp .DataStore .Seal ()
161
164
162
165
// Deploy a new capability registry contract
163
- resp , err = changeset .DeployCapabilityRegistryV2 (env .Env , & changeset.DeployRequestV2 {ChainSel : registryChain })
166
+ resp , err = changeset .DeployCapabilityRegistryV2 (env .Env , & changeset.DeployRequestV2 {ChainSel : env . RegistrySelector })
164
167
require .NoError (t , err )
165
168
require .NotNil (t , resp )
166
169
require .NoError (t , resp .DataStore .Merge (env .Env .DataStore ))
167
170
//nolint:staticcheck // Temporarily using deprecated AddressBook until migration is complete
168
- require .NoError (t , env .Env .ExistingAddresses .Merge (resp .AddressBook ))
171
+ require .NoError (t , localAddrsBook .Merge (resp .AddressBook ))
172
+
169
173
env .Env .DataStore = resp .DataStore .Seal ()
174
+ env .Env .ExistingAddresses = localAddrsBook
170
175
171
176
var ocr3Addr , forwarderAddr , workflowRegistryAddr , capabilityRegistryAddr string
172
177
existingAddrs := env .Env .DataStore .Addresses ().Filter (
173
- datastore .AddressRefByChainSelector (registryChain ),
178
+ datastore .AddressRefByChainSelector (env . RegistrySelector ),
174
179
)
175
180
for _ , addr := range existingAddrs {
181
+ if ocr3Addr != "" && forwarderAddr != "" && workflowRegistryAddr != "" && capabilityRegistryAddr != "" {
182
+ break
183
+ }
176
184
switch addr .Type {
177
185
case datastore .ContractType (internal .OCR3Capability ):
178
186
if addr .Address != newOCR3Addr {
@@ -211,12 +219,43 @@ func TestKeystoneView(t *testing.T) {
211
219
_ , err = changeset .ConfigureOCR3Contract (env .Env , cfg )
212
220
require .NoError (t , err )
213
221
222
+ ocr3CapCfg := test .GetDefaultCapConfig (t , internal .OCR3Cap )
223
+
214
224
var wfNodes []string
215
225
for _ , id := range env .GetP2PIDs ("wfDon" ) {
216
226
wfNodes = append (wfNodes , id .String ())
217
227
}
228
+
229
+ wfDonCapabilities := internal.DonCapabilities {
230
+ Name : "wfDon" ,
231
+ Nops : []internal.NOP {
232
+ {
233
+ Name : "nop 1" ,
234
+ Nodes : wfNodes ,
235
+ },
236
+ },
237
+ Capabilities : []internal.DONCapabilityWithConfig {
238
+ {Capability : internal .OCR3Cap , Config : ocr3CapCfg },
239
+ },
240
+ }
241
+ var allDons = []internal.DonCapabilities {wfDonCapabilities }
242
+ cr , err := changeset .GetOwnedContractV2 [* capabilities_registry.CapabilitiesRegistry ](
243
+ env .Env .DataStore .Addresses (), env .Env .Chains [env .RegistrySelector ], capabilityRegistryAddr ,
244
+ )
245
+ require .NoError (t , err )
246
+
247
+ _ , err = internal .ConfigureRegistry (t .Context (), env .Env .Logger , & internal.ConfigureRegistryRequest {
248
+ ConfigureContractsRequest : internal.ConfigureContractsRequest {
249
+ RegistryChainSel : env .RegistrySelector ,
250
+ Env : & env .Env ,
251
+ Dons : allDons ,
252
+ },
253
+ CapabilitiesRegistry : cr .Contract ,
254
+ }, nil )
255
+ require .NoError (t , err )
256
+
218
257
_ , err = changeset .ConfigureForwardContracts (env .Env , changeset.ConfigureForwardContractsRequest {
219
- WFDonName : "test-wf-don " ,
258
+ WFDonName : "wfDon " ,
220
259
WFNodeIDs : wfNodes ,
221
260
RegistryChainSel : env .RegistrySelector ,
222
261
})
@@ -232,7 +271,7 @@ func TestKeystoneView(t *testing.T) {
232
271
var outView changeset.KeystoneView
233
272
require .NoError (t , json .Unmarshal (b , & outView ))
234
273
235
- chainID , err := chain_selectors .ChainIdFromSelector (registryChain )
274
+ chainID , err := chain_selectors .ChainIdFromSelector (env . RegistrySelector )
236
275
require .NoError (t , err )
237
276
chainName , err := chain_selectors .NameFromChainId (chainID )
238
277
require .NoError (t , err )
@@ -261,7 +300,7 @@ func TestKeystoneView(t *testing.T) {
261
300
262
301
t .Run ("generates a partial view of the keystone state with OCR3 not configured" , func (t * testing.T ) {
263
302
// Deploy a new OCR3 contract
264
- resp , err := changeset .DeployOCR3 (env .Env , registryChain )
303
+ resp , err := changeset .DeployOCR3 (env .Env , env . RegistrySelector )
265
304
require .NoError (t , err )
266
305
require .NotNil (t , resp )
267
306
require .NoError (t , env .Env .ExistingAddresses .Merge (resp .AddressBook ))
@@ -275,7 +314,7 @@ func TestKeystoneView(t *testing.T) {
275
314
276
315
var outView changeset.KeystoneView
277
316
require .NoError (t , json .Unmarshal (b , & outView ))
278
- chainID , err := chain_selectors .ChainIdFromSelector (registryChain )
317
+ chainID , err := chain_selectors .ChainIdFromSelector (env . RegistrySelector )
279
318
require .NoError (t , err )
280
319
chainName , err := chain_selectors .NameFromChainId (chainID )
281
320
require .NoError (t , err )
@@ -290,6 +329,7 @@ func TestKeystoneView(t *testing.T) {
290
329
})
291
330
292
331
t .Run ("fails to generate a view of the keystone state with a bad OracleConfig" , func (t * testing.T ) {
332
+ env .Env .ExistingAddresses = originalAddressBook
293
333
oracleConfigCopy := oracleConfig
294
334
oracleConfigCopy .DeltaRoundMillis = 0
295
335
oracleConfigCopy .DeltaProgressMillis = 0
0 commit comments