Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions test/AdminRecipientRegistry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ contract AdminRecipientRegistryTest is TestWrapper {
registry.initialize(ADMIN);
}

function test_Initialize() public view {
function test_WhenInitializing() external view {
// it should set admin and zero recipients
assertEq(registry.owner(), ADMIN);
assertEq(registry.getRecipientCount(), 0);
}

function test_QueueAndUpdateRecipient() public {
function test_WhenQueuingASingleAddition() external {
// it should queue recipient and process correctly
vm.prank(ADMIN);
vm.expectEmit(true, false, false, false);
emit IRecipientRegistry.RecipientQueued(RECIPIENT_1, true);
Expand Down Expand Up @@ -54,7 +56,8 @@ contract AdminRecipientRegistryTest is TestWrapper {
assertEq(recipients[0], RECIPIENT_1);
}

function test_QueueMultipleRecipients() public {
function test_WhenQueuingMultipleAdditions() external {
// it should queue and process all recipients
address[] memory toAdd = new address[](3);
toAdd[0] = RECIPIENT_1;
toAdd[1] = RECIPIENT_2;
Expand All @@ -75,7 +78,8 @@ contract AdminRecipientRegistryTest is TestWrapper {
assertTrue(registry.isRecipient(RECIPIENT_3));
}

function test_QueueAndRemoveRecipient() public {
function test_WhenQueuingARemoval() external {
// it should remove recipient after processing
vm.startPrank(ADMIN);
registry.queueRecipientAddition(RECIPIENT_1);
registry.queueRecipientAddition(RECIPIENT_2);
Expand Down Expand Up @@ -103,7 +107,8 @@ contract AdminRecipientRegistryTest is TestWrapper {
assertEq(registry.getRecipientCount(), 1);
}

function test_QueueMultipleRemoval() public {
function test_WhenQueuingMultipleRemovals() external {
// it should remove selected recipients
vm.startPrank(ADMIN);

// Add recipients
Expand Down Expand Up @@ -131,13 +136,15 @@ contract AdminRecipientRegistryTest is TestWrapper {
assertEq(registry.getRecipientCount(), 2);
}

function test_RevertOnInvalidRecipient() public {
function test_RevertWhen_QueuingAnInvalidRecipient() external {
// it should revert
vm.prank(ADMIN);
vm.expectRevert();
registry.queueRecipientAddition(address(0));
}

function test_RevertOnDuplicateRecipient() public {
function test_RevertWhen_QueuingADuplicateRecipient() external {
// it should revert
vm.startPrank(ADMIN);
registry.queueRecipientAddition(RECIPIENT_1);
registry.processQueue();
Expand All @@ -147,19 +154,22 @@ contract AdminRecipientRegistryTest is TestWrapper {
vm.stopPrank();
}

function test_RevertOnRemovingNonExistent() public {
function test_RevertWhen_RemovingANonExistentRecipient() external {
// it should revert
vm.prank(ADMIN);
vm.expectRevert();
registry.queueRecipientRemoval(RECIPIENT_1);
}

function test_OnlyAdminCanQueue() public {
function test_RevertWhen_ANonAdminQueuesAddition() external {
// it should revert
vm.prank(address(0xdead));
vm.expectRevert();
registry.queueRecipientAddition(RECIPIENT_1);
}

function test_OnlyAdminCanQueueRemoval() public {
function test_RevertWhen_ANonAdminQueuesRemoval() external {
// it should revert
vm.prank(ADMIN);
registry.queueRecipientAddition(RECIPIENT_1);
registry.processQueue();
Expand All @@ -169,7 +179,8 @@ contract AdminRecipientRegistryTest is TestWrapper {
registry.queueRecipientRemoval(RECIPIENT_1);
}

function test_TransferAdmin() public {
function test_WhenTransferringAdmin() external {
// it should allow new admin and revoke old
address newAdmin = address(0xBEEF);

vm.prank(ADMIN);
Expand All @@ -189,7 +200,8 @@ contract AdminRecipientRegistryTest is TestWrapper {
registry.queueRecipientAddition(RECIPIENT_2);
}

function test_LargeScaleOperations() public {
function test_WhenPerformingLargeScaleOperations() external {
// it should handle 100 additions and 50 removals
vm.startPrank(ADMIN);

// Queue many recipients
Expand Down
25 changes: 25 additions & 0 deletions test/AdminRecipientRegistry.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
AdminRecipientRegistryTest
├── when initializing
│ └── it should set admin and zero recipients
├── when queuing a single addition
│ └── it should queue recipient and process correctly
├── when queuing multiple additions
│ └── it should queue and process all recipients
├── when queuing a removal
│ └── it should remove recipient after processing
├── when queuing multiple removals
│ └── it should remove selected recipients
├── when queuing an invalid recipient
│ └── it should revert
├── when queuing a duplicate recipient
│ └── it should revert
├── when removing a non-existent recipient
│ └── it should revert
├── when a non-admin queues addition
│ └── it should revert
├── when a non-admin queues removal
│ └── it should revert
├── when transferring admin
│ └── it should allow new admin and revoke old
└── when performing large scale operations
└── it should handle 100 additions and 50 removals
12 changes: 8 additions & 4 deletions test/BreadKitTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ contract BreadKitTest is TestWrapper {
token.mint{value: 1}(0x0000000000000000000000000000000000000009);
}

function test_mint() public {
// ============ when minting tokens ============

function test_WhenMintingTokens_ShouldUpdateSupplyBalanceAndYieldBacking() public {
uint256 supplyBefore = token.totalSupply();
uint256 balBefore = token.balanceOf(address(this));
uint256 contractBalBefore = IERC20(SX_DAI).balanceOf(address(token));
Expand Down Expand Up @@ -78,7 +80,9 @@ contract BreadKitTest is TestWrapper {
assertEq(token.balanceOf(address(this)), 1.5 ether);
}

function test_finalizeNewYieldClaimer_revertsBeforeTimelock() public {
// ============ when finalizing new yield claimer ============

function test_RevertWhen_FinalizingNewYieldClaimer_GivenTimelockHasNotElapsed() public {
address newClaimer = address(0xCAFE);

token.prepareNewYieldClaimer(newClaimer);
Expand All @@ -90,7 +94,7 @@ contract BreadKitTest is TestWrapper {
token.finalizeNewYieldClaimer();
}

function test_finalizeNewYieldClaimer_succeedsAfterTimelock() public {
function test_WhenFinalizingNewYieldClaimer_GivenTimelockHasElapsed_ShouldUpdateYieldClaimer() public {
address newClaimer = address(0xCAFE);

token.prepareNewYieldClaimer(newClaimer);
Expand All @@ -103,7 +107,7 @@ contract BreadKitTest is TestWrapper {
assertEq(AbstractToken(address(token)).yieldClaimer(), newClaimer);
}

function test_finalizeNewYieldClaimer_clearsPendingState() public {
function test_WhenFinalizingNewYieldClaimer_ShouldClearPendingStateAfterFinalization() public {
address newClaimer = address(0xCAFE);

token.prepareNewYieldClaimer(newClaimer);
Expand Down
9 changes: 9 additions & 0 deletions test/BreadKitTest.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BreadKitTest
├── when minting tokens
│ └── it should update supply balance and yield backing
└── when finalizing new yield claimer
├── given timelock has not elapsed
│ └── it should revert with TimelockNotElapsed
├── given timelock has elapsed
│ └── it should update yield claimer
└── it should clear pending state after finalization
Loading
Loading