Skip to content

Commit

Permalink
init basic invariants setup
Browse files Browse the repository at this point in the history
  • Loading branch information
haythemsellami committed Jul 1, 2024
1 parent 76bef1d commit f8269f8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ call_override = false
dictionary_weight = 80
include_storage = true
include_push_bytes = true
match_test = "invariant_"

[profile.coverage]
via_ir = true
Expand Down
32 changes: 32 additions & 0 deletions test/invariant/EulerAggregationLayerInvariants.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {
EulerAggregationLayerBase,
EulerAggregationLayer,
IWithdrawalQueue
} from "../common/EulerAggregationLayerBase.t.sol";

contract EulerAggregationLayerInvariants is EulerAggregationLayerBase {
function setUp() public override {
super.setUp();

targetContract(address(eulerAggregationLayer));
}

function invariant_totalAllocationPoints() public view {
address withdrawalQueueAddr = eulerAggregationLayer.withdrawalQueue();

(address[] memory withdrawalQueueArray, uint256 withdrawalQueueLength) =
IWithdrawalQueue(withdrawalQueueAddr).getWithdrawalQueueArray();

uint256 expectedTotalAllocationpoints;
expectedTotalAllocationpoints += (eulerAggregationLayer.getStrategy(address(0))).allocationPoints;
for (uint256 i; i < withdrawalQueueLength; i++) {
expectedTotalAllocationpoints +=
(eulerAggregationLayer.getStrategy(withdrawalQueueArray[i])).allocationPoints;
}

assertEq(eulerAggregationLayer.totalAllocationPoints(), expectedTotalAllocationpoints);
}
}

0 comments on commit f8269f8

Please sign in to comment.