Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

Commit

Permalink
Add public accessor to hasVoted
Browse files Browse the repository at this point in the history
  • Loading branch information
jannikluhn committed Apr 7, 2024
1 parent 1bb7f0d commit 08ef5d8
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
33 changes: 32 additions & 1 deletion bindings/eonkeypublish.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/EonKeyPublish.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ contract EonKeyPublish is EonKeyPublisher {
return false;
}

function hasKeyperVoted(address keyper) public view returns (bool) {
return hasVoted[keyper];
}

function publishEonKey(bytes memory eonKey, uint64 keyperId) public {
if (eonKey.length == 0) {
revert InvalidKey();
Expand Down
33 changes: 33 additions & 0 deletions test/EonKeyPublish.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,37 @@ contract EonKeyPublishTest is Test {
assertEq(broadcastContract.getEonKey(eon), bytes("deadbeef"));
vm.stopPrank();
}

function testHasVoted() public {
uint64 eon = 1;
address[] memory members = new address[](5);
members[0] = address(61);
members[1] = address(62);
members[2] = address(63);
members[3] = address(64);
members[4] = address(65);
keyperSet.addMembers(members);
keyperSet.setThreshold(2);
keyperSet.setPublisher(address(eonKeyPublish));
keyperSet.setFinalized();
assertEq(keyperSet.getThreshold(), 2);
bytes memory key = bytes("deadbeef");
vm.startPrank(dao);
manager.addKeyperSet(uint64(block.number + 10), address(keyperSet));
vm.stopPrank();
for (uint i = 0; i < members.length; i++) {
assertEq(eonKeyPublish.hasKeyperVoted(members[i]), false);
}
for (uint i = 0; i < keyperSet.getThreshold(); i++) {
vm.prank(members[i]);
eonKeyPublish.publishEonKey(key, uint64(i));

for (uint j = 0; j <= i; j++) {
assertEq(eonKeyPublish.hasKeyperVoted(members[j]), true);
}
for (uint j = i + 1; j < members.length; j++) {
assertEq(eonKeyPublish.hasKeyperVoted(members[j]), false);
}
}
}
}

0 comments on commit 08ef5d8

Please sign in to comment.