Skip to content

Commit

Permalink
update distribute function (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKurt authored Jan 20, 2025
1 parent cf37467 commit 8ba3f39
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,12 @@ contract EasyRetroFundingStrategy is Native, BaseStrategy, Multicall {
override
onlyPoolManager(_sender)
{
if (keccak256(bytes(distributionMetadata.pointer)) != NULL_POINTER) {
distributionStarted = true;
if (!distributionStarted) {
if (keccak256(bytes(distributionMetadata.pointer)) != NULL_POINTER) {
distributionStarted = true;
} else {
revert INVALID();
}
}

// Decode the '_data' to get the distributions
Expand Down
23 changes: 22 additions & 1 deletion test/foundry/strategies/EasyRFStrategy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,13 @@ contract EasyRetroFundingStrategyTest is Test, AlloSetup, RegistrySetupFull, Eve
// invalid recipientId
distributions[1] = EasyRetroFundingStrategy.Distribution({index: 1, recipientId: randomAddress(), amount: 2e18});

vm.prank(address(allo()));
vm.warp(poolEndTime + 1);
vm.prank(pool_admin());
strategy.updateDistribution(Metadata(1, "metadata"));

vm.expectRevert(abi.encodeWithSelector(RECIPIENT_ERROR.selector, profile1_notAMember()));

vm.prank(address(allo()));
strategy.distribute(new address[](0), abi.encode(distributions), pool_admin());
}

Expand Down Expand Up @@ -645,6 +649,23 @@ contract EasyRetroFundingStrategyTest is Test, AlloSetup, RegistrySetupFull, Eve
strategy.distribute(new address[](0), abi.encode(distributions), pool_admin());
}

function testRevert_distribute_INVALID() public {
__register_accept_recipient();
__register_recipient2();

EasyRetroFundingStrategy.Distribution[] memory distributions = new EasyRetroFundingStrategy.Distribution[](2);
distributions[0] =
EasyRetroFundingStrategy.Distribution({index: 0, recipientId: profile1_notAMember(), amount: 1e18});

// invalid recipientId
distributions[1] = EasyRetroFundingStrategy.Distribution({index: 1, recipientId: randomAddress(), amount: 2e18});

vm.prank(address(allo()));
vm.expectRevert(INVALID.selector);

strategy.distribute(new address[](0), abi.encode(distributions), pool_admin());
}

/// ====================
/// ===== Helpers ======
/// ====================
Expand Down

0 comments on commit 8ba3f39

Please sign in to comment.