From f8269f8a8ff6b2066749d85960517762466214e6 Mon Sep 17 00:00:00 2001 From: Haythem Sellami <17862704+haythemsellami@users.noreply.github.com> Date: Mon, 1 Jul 2024 13:20:16 +0300 Subject: [PATCH] init basic invariants setup --- foundry.toml | 1 + .../EulerAggregationLayerInvariants.t.sol | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 test/invariant/EulerAggregationLayerInvariants.t.sol diff --git a/foundry.toml b/foundry.toml index 401821aa..82ad47cc 100644 --- a/foundry.toml +++ b/foundry.toml @@ -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 diff --git a/test/invariant/EulerAggregationLayerInvariants.t.sol b/test/invariant/EulerAggregationLayerInvariants.t.sol new file mode 100644 index 00000000..564cdb30 --- /dev/null +++ b/test/invariant/EulerAggregationLayerInvariants.t.sol @@ -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); + } +}