-
Notifications
You must be signed in to change notification settings - Fork 23
/
harness.go
514 lines (439 loc) · 25.3 KB
/
harness.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
package testutil
import (
"context"
"fmt"
"github.com/synapsecns/sanguine/agents/contracts/test/attestationharness"
"github.com/synapsecns/sanguine/agents/contracts/test/basemessageharness"
"github.com/synapsecns/sanguine/agents/contracts/test/bondingmanagerharness"
gasdataharness "github.com/synapsecns/sanguine/agents/contracts/test/gasdata"
"github.com/synapsecns/sanguine/agents/contracts/test/lightmanagerharness"
"github.com/synapsecns/sanguine/agents/contracts/test/originharness"
"github.com/synapsecns/sanguine/agents/contracts/test/receiptharness"
"github.com/synapsecns/sanguine/agents/contracts/test/requestharness"
"github.com/synapsecns/sanguine/agents/contracts/test/snapshotharness"
"github.com/synapsecns/sanguine/agents/contracts/test/stateharness"
"github.com/synapsecns/sanguine/agents/contracts/test/tipsharness"
"github.com/synapsecns/sanguine/agents/contracts/test/summitharness"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/synapsecns/sanguine/agents/contracts/test/destinationharness"
"github.com/synapsecns/sanguine/agents/contracts/test/headerharness"
"github.com/synapsecns/sanguine/agents/contracts/test/messageharness"
"github.com/synapsecns/sanguine/agents/contracts/test/pingpongclient"
"github.com/synapsecns/sanguine/agents/contracts/test/testclient"
"github.com/synapsecns/sanguine/agents/testutil/agentstestcontract"
"github.com/synapsecns/sanguine/ethergo/backends"
"github.com/synapsecns/sanguine/ethergo/contracts"
"github.com/synapsecns/sanguine/ethergo/deployer"
)
// SynapseChainID is the chain ID for the synapse chain.
const SynapseChainID = 10
// MessageHarnessDeployer deploys the message harness for testing.
type MessageHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewMessageHarnessDeployer creates a message harness deployer.
func NewMessageHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return MessageHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, MessageHarnessType)}
}
// Deploy deploys the message harness deployer.
func (d MessageHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
return d.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return messageharness.DeployMessageHarness(transactOps, backend)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return messageharness.NewMessageHarnessRef(address, backend)
})
}
// BaseMessageHarnessDeployer deploys the base message harness for testing.
type BaseMessageHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewBaseMessageHarnessDeployer creates a base message harness deployer.
func NewBaseMessageHarnessDeployer(regirstry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return BaseMessageHarnessDeployer{deployer.NewSimpleDeployer(regirstry, backend, BaseMessageHarnessType)}
}
// Deploy deploys the base message harness deployer.
func (d BaseMessageHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
return d.DeploySimpleContract(ctx, func(transactOpts *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return basemessageharness.DeployBaseMessageHarness(transactOpts, backend)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return basemessageharness.NewBaseMessageHarnessRef(address, backend)
})
}
// ReceiptHarnessDeployer deploys the request harness for testing.
type ReceiptHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewReceiptHarnessDeployer creates a request harness deployer.
func NewReceiptHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return ReceiptHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, ReceiptHarnessType)}
}
// Deploy deploys the receipt harness deployer.
func (d ReceiptHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
return d.DeploySimpleContract(ctx, func(transactOpts *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return receiptharness.DeployReceiptHarness(transactOpts, backend)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return receiptharness.NewReceiptHarnessRef(address, backend)
})
}
// RequestHarnessDeployer deploys the request harness for testing.
type RequestHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewRequestHarnessDeployer creates a request harness deployer.
func NewRequestHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return RequestHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, RequestHarnessType)}
}
// Deploy deploys the request harness deployer.
func (d RequestHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
return d.DeploySimpleContract(ctx, func(transactOpts *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return requestharness.DeployRequestHarness(transactOpts, backend)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return requestharness.NewRequestHarnessRef(address, backend)
})
}
// LightManagerHarnessDeployer deploys the light agent manager for testing.
type LightManagerHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewLightManagerHarnessDeployer deploys a new light agent manager harness.
func NewLightManagerHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return LightManagerHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, LightManagerHarnessType)}
}
// Deploy deploys the light manager harness.
// nolint:dupl,dupword
func (o LightManagerHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
/*originHarnessContract := o.Registry().Get(ctx, OriginHarnessType)
destinationHarnessContract := o.Registry().Get(ctx, DestinationHarnessType)
originAddress := originHarnessContract.Address()
destinationAddress := destinationHarnessContract.Address()*/
return o.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
address, tx, rawHandle, err := lightmanagerharness.DeployLightManagerHarness(transactOps, backend, SynapseChainID)
if err != nil {
return common.Address{}, nil, nil, fmt.Errorf("could not deploy %s: %w", o.ContractType().ContractName(), err)
}
o.Backend().WaitForConfirmation(ctx, tx)
/*initializeOpts := o.Backend().GetTxContext(ctx, &transactOps.From)
initializeTx, err := rawHandle.Initialize(initializeOpts.TransactOpts, originAddress, destinationAddress)
if err != nil {
return common.Address{}, nil, nil, fmt.Errorf("could not initialize origin (%s) on %s: %w", transactOps.From, o.ContractType().ContractName(), err)
}
o.Backend().WaitForConfirmation(ctx, initializeTx)*/
return address, tx, rawHandle, err
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return lightmanagerharness.NewLightManagerHarnessRef(address, backend)
})
}
// Dependencies gets a list of dependencies used to deploy the light agent manager contract.
func (o LightManagerHarnessDeployer) Dependencies() []contracts.ContractType {
return []contracts.ContractType{}
}
// BondingManagerHarnessDeployer deploys the bonding manager for testing.
type BondingManagerHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewBondingManagerHarnessDeployer deploys a new bonding agent manager harness.
func NewBondingManagerHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return BondingManagerHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, BondingManagerHarnessType)}
}
// Deploy deploys the light manager harness.
// nolint:dupl,dupword
func (o BondingManagerHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
/*originHarnessContract := o.Registry().Get(ctx, OriginHarnessType)
destinationHarnessContract := o.Registry().Get(ctx, DestinationHarnessType)
originAddress := originHarnessContract.Address()
destinationAddress := destinationHarnessContract.Address()*/
return o.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
address, tx, rawHandle, err := bondingmanagerharness.DeployBondingManagerHarness(transactOps, backend, SynapseChainID)
if err != nil {
return common.Address{}, nil, nil, fmt.Errorf("could not deploy %s: %w", o.ContractType().ContractName(), err)
}
o.Backend().WaitForConfirmation(ctx, tx)
/*initializeOpts := o.Backend().GetTxContext(ctx, &transactOps.From)
initializeTx, err := rawHandle.Initialize(initializeOpts.TransactOpts, originAddress, destinationAddress)
if err != nil {
return common.Address{}, nil, nil, fmt.Errorf("could not initialize origin (%s) on %s: %w", transactOps.From, o.ContractType().ContractName(), err)
}
o.Backend().WaitForConfirmation(ctx, initializeTx)*/
return address, tx, rawHandle, err
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return bondingmanagerharness.NewBondingManagerHarnessRef(address, backend)
})
}
// Dependencies gets a list of dependencies used to deploy the bonding manager contract.
func (o BondingManagerHarnessDeployer) Dependencies() []contracts.ContractType {
return []contracts.ContractType{}
}
// OriginHarnessDeployer deploys the origin harness for testing.
type OriginHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewOriginHarnessDeployer deploys a new origin harness.
func NewOriginHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return OriginHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, OriginHarnessType)}
}
// Deploy deploys the origin harness.
// nolint:dupl
func (o OriginHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
var agentAddress common.Address
var inboxAddress common.Address
if o.Backend().GetChainID() == 10 {
bondingManagerHarnessContract := o.Registry().Get(ctx, BondingManagerHarnessType)
agentAddress = bondingManagerHarnessContract.Address()
inboxContract := o.Registry().Get(ctx, InboxType)
inboxAddress = inboxContract.Address()
} else {
lightManagerHarnessContract := o.Registry().Get(ctx, LightManagerHarnessType)
agentAddress = lightManagerHarnessContract.Address()
lightInboxContract := o.Registry().Get(ctx, LightInboxType)
inboxAddress = lightInboxContract.Address()
}
gasOracleContract := o.Registry().Get(ctx, GasOracleType)
gasOracleAddress := gasOracleContract.Address()
return o.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
address, tx, rawHandle, err := originharness.DeployOriginHarness(transactOps, backend, SynapseChainID, agentAddress, inboxAddress, gasOracleAddress)
if err != nil {
return common.Address{}, nil, nil, fmt.Errorf("could not deploy %s: %w", o.ContractType().ContractName(), err)
}
o.Backend().WaitForConfirmation(ctx, tx)
initializeOpts := o.Backend().GetTxContext(ctx, &transactOps.From)
initializeTx, err := rawHandle.Initialize(initializeOpts.TransactOpts)
if err != nil {
return common.Address{}, nil, nil, fmt.Errorf("could not initialize origin (%s) on %s: %w", transactOps.From, o.ContractType().ContractName(), err)
}
o.Backend().WaitForConfirmation(ctx, initializeTx)
return address, tx, rawHandle, err
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return originharness.NewOriginHarnessRef(address, backend)
})
}
// Dependencies gets a list of dependencies used to deploy the origin contract.
func (o OriginHarnessDeployer) Dependencies() []contracts.ContractType {
return []contracts.ContractType{}
}
// GasDataHarnessDeployer deploys the gasData harness.
type GasDataHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewGasDataHarnessDeployer creates a new deployer for the gasData harness.
func NewGasDataHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return GasDataHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, GasDataHarnessType)}
}
// Deploy deploys the gasData harness.
func (a GasDataHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
return a.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return gasdataharness.DeployGasDataHarness(transactOps, backend)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return gasdataharness.NewGasDataHarnessRef(address, backend)
})
}
// StateHarnessDeployer deploys the state harness.
type StateHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewStateHarnessDeployer creates a new deployer for the state harness.
func NewStateHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return StateHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, StateHarnessType)}
}
// Deploy deploys the state harness.
func (a StateHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
return a.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return stateharness.DeployStateHarness(transactOps, backend)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return stateharness.NewStateHarnessRef(address, backend)
})
}
// SnapshotHarnessDeployer deploys the snapshot harness.
type SnapshotHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewSnapshotHarnessDeployer creates a new deployer for the snapshot harness.
func NewSnapshotHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return SnapshotHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, SnapshotHarnessType)}
}
// Deploy deploys the snapshot harness.
func (a SnapshotHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
return a.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return snapshotharness.DeploySnapshotHarness(transactOps, backend)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return snapshotharness.NewSnapshotHarnessRef(address, backend)
})
}
// AttestationHarnessDeployer deploys the attestation harness for testing.
type AttestationHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewAttestationHarnessDeployer creates a new deployer for the attestation harness.
func NewAttestationHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return AttestationHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, AttestationHarnessType)}
}
// Deploy deploys the attestation harness.
func (a AttestationHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
return a.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return attestationharness.DeployAttestationHarness(transactOps, backend)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return attestationharness.NewAttestationHarnessRef(address, backend)
})
}
// TipsHarnessDeployer deploys the tip harness for tester.
type TipsHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewTipsHarnessDeployer creates a new deployer for the attestation harness.
func NewTipsHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return TipsHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, TipsHarnessType)}
}
// Deploy deploys the attestation harness.
func (a TipsHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
return a.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return tipsharness.DeployTipsHarness(transactOps, backend)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return tipsharness.NewTipsHarnessRef(address, backend)
})
}
// DestinationHarnessDeployer deploys the destination harness.
type DestinationHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewDestinationHarnessDeployer creates a new deployer for the destination harness.
func NewDestinationHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return DestinationHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, DestinationHarnessType)}
}
// Deploy deploys the destination harness.
// nolint:dupl,dupword
func (d DestinationHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
var agentManagerAddress common.Address
var inboxAddress common.Address
if d.Backend().GetChainID() == 10 {
bondingManagerHarnessContract := d.Registry().Get(ctx, BondingManagerHarnessType)
agentManagerAddress = bondingManagerHarnessContract.Address()
inboxContract := d.Registry().Get(ctx, InboxType)
inboxAddress = inboxContract.Address()
} else {
lightManagerHarnessContract := d.Registry().Get(ctx, LightManagerHarnessType)
agentManagerAddress = lightManagerHarnessContract.Address()
lightInboxContract := d.Registry().Get(ctx, LightInboxType)
inboxAddress = lightInboxContract.Address()
}
return d.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
address, tx, rawHandle, err := destinationharness.DeployDestinationHarness(transactOps, backend, SynapseChainID, agentManagerAddress, inboxAddress)
if err != nil {
return common.Address{}, nil, nil, fmt.Errorf("could not deploy %s: %w", d.ContractType().ContractName(), err)
}
d.Backend().WaitForConfirmation(ctx, tx)
/*initializeOpts := d.Backend().GetTxContext(ctx, &transactOps.From)
initializeTx, err := rawHandle.Initialize(initializeOpts.TransactOpts)
if err != nil {
return common.Address{}, nil, nil, fmt.Errorf("could not initialize destination (%s) on %s: %w", transactOps.From, d.ContractType().ContractName(), err)
}
d.Backend().WaitForConfirmation(ctx, initializeTx)*/
return address, tx, rawHandle, err
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return destinationharness.NewDestinationHarnessRef(address, backend)
})
}
// SummitHarnessDeployer deploys the summit harness.
type SummitHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewSummitHarnessDeployer creates a new deployer for the summit harness.
func NewSummitHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return SummitHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, SummitHarnessType)}
}
// Deploy deploys the summit harness.
// nolint:dupl
func (d SummitHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
bondingManagerHarnessContract := d.Registry().Get(ctx, BondingManagerHarnessType)
bondingManagerAddress := bondingManagerHarnessContract.Address()
inboxContract := d.Registry().Get(ctx, InboxType)
inboxAddress := inboxContract.Address()
return d.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
address, tx, rawHandle, err := summitharness.DeploySummitHarness(transactOps, backend, bondingManagerAddress, inboxAddress)
if err != nil {
return common.Address{}, nil, nil, fmt.Errorf("could not deploy %s: %w", d.ContractType().ContractName(), err)
}
d.Backend().WaitForConfirmation(ctx, tx)
initializeOpts := d.Backend().GetTxContext(ctx, &transactOps.From)
initializeTx, err := rawHandle.Initialize(initializeOpts.TransactOpts)
if err != nil {
return common.Address{}, nil, nil, fmt.Errorf("could not initialize summit harness (%s) on %s: %w", transactOps.From, d.ContractType().ContractName(), err)
}
d.Backend().WaitForConfirmation(ctx, initializeTx)
return address, tx, rawHandle, err
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return summitharness.NewSummitHarnessRef(address, backend)
})
}
// HeaderHarnessDeployer deploys the header harness.
type HeaderHarnessDeployer struct {
*deployer.BaseDeployer
}
// NewHeaderHarnessDeployer gets the header harness.
func NewHeaderHarnessDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return HeaderHarnessDeployer{deployer.NewSimpleDeployer(registry, backend, HeaderHarnessType)}
}
// Deploy deploys the header harness.
func (h HeaderHarnessDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
return h.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return headerharness.DeployHeaderHarness(transactOps, backend)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return headerharness.NewHeaderHarnessRef(address, backend)
})
}
// AgentsTestContractDeployer deploys the agents test contract.
type AgentsTestContractDeployer struct {
*deployer.BaseDeployer
}
// NewAgentsTestContractDeployer gets the agents test contract.
func NewAgentsTestContractDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return AgentsTestContractDeployer{deployer.NewSimpleDeployer(registry, backend, AgentsTestContractType)}
}
// Deploy deploys the agents test contract.
func (h AgentsTestContractDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
return h.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return agentstestcontract.DeployAgentsTestContract(transactOps, backend)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return agentstestcontract.NewAgentsTestContractRef(address, backend)
})
}
// TestClientDeployer deploys the test client.
type TestClientDeployer struct {
*deployer.BaseDeployer
}
// NewTestClientDeployer gets the test client.
func NewTestClientDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return TestClientDeployer{deployer.NewSimpleDeployer(registry, backend, TestClientType)}
}
// Deploy deploys the test client.
func (h TestClientDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
originHarnessContract := h.Registry().Get(ctx, OriginHarnessType)
destinationHarnessContract := h.Registry().Get(ctx, DestinationHarnessType)
originAddress := originHarnessContract.Address()
destinationAddress := destinationHarnessContract.Address()
return h.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return testclient.DeployTestClient(transactOps, backend, originAddress, destinationAddress)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return testclient.NewTestClientRef(address, backend)
})
}
// PingPongClientDeployer deploys the ping pong test client.
type PingPongClientDeployer struct {
*deployer.BaseDeployer
}
// NewPingPongClientDeployer gets the ping pong test client.
func NewPingPongClientDeployer(registry deployer.GetOnlyContractRegistry, backend backends.SimulatedTestBackend) deployer.ContractDeployer {
return PingPongClientDeployer{deployer.NewSimpleDeployer(registry, backend, PingPongClientType)}
}
// Deploy deploys the ping pong test client.
func (h PingPongClientDeployer) Deploy(ctx context.Context) (contracts.DeployedContract, error) {
originHarnessContract := h.Registry().Get(ctx, OriginHarnessType)
destinationHarnessContract := h.Registry().Get(ctx, DestinationHarnessType)
originAddress := originHarnessContract.Address()
destinationAddress := destinationHarnessContract.Address()
return h.DeploySimpleContract(ctx, func(transactOps *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, interface{}, error) {
return pingpongclient.DeployPingPongClient(transactOps, backend, originAddress, destinationAddress)
}, func(address common.Address, backend bind.ContractBackend) (interface{}, error) {
return pingpongclient.NewPingPongClientRef(address, backend)
})
}