1
1
// SPDX-License-Identifier: BUSL-1.1
2
2
pragma solidity ^ 0.8.27 ;
3
3
4
- import {Test} from "forge-std/Test.sol " ;
5
4
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol " ;
6
5
import {TransparentUpgradeableProxy} from
7
6
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol " ;
@@ -17,12 +16,11 @@ import {ITaskAVSRegistrarBaseTypes} from "../../src/interfaces/ITaskAVSRegistrar
17
16
import {ITaskAVSRegistrarBaseErrors} from "../../src/interfaces/ITaskAVSRegistrarBase.sol " ;
18
17
import {ITaskAVSRegistrarBaseEvents} from "../../src/interfaces/ITaskAVSRegistrarBase.sol " ;
19
18
import {MockTaskAVSRegistrar} from "../mocks/MockTaskAVSRegistrar.sol " ;
20
- import {AllocationManagerMock} from "../mocks/AllocationManagerMock.sol " ;
21
- import {KeyRegistrarMock} from "../mocks/KeyRegistrarMock.sol " ;
19
+ import {MockEigenLayerDeployer} from "./middlewareV2/MockDeployer.sol " ;
22
20
23
21
// Base test contract with common setup
24
22
contract TaskAVSRegistrarBaseUnitTests is
25
- Test ,
23
+ MockEigenLayerDeployer ,
26
24
ITaskAVSRegistrarBaseTypes ,
27
25
ITaskAVSRegistrarBaseErrors ,
28
26
ITaskAVSRegistrarBaseEvents
@@ -32,10 +30,6 @@ contract TaskAVSRegistrarBaseUnitTests is
32
30
address public owner = address (0x4 );
33
31
address public nonOwner = address (0x5 );
34
32
35
- // Mock contracts
36
- AllocationManagerMock public allocationManager;
37
- KeyRegistrarMock public keyRegistrar;
38
-
39
33
// Test operator set IDs
40
34
uint32 public constant AGGREGATOR_OPERATOR_SET_ID = 1 ;
41
35
uint32 public constant EXECUTOR_OPERATOR_SET_ID_1 = 2 ;
@@ -44,20 +38,19 @@ contract TaskAVSRegistrarBaseUnitTests is
44
38
45
39
// Contract under test
46
40
MockTaskAVSRegistrar public registrar;
47
- ProxyAdmin public proxyAdmin;
48
41
49
42
function setUp () public virtual {
50
- // Deploy mock contracts
51
- allocationManager = new AllocationManagerMock ();
52
- keyRegistrar = new KeyRegistrarMock ();
43
+ // Deploy mock EigenLayer contracts
44
+ _deployMockEigenLayer ();
53
45
54
46
// Create initial valid config
55
47
AvsConfig memory initialConfig = _createValidAvsConfig ();
56
48
57
49
// Deploy the registrar with proxy pattern
58
- proxyAdmin = new ProxyAdmin ();
59
50
MockTaskAVSRegistrar registrarImpl = new MockTaskAVSRegistrar (
60
- IAllocationManager (address (allocationManager)), IKeyRegistrar (address (keyRegistrar))
51
+ IAllocationManager (address (allocationManagerMock)),
52
+ IKeyRegistrar (address (keyRegistrarMock)),
53
+ permissionController
61
54
);
62
55
TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy (
63
56
address (registrarImpl),
@@ -139,7 +132,9 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe
139
132
// Deploy new registrar with proxy pattern
140
133
ProxyAdmin newProxyAdmin = new ProxyAdmin ();
141
134
MockTaskAVSRegistrar newRegistrarImpl = new MockTaskAVSRegistrar (
142
- IAllocationManager (address (allocationManager)), IKeyRegistrar (address (keyRegistrar))
135
+ IAllocationManager (address (allocationManagerMock)),
136
+ IKeyRegistrar (address (keyRegistrarMock)),
137
+ permissionController
143
138
);
144
139
TransparentUpgradeableProxy newProxy = new TransparentUpgradeableProxy (
145
140
address (newRegistrarImpl),
@@ -169,7 +164,9 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe
169
164
// Deploy implementation
170
165
ProxyAdmin newProxyAdmin = new ProxyAdmin ();
171
166
MockTaskAVSRegistrar newRegistrarImpl = new MockTaskAVSRegistrar (
172
- IAllocationManager (address (allocationManager)), IKeyRegistrar (address (keyRegistrar))
167
+ IAllocationManager (address (allocationManagerMock)),
168
+ IKeyRegistrar (address (keyRegistrarMock)),
169
+ permissionController
173
170
);
174
171
175
172
// Expect event during initialization
@@ -190,7 +187,9 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe
190
187
// Deploy implementation
191
188
ProxyAdmin newProxyAdmin = new ProxyAdmin ();
192
189
MockTaskAVSRegistrar newRegistrarImpl = new MockTaskAVSRegistrar (
193
- IAllocationManager (address (allocationManager)), IKeyRegistrar (address (keyRegistrar))
190
+ IAllocationManager (address (allocationManagerMock)),
191
+ IKeyRegistrar (address (keyRegistrarMock)),
192
+ permissionController
194
193
);
195
194
196
195
// Expect revert during initialization
@@ -208,7 +207,9 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe
208
207
// Deploy implementation
209
208
ProxyAdmin newProxyAdmin = new ProxyAdmin ();
210
209
MockTaskAVSRegistrar newRegistrarImpl = new MockTaskAVSRegistrar (
211
- IAllocationManager (address (allocationManager)), IKeyRegistrar (address (keyRegistrar))
210
+ IAllocationManager (address (allocationManagerMock)),
211
+ IKeyRegistrar (address (keyRegistrarMock)),
212
+ permissionController
212
213
);
213
214
214
215
// Expect revert during initialization
@@ -226,7 +227,9 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe
226
227
// Deploy implementation
227
228
ProxyAdmin newProxyAdmin = new ProxyAdmin ();
228
229
MockTaskAVSRegistrar newRegistrarImpl = new MockTaskAVSRegistrar (
229
- IAllocationManager (address (allocationManager)), IKeyRegistrar (address (keyRegistrar))
230
+ IAllocationManager (address (allocationManagerMock)),
231
+ IKeyRegistrar (address (keyRegistrarMock)),
232
+ permissionController
230
233
);
231
234
232
235
// Expect revert during initialization
@@ -244,7 +247,9 @@ contract TaskAVSRegistrarBaseUnitTests_Constructor is TaskAVSRegistrarBaseUnitTe
244
247
// Deploy implementation
245
248
ProxyAdmin newProxyAdmin = new ProxyAdmin ();
246
249
MockTaskAVSRegistrar newRegistrarImpl = new MockTaskAVSRegistrar (
247
- IAllocationManager (address (allocationManager)), IKeyRegistrar (address (keyRegistrar))
250
+ IAllocationManager (address (allocationManagerMock)),
251
+ IKeyRegistrar (address (keyRegistrarMock)),
252
+ permissionController
248
253
);
249
254
250
255
// Expect revert during initialization
@@ -416,7 +421,9 @@ contract TaskAVSRegistrarBaseUnitTests_Upgradeable is TaskAVSRegistrarBaseUnitTe
416
421
function test_Implementation_CannotBeInitialized () public {
417
422
// Deploy a new implementation
418
423
MockTaskAVSRegistrar newImpl = new MockTaskAVSRegistrar (
419
- IAllocationManager (address (allocationManager)), IKeyRegistrar (address (keyRegistrar))
424
+ IAllocationManager (address (allocationManagerMock)),
425
+ IKeyRegistrar (address (keyRegistrarMock)),
426
+ permissionController
420
427
);
421
428
422
429
// Try to initialize the implementation directly, should revert
@@ -438,7 +445,9 @@ contract TaskAVSRegistrarBaseUnitTests_Upgradeable is TaskAVSRegistrarBaseUnitTe
438
445
439
446
// Deploy new implementation (could have new functions/logic)
440
447
MockTaskAVSRegistrar newImpl = new MockTaskAVSRegistrar (
441
- IAllocationManager (address (allocationManager)), IKeyRegistrar (address (keyRegistrar))
448
+ IAllocationManager (address (allocationManagerMock)),
449
+ IKeyRegistrar (address (keyRegistrarMock)),
450
+ permissionController
442
451
);
443
452
444
453
// Upgrade proxy to new implementation
@@ -463,7 +472,9 @@ contract TaskAVSRegistrarBaseUnitTests_Upgradeable is TaskAVSRegistrarBaseUnitTe
463
472
464
473
// Deploy new implementation
465
474
MockTaskAVSRegistrar newImpl = new MockTaskAVSRegistrar (
466
- IAllocationManager (address (allocationManager)), IKeyRegistrar (address (keyRegistrar))
475
+ IAllocationManager (address (allocationManagerMock)),
476
+ IKeyRegistrar (address (keyRegistrarMock)),
477
+ permissionController
467
478
);
468
479
469
480
// Try to upgrade from non-owner, should revert
@@ -511,7 +522,9 @@ contract TaskAVSRegistrarBaseUnitTests_Upgradeable is TaskAVSRegistrarBaseUnitTe
511
522
512
523
// Deploy new implementation
513
524
MockTaskAVSRegistrar newImpl = new MockTaskAVSRegistrar (
514
- IAllocationManager (address (allocationManager)), IKeyRegistrar (address (keyRegistrar))
525
+ IAllocationManager (address (allocationManagerMock)),
526
+ IKeyRegistrar (address (keyRegistrarMock)),
527
+ permissionController
515
528
);
516
529
517
530
// Upgrade
@@ -540,8 +553,9 @@ contract TaskAVSRegistrarBaseUnitTests_Upgradeable is TaskAVSRegistrarBaseUnitTe
540
553
TransparentUpgradeableProxy uninitializedProxy = new TransparentUpgradeableProxy (
541
554
address (
542
555
new MockTaskAVSRegistrar (
543
- IAllocationManager (address (allocationManager)),
544
- IKeyRegistrar (address (keyRegistrar))
556
+ IAllocationManager (address (allocationManagerMock)),
557
+ IKeyRegistrar (address (keyRegistrarMock)),
558
+ permissionController
545
559
)
546
560
),
547
561
address (new ProxyAdmin ()),
@@ -564,7 +578,9 @@ contract TaskAVSRegistrarBaseUnitTests_Upgradeable is TaskAVSRegistrarBaseUnitTe
564
578
function test_DisableInitializers_InImplementation () public {
565
579
// This test verifies that the implementation contract has initializers disabled
566
580
MockTaskAVSRegistrar impl = new MockTaskAVSRegistrar (
567
- IAllocationManager (address (allocationManager)), IKeyRegistrar (address (keyRegistrar))
581
+ IAllocationManager (address (allocationManagerMock)),
582
+ IKeyRegistrar (address (keyRegistrarMock)),
583
+ permissionController
568
584
);
569
585
570
586
// Try to initialize the implementation, should revert
0 commit comments