Skip to content

Commit 8243213

Browse files
test: Tests added for duplicated recipients check
1 parent ddca6ca commit 8243213

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/ATokenVaultRevenueSplitterOwner.t.sol

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,34 @@ contract ATokenVaultRevenueSplitterOwnerTest is Test {
105105
new ATokenVaultRevenueSplitterOwner(address(vault), owner, recipients);
106106
}
107107

108+
function test_constructor_revertsIfSomeRecipientIsDuplicated(
109+
uint8 recipientsLength, uint8 setDuplicatedAt, uint8 copyFrom
110+
) public {
111+
recipientsLength = uint8(bound(recipientsLength, 2, 15));
112+
setDuplicatedAt = uint8(bound(setDuplicatedAt, 0, recipientsLength - 1));
113+
copyFrom = uint8(bound(copyFrom, 0, recipientsLength - 1));
114+
vm.assume(setDuplicatedAt != copyFrom);
115+
116+
117+
uint16 eachRecipientShare = uint16(TOTAL_SHARE_IN_BPS / recipientsLength);
118+
uint16 accumulatedShares = 0;
119+
120+
ATokenVaultRevenueSplitterOwner.Recipient[] memory recipientsWithDuplicate =
121+
new ATokenVaultRevenueSplitterOwner.Recipient[](recipientsLength);
122+
for (uint8 i = 0; i < recipientsLength - 1; i++) {
123+
recipientsWithDuplicate[i].addr = makeAddr(string(abi.encodePacked("recipient", i)));
124+
recipientsWithDuplicate[i].shareInBps = eachRecipientShare;
125+
accumulatedShares += eachRecipientShare;
126+
}
127+
recipientsWithDuplicate[recipientsLength - 1].addr = makeAddr(string(abi.encodePacked("recipient", recipientsLength - 1)));
128+
recipientsWithDuplicate[recipientsLength - 1].shareInBps = uint16(TOTAL_SHARE_IN_BPS - accumulatedShares);
129+
130+
recipientsWithDuplicate[setDuplicatedAt].addr = recipientsWithDuplicate[copyFrom].addr;
131+
132+
vm.expectRevert("DUPLICATED_RECIPIENT");
133+
new ATokenVaultRevenueSplitterOwner(address(vault), owner, recipientsWithDuplicate);
134+
}
135+
108136
function test_constructor_revertsIfRecipientsSumExceedsTotalBpsSum() public {
109137
// Sum of shares (50.00% + 30.00% + 30.00% = 110.00%) exceeds the expected 100.00%
110138
recipients[0].shareInBps = 5_000; // 50.00%

0 commit comments

Comments
 (0)