Skip to content

Commit

Permalink
fix: BI04
Browse files Browse the repository at this point in the history
  • Loading branch information
GalloDaSballo committed Oct 19, 2024
1 parent 29b8b76 commit 295ac1a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
36 changes: 36 additions & 0 deletions test/recon/CryticToFoundry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.0;
import {Test} from "forge-std/Test.sol";
import {TargetFunctions} from "./TargetFunctions.sol";
import {FoundryAsserts} from "@chimera/FoundryAsserts.sol";
import {IBribeInitiative} from "src/interfaces/IBribeInitiative.sol";

import {console} from "forge-std/console.sol";

Expand Down Expand Up @@ -35,6 +36,41 @@ contract CryticToFoundry is Test, TargetFunctions, FoundryAsserts {
property_BI04();
}

// forge test --match-test test_property_BI04_0 -vv
function test_property_BI04_0() public {

governance_depositLQTY(2);

vm.roll(block.number + 1);
vm.warp(block.timestamp + 794178);
check_skip_consistecy(0);

IBribeInitiative initiative = IBribeInitiative(_getDeployedInitiative(0));

(uint88 totalLQTYAllocatedAtEpochPrev, ) = initiative.totalLQTYAllocatedByEpoch(governance.epoch());
vm.roll(block.number + 1);
vm.warp(block.timestamp + 1022610);

governance_allocateLQTY_clamped_single_initiative(0,1,0);

(uint88 totalLQTYAllocatedAtEpoch, ) = initiative.totalLQTYAllocatedByEpoch(governance.epoch());
(
uint88 voteLQTY,
,
,
,

) = governance.initiativeStates(_getDeployedInitiative(0));

check_unregisterable_consistecy(0);

console.log("totalLQTYAllocatedAtEpochPrev", totalLQTYAllocatedAtEpochPrev);
console.log("totalLQTYAllocatedAtEpoch", totalLQTYAllocatedAtEpoch);
console.log("voteLQTY", voteLQTY);

property_BI04();
}

// forge test --match-test test_property_BI11_3 -vv
function test_property_BI11_3() public {

Expand Down
19 changes: 16 additions & 3 deletions test/recon/properties/BribeInitiativeProperties.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ function property_BI04() public {
for(uint8 i; i < deployedInitiatives.length; i++) {
IBribeInitiative initiative = IBribeInitiative(deployedInitiatives[i]);

// NOTE: This can revert if no changes happen in an epoch | That's ok
(uint88 totalLQTYAllocatedAtEpoch, ) = initiative.totalLQTYAllocatedByEpoch(currentEpoch);
// NOTE: This doesn't revert in the future!
uint88 lastKnownLQTYAlloc = _getLastLQTYAllocationKnown(initiative, currentEpoch);

// We compare when we don't get a revert (a change happened this epoch)

Expand All @@ -82,10 +82,23 @@ function property_BI04() public {



eq(totalLQTYAllocatedAtEpoch, voteLQTY, "BI-04: Initiative Account matches governace");
eq(lastKnownLQTYAlloc, voteLQTY, "BI-04: Initiative Account matches governace");
}
}

function _getLastLQTYAllocationKnown(IBribeInitiative initiative, uint16 targetEpoch) internal returns (uint88) {
uint16 currenEpoch;
uint88 found;
while(currenEpoch <= targetEpoch) {
(uint88 totalLQTYAllocatedAtEpoch, uint32 ts) = initiative.totalLQTYAllocatedByEpoch(currenEpoch++);
if(ts != 0) {
found = totalLQTYAllocatedAtEpoch;
}
}

return found;
}

function property_BI05() public {
// users can't claim for current epoch so checking for previous
uint16 checkEpoch = governance.epoch() - 1;
Expand Down

0 comments on commit 295ac1a

Please sign in to comment.