Skip to content

Commit

Permalink
feat: update to add freeze market events, events testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-manuel committed Nov 10, 2023
1 parent c64a86b commit 3bdc955
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/SparkLendFreezerMom.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ contract SparkLendFreezerMom is ISparkLendFreezerMom {

for (uint256 i = 0; i < reserves.length; i++) {
PoolConfiguratorLike(poolConfigurator).setReserveFreeze(reserves[i], true);
emit FreezeMarket(reserves[i]);
}
}

function freezeMarket(address reserve) external override auth {
PoolConfiguratorLike(poolConfigurator).setReserveFreeze(reserve, true);
emit FreezeMarket(reserve);
}

/**********************************************************************************************/
Expand Down
6 changes: 6 additions & 0 deletions src/interfaces/ISparkLendFreezerMom.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ interface ISparkLendFreezerMom {
/*** Events ***/
/**********************************************************************************************/

/**
* @dev Event to log the freezing of a given market in SparkLend.
* @param reserve The address of the market reserve.
*/
event FreezeMarket(address indexed reserve);

/**
* @dev Event to log the setting of a new owner.
* @param oldOwner The address of the previous owner.
Expand Down
65 changes: 65 additions & 0 deletions test/SparkLendFreezerMom.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,69 @@ contract FreezeMarketTests is SparkLendFreezerMomUnitTestBase {

}

contract EventTests is SparkLendFreezerMomUnitTestBase {

event FreezeMarket(address indexed reserve);
event SetOwner(address indexed oldOwner, address indexed newOwner);
event SetAuthority(address indexed oldAuthority, address indexed newAuthority);

function test_setAuthority_eventData() external {
address newAuthority = makeAddr("newAuthority");

vm.prank(owner);
vm.expectEmit(address(freezer));
emit SetAuthority(address(authority), newAuthority);
freezer.setAuthority(newAuthority);
}

function test_setOwner_eventData() external {
address newOwner = makeAddr("newOwner");

vm.prank(owner);
vm.expectEmit(address(freezer));
emit SetOwner(owner, newOwner);
freezer.setOwner(newOwner);
}

function test_freezeMarket_eventData() public {
address caller = makeAddr("caller");
address asset = makeAddr("asset");

authority.__setCanCall(
caller,
address(freezer),
freezer.freezeMarket.selector,
true
);

vm.prank(caller);
emit FreezeMarket(asset);
freezer.freezeMarket(asset);
}

function test_freezeAllMarkets_eventData() public {
address caller = makeAddr("caller");

authority.__setCanCall(
caller,
address(freezer),
freezer.freezeAllMarkets.selector,
true
);

address asset1 = makeAddr("asset1");
address asset2 = makeAddr("asset2");

PoolMock(pool).__addAsset(asset1);
PoolMock(pool).__addAsset(asset2);

vm.prank(caller);
vm.expectEmit(address(freezer));
emit FreezeMarket(asset1);
vm.expectEmit(address(freezer));
emit FreezeMarket(asset2);
freezer.freezeAllMarkets();
}
}


0 comments on commit 3bdc955

Please sign in to comment.