2
2
pragma solidity ^ 0.8.20 ;
3
3
4
4
import "forge-std/Test.sol " ;
5
- import "../src/KeyperSetManager.sol " ;
6
- import "../src/KeyperSet.sol " ;
5
+ import "../src/common/ KeyperSetManager.sol " ;
6
+ import "../src/common/ KeyperSet.sol " ;
7
7
8
8
contract KeyperSetManagerTest is Test {
9
9
KeyperSetManager public keyperSetManager;
10
10
KeyperSet public members0;
11
11
KeyperSet public members1;
12
-
12
+ address public owner;
13
+
13
14
function setUp () public {
14
- keyperSetManager = new KeyperSetManager ();
15
+ owner = vm.addr (42 );
16
+ vm.prank (owner);
17
+ keyperSetManager = new KeyperSetManager (owner);
18
+ vm.prank (owner);
19
+ keyperSetManager.initialize (owner, owner);
15
20
members0 = new KeyperSet ();
16
21
members0.setFinalized ();
17
22
members1 = new KeyperSet ();
@@ -20,15 +25,23 @@ contract KeyperSetManagerTest is Test {
20
25
21
26
function testGetNumKeyperSets () public {
22
27
assertEq (keyperSetManager.getNumKeyperSets (), 0 );
28
+ vm.prank (owner);
23
29
keyperSetManager.addKeyperSet (0 , address (members0));
24
30
assertEq (keyperSetManager.getNumKeyperSets (), 1 );
31
+ vm.prank (owner);
25
32
keyperSetManager.addKeyperSet (1 , address (members0));
26
33
assertEq (keyperSetManager.getNumKeyperSets (), 2 );
27
34
}
28
35
29
36
function testAddKeyperSetOnlyOwner () public {
30
37
vm.prank (address (1 ));
31
- vm.expectRevert ("Ownable: caller is not the owner " );
38
+ vm.expectRevert (
39
+ abi.encodeWithSelector (
40
+ IAccessControl.AccessControlUnauthorizedAccount.selector ,
41
+ address (1 ),
42
+ keyperSetManager.DEFAULT_ADMIN_ROLE
43
+ )
44
+ );
32
45
keyperSetManager.addKeyperSet (0 , address (members0));
33
46
}
34
47
@@ -50,36 +63,37 @@ contract KeyperSetManagerTest is Test {
50
63
function testAddKeyperSetEmits () public {
51
64
vm.expectEmit (address (keyperSetManager));
52
65
emit KeyperSetAdded (1000 , address (members0));
66
+ vm.prank (owner);
53
67
keyperSetManager.addKeyperSet (1000 , address (members0));
54
68
}
55
69
56
- function testGetKeyperSetIndexBySlotEmpty () public {
70
+ function testGetKeyperSetIndexByBlockEmpty () public {
57
71
vm.expectRevert (NoActiveKeyperSet.selector );
58
- keyperSetManager.getKeyperSetIndexBySlot (0 );
72
+ keyperSetManager.getKeyperSetIndexByBlock (0 );
59
73
}
60
74
61
- function testGetKeyperSetIndexBySlot () public {
75
+ function testGetKeyperSetIndexByBlock () public {
62
76
keyperSetManager.addKeyperSet (1000 , address (members0));
63
77
keyperSetManager.addKeyperSet (1100 , address (members1));
64
78
65
79
vm.expectRevert (NoActiveKeyperSet.selector );
66
- keyperSetManager.getKeyperSetIndexBySlot (0 );
80
+ keyperSetManager.getKeyperSetIndexByBlock (0 );
67
81
68
82
vm.expectRevert (NoActiveKeyperSet.selector );
69
- keyperSetManager.getKeyperSetIndexBySlot (999 );
83
+ keyperSetManager.getKeyperSetIndexByBlock (999 );
70
84
71
- assertEq (keyperSetManager.getKeyperSetIndexBySlot (1000 ), 0 );
72
- assertEq (keyperSetManager.getKeyperSetIndexBySlot (1099 ), 0 );
85
+ assertEq (keyperSetManager.getKeyperSetIndexByBlock (1000 ), 0 );
86
+ assertEq (keyperSetManager.getKeyperSetIndexByBlock (1099 ), 0 );
73
87
74
- assertEq (keyperSetManager.getKeyperSetIndexBySlot (1100 ), 1 );
75
- assertEq (keyperSetManager.getKeyperSetIndexBySlot (1250 ), 1 );
88
+ assertEq (keyperSetManager.getKeyperSetIndexByBlock (1100 ), 1 );
89
+ assertEq (keyperSetManager.getKeyperSetIndexByBlock (1250 ), 1 );
76
90
}
77
91
78
- function testGetKeyperSetActivationSlot () public {
92
+ function testGetKeyperSetActivationBlock () public {
79
93
keyperSetManager.addKeyperSet (1000 , address (members0));
80
94
keyperSetManager.addKeyperSet (1100 , address (members1));
81
- assertEq (keyperSetManager.getKeyperSetActivationSlot (0 ), 1000 );
82
- assertEq (keyperSetManager.getKeyperSetActivationSlot (1 ), 1100 );
95
+ assertEq (keyperSetManager.getKeyperSetActivationBlock (0 ), 1000 );
96
+ assertEq (keyperSetManager.getKeyperSetActivationBlock (1 ), 1100 );
83
97
}
84
98
85
99
function testGetKeyperSetAddress () public {
0 commit comments