Skip to content

Commit

Permalink
refactor: using Given keyword in branching Trees (#641)
Browse files Browse the repository at this point in the history
* Using Given keyword on the branching trees

(cherry picked from commit d365705)

* test: use "it" for test nodes

---------

Co-authored-by: Paul Razvan Berg <paul.razvan.berg@gmail.com>
  • Loading branch information
smol-ninja and PaulRBerg authored Jul 31, 2023
1 parent b5d02b7 commit f4a0731
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ contract SetProtocolFee_Integration_Concrete_Test is Integration_Test {
}

/// @dev The Admin is the default caller in the comptroller tests.
modifier whenCallerAdmin() {
modifier givenCallerAdmin() {
_;
}

function test_SetProtocolFee_SameFee() external whenCallerAdmin {
function test_SetProtocolFee_SameFee() external givenCallerAdmin {
// Expect the relevant event to be emitted.
vm.expectEmit({ emitter: address(comptroller) });
emit SetProtocolFee({ admin: users.admin, asset: dai, oldProtocolFee: ZERO, newProtocolFee: ZERO });
Expand All @@ -40,7 +40,7 @@ contract SetProtocolFee_Integration_Concrete_Test is Integration_Test {
_;
}

function test_SetProtocolFee() external whenCallerAdmin whenNewFee {
function test_SetProtocolFee() external givenCallerAdmin whenNewFee {
UD60x18 newProtocolFee = defaults.FLASH_FEE();

// Expect the relevant event to be emitted.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
setProtocolFee.t.sol
├── when the caller is not the admin
├── given the caller is not the admin
│ └── it should revert
└── when the caller is the admin
└── given the caller is the admin
├── when the new protocol fee is the same as the current protocol fee
│ ├── it should re-set the protocol fee
│ └── it should emit a {SetProtocolFee} event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ contract ToggleFlashAsset_Integration_Concrete_Test is Integration_Test {
}

/// @dev The admin is the default caller in the comptroller tests.
modifier whenCallerAdmin() {
modifier givenCallerAdmin() {
_;
}

function test_ToggleFlashAsset_FlagNotEnabled() external whenCallerAdmin {
function test_ToggleFlashAsset_FlagNotEnabled() external givenCallerAdmin {
// Expect the relevant event to be emitted.
vm.expectEmit({ emitter: address(comptroller) });
emit ToggleFlashAsset({ admin: users.admin, asset: dai, newFlag: true });
Expand All @@ -38,7 +38,7 @@ contract ToggleFlashAsset_Integration_Concrete_Test is Integration_Test {
_;
}

function test_ToggleFlashAsset() external whenCallerAdmin whenFlagEnabled {
function test_ToggleFlashAsset() external givenCallerAdmin whenFlagEnabled {
// Expect the relevant event to be emitted.
vm.expectEmit({ emitter: address(comptroller) });
emit ToggleFlashAsset({ admin: users.admin, asset: dai, newFlag: false });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
toggleFlashAsset.t.sol
├── when the caller is not the admin
├── given the caller is not the admin
│ └── it should revert
└── when the caller is the admin
└── given the caller is the admin
├── when the flag is not enabled
│ ├── it should toggle the flash asset
│ └── it should emit a {ToggleFlashAsset} event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ contract TransferAdmin_Unit_Concrete_Test is Adminable_Unit_Shared_Test {
adminableMock.transferAdmin(users.eve);
}

modifier whenCallerAdmin() {
modifier givenCallerAdmin() {
_;
}

function test_TransferAdmin_SameAdmin() external whenCallerAdmin {
function test_TransferAdmin_SameAdmin() external givenCallerAdmin {
// Expect the relevant event to be emitted.
vm.expectEmit({ emitter: address(adminableMock) });
emit TransferAdmin({ oldAdmin: users.admin, newAdmin: users.admin });
Expand All @@ -33,7 +33,7 @@ contract TransferAdmin_Unit_Concrete_Test is Adminable_Unit_Shared_Test {
assertEq(actualAdmin, expectedAdmin, "admin");
}

function test_TransferAdmin_ZeroAddress() external whenCallerAdmin {
function test_TransferAdmin_ZeroAddress() external givenCallerAdmin {
// Expect the relevant event to be emitted.
vm.expectEmit({ emitter: address(adminableMock) });
emit TransferAdmin({ oldAdmin: users.admin, newAdmin: address(0) });
Expand All @@ -51,7 +51,7 @@ contract TransferAdmin_Unit_Concrete_Test is Adminable_Unit_Shared_Test {
_;
}

function test_TransferAdmin_NewAdmin() external whenCallerAdmin whenNotZeroAddress {
function test_TransferAdmin_NewAdmin() external givenCallerAdmin whenNotZeroAddress {
// Expect the relevant event to be emitted.
vm.expectEmit({ emitter: address(adminableMock) });
emit TransferAdmin({ oldAdmin: users.admin, newAdmin: users.alice });
Expand Down
12 changes: 6 additions & 6 deletions test/unit/concrete/adminable/transfer-admin/transferAdmin.tree
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
transferAdmin.t.sol
├── when the caller is not the admin
├── given the caller is not the admin
│ └── it should revert
└── when the caller is the admin
├── when the admin is the same as the current admin
└── given the caller is the admin
├── when new admin is same as current admin
│ ├── it should re-set the admin
│ └── it should emit a {TransferAdmin} event
└── when the admin is not the same as the current admin
├── when the admin is the zero address
└── when new admin is not same as current admin
├── when the new admin is the zero address
│ ├── it should set the admin to the zero address
│ └── it should emit a {TransferAdmin}
└── when the admin is not the zero address
└── when the new admin is not the zero address
├── it should set the new admin
└── it should emit a {TransferAdmin} event and set the new admin
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ contract SetFlashFee_Unit_Concrete_Test is Comptroller_Unit_Concrete_Test {
}

/// @dev The admin is the default caller in the comptroller tests.
modifier whenCallerAdmin() {
modifier givenCallerAdmin() {
_;
}

function test_SetFlashFee_SameFee() external whenCallerAdmin {
function test_SetFlashFee_SameFee() external givenCallerAdmin {
// Expect the relevant event to be emitted.
vm.expectEmit({ emitter: address(comptroller) });
emit SetFlashFee({ admin: users.admin, oldFlashFee: ZERO, newFlashFee: ZERO });
Expand All @@ -47,7 +47,7 @@ contract SetFlashFee_Unit_Concrete_Test is Comptroller_Unit_Concrete_Test {
_;
}

function test_SetFlashFee() external whenCallerAdmin whenNewFee {
function test_SetFlashFee() external givenCallerAdmin whenNewFee {
UD60x18 newFlashFee = defaults.FLASH_FEE();

// Expect the relevant event to be emitted.
Expand Down
4 changes: 2 additions & 2 deletions test/unit/concrete/comptroller/set-flash-fee/setFlashFee.tree
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
setFlashFee.t.sol
├── when the caller is not the admin
├── given the caller is not the admin
│ └── it should revert
└── when the caller is the admin
└── given the caller is the admin
├── when the new flash fee is the same as the current flash fee
│ ├── it should re-set the flash fee
│ └── it should emit a {SetFlashFee} event
Expand Down

0 comments on commit f4a0731

Please sign in to comment.