diff --git a/packages/protocol/contracts-0.8/common/EpochManager.sol b/packages/protocol/contracts-0.8/common/EpochManager.sol index eb680c41a4..5f847e56de 100644 --- a/packages/protocol/contracts-0.8/common/EpochManager.sol +++ b/packages/protocol/contracts-0.8/common/EpochManager.sol @@ -306,10 +306,11 @@ contract EpochManager is delete processedGroups[group]; toProcessGroups--; + emit GroupProcessed(group, currentEpochNumber); + if (toProcessGroups == 0) { _finishEpochHelper(_epochProcessing, election); } - emit GroupProcessed(group, currentEpochNumber); } /** @@ -364,7 +365,7 @@ contract EpochManager is } delete processedGroups[groups[i]]; - emit GroupProcessed(group, currentEpochNumber); + emit GroupProcessed(groups[i], currentEpochNumber); } _finishEpochHelper(_epochProcessing, election); diff --git a/packages/protocol/test-sol/unit/common/EpochManager.t.sol b/packages/protocol/test-sol/unit/common/EpochManager.t.sol index e1e342e5fc..b166776750 100644 --- a/packages/protocol/test-sol/unit/common/EpochManager.t.sol +++ b/packages/protocol/test-sol/unit/common/EpochManager.t.sol @@ -74,12 +74,11 @@ contract EpochManagerTest is Test, TestConstants, Utils08 { address indexed beneficiary, uint256 delegatedPayment ); - event EpochProcessingStarted(uint256 indexed epochNumber); event EpochDurationSet(uint256 indexed newEpochDuration); event OracleAddressSet(address indexed newOracleAddress); - event GroupMarkedForProcessing(address indexed group); - event GroupProcessed(address indexed group); + event GroupMarkedForProcessing(address indexed group, uint256 indexed epochNumber); + event GroupProcessed(address indexed group, uint256 indexed epochNumber); function setUp() public virtual { epochManager = new EpochManager_WithMocks(); @@ -642,6 +641,23 @@ contract EpochManagerTest_finishNextEpochProcess is EpochManagerTest { assertEq(newElected[i], afterElected[i]); } } + + function test_Emits_GroupProcessedEvent() public { + ( + address[] memory groups, + address[] memory lessers, + address[] memory greaters + ) = getGroupsWithLessersAndGreaters(); + + epochManager.startNextEpochProcess(); + + for (uint i = 0; i < groups.length; i++) { + vm.expectEmit(true, true, true, true); + emit GroupProcessed(groups[i], firstEpochNumber); + } + + epochManager.finishNextEpochProcess(groups, lessers, greaters); + } } contract EpochManagerTest_setToProcessGroups is EpochManagerTest { @@ -714,8 +730,12 @@ contract EpochManagerTest_setToProcessGroups is EpochManagerTest { (address[] memory groups, , ) = getGroupsWithLessersAndGreaters(); epochManager.startNextEpochProcess(); - vm.expectEmit(true, true, true, true); - emit GroupMarkedForProcessing(groups[0]); + + for (uint i = 0; i < groups.length; i++) { + vm.expectEmit(true, true, true, true); + emit GroupMarkedForProcessing(groups[i], firstEpochNumber); + } + epochManager.setToProcessGroups(); } } @@ -845,7 +865,7 @@ contract EpochManagerTest_processGroup is EpochManagerTest { epochManager.startNextEpochProcess(); epochManager.setToProcessGroups(); vm.expectEmit(true, true, true, true); - emit GroupProcessed(group); + emit GroupProcessed(group, firstEpochNumber); epochManager.processGroup(group, address(0), address(0)); } }