Skip to content

Commit 08ef5d8

Browse files
committed
Add public accessor to hasVoted
1 parent 1bb7f0d commit 08ef5d8

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

bindings/eonkeypublish.go

Lines changed: 32 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/EonKeyPublish.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ contract EonKeyPublish is EonKeyPublisher {
2929
return false;
3030
}
3131

32+
function hasKeyperVoted(address keyper) public view returns (bool) {
33+
return hasVoted[keyper];
34+
}
35+
3236
function publishEonKey(bytes memory eonKey, uint64 keyperId) public {
3337
if (eonKey.length == 0) {
3438
revert InvalidKey();

test/EonKeyPublish.t.sol

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,37 @@ contract EonKeyPublishTest is Test {
192192
assertEq(broadcastContract.getEonKey(eon), bytes("deadbeef"));
193193
vm.stopPrank();
194194
}
195+
196+
function testHasVoted() public {
197+
uint64 eon = 1;
198+
address[] memory members = new address[](5);
199+
members[0] = address(61);
200+
members[1] = address(62);
201+
members[2] = address(63);
202+
members[3] = address(64);
203+
members[4] = address(65);
204+
keyperSet.addMembers(members);
205+
keyperSet.setThreshold(2);
206+
keyperSet.setPublisher(address(eonKeyPublish));
207+
keyperSet.setFinalized();
208+
assertEq(keyperSet.getThreshold(), 2);
209+
bytes memory key = bytes("deadbeef");
210+
vm.startPrank(dao);
211+
manager.addKeyperSet(uint64(block.number + 10), address(keyperSet));
212+
vm.stopPrank();
213+
for (uint i = 0; i < members.length; i++) {
214+
assertEq(eonKeyPublish.hasKeyperVoted(members[i]), false);
215+
}
216+
for (uint i = 0; i < keyperSet.getThreshold(); i++) {
217+
vm.prank(members[i]);
218+
eonKeyPublish.publishEonKey(key, uint64(i));
219+
220+
for (uint j = 0; j <= i; j++) {
221+
assertEq(eonKeyPublish.hasKeyperVoted(members[j]), true);
222+
}
223+
for (uint j = i + 1; j < members.length; j++) {
224+
assertEq(eonKeyPublish.hasKeyperVoted(members[j]), false);
225+
}
226+
}
227+
}
195228
}

0 commit comments

Comments
 (0)