From e7052e7fe30ab36729790c369e1094665545dd41 Mon Sep 17 00:00:00 2001 From: 0xKurt Date: Mon, 20 Jan 2025 09:04:43 +0100 Subject: [PATCH] update distribute function --- .../_poc/easy-rf/EasyRetroFundingStrategy.sol | 8 +++++-- test/foundry/strategies/EasyRFStrategy.t.sol | 23 ++++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/contracts/strategies/_poc/easy-rf/EasyRetroFundingStrategy.sol b/contracts/strategies/_poc/easy-rf/EasyRetroFundingStrategy.sol index 22cb7366..f17c8938 100644 --- a/contracts/strategies/_poc/easy-rf/EasyRetroFundingStrategy.sol +++ b/contracts/strategies/_poc/easy-rf/EasyRetroFundingStrategy.sol @@ -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 diff --git a/test/foundry/strategies/EasyRFStrategy.t.sol b/test/foundry/strategies/EasyRFStrategy.t.sol index 4c72baa1..6bd8350e 100644 --- a/test/foundry/strategies/EasyRFStrategy.t.sol +++ b/test/foundry/strategies/EasyRFStrategy.t.sol @@ -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()); } @@ -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 ====== /// ====================