Skip to content

[contracts] LiquidationExecuted selector computed from inline string — breaks silently on event signature change #273

@obchain

Description

@obchain

Refs #53

File: contracts/test/CharonLiquidatorFork.t.sol, _assertHappyPath(), selector computation

Code:
bytes32 expectedSelector = keccak256("LiquidationExecuted(address,address,uint256,uint256)");

Problem:
The selector is computed from a hardcoded ABI string. If CharonLiquidator.LiquidationExecuted gains or loses a field, this string becomes stale. Solidity will not produce a compile error; the test will simply fail to find the event and report 'LiquidationExecuted not emitted' — hiding the real diagnosis (event signature mismatch).

Additionally, this pattern is more error-prone to type. The canonical form must include exact parameter types including uint256 not uint and address not address payable.

Fix:
Use Foundry's vm.expectEmit() approach or reference the selector via the import:

vm.expectEmit(true, true, false, false, address(liquidator));
emit CharonLiquidator.LiquidationExecuted(borrower, m.debtToken, m.repayAmount, 0);
liquidator.executeLiquidation(_params(m));

This approach is compile-time checked: any signature change to LiquidationExecuted causes a build failure rather than a silent test misfire.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions