Skip to content

Commit

Permalink
feat: view vs non view properties
Browse files Browse the repository at this point in the history
  • Loading branch information
GalloDaSballo committed Oct 15, 2024
1 parent c4da233 commit 3d192fa
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/recon/properties/GovernanceProperties.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.8.0;

import {BeforeAfter} from "../BeforeAfter.sol";
import {Governance} from "src/Governance.sol";
import {IGovernance} from "src/interfaces/IGovernance.sol";

abstract contract GovernanceProperties is BeforeAfter {

Expand Down Expand Up @@ -45,4 +46,29 @@ abstract contract GovernanceProperties is BeforeAfter {
}
}

// View vs non view must have same results
function property_viewTotalVotesAndStateEquivalency() public {
for(uint8 i; i < deployedInitiatives.length; i++) {
(IGovernance.InitiativeVoteSnapshot memory initiativeSnapshot_view, , bool shouldUpdate) = governance.getInitiativeSnapshotAndState(deployedInitiatives[i]);
(, IGovernance.InitiativeVoteSnapshot memory initiativeVoteSnapshot) = governance.snapshotVotesForInitiative(deployedInitiatives[i]);

eq(initiativeSnapshot_view.votes, initiativeVoteSnapshot.votes, "votes");
eq(initiativeSnapshot_view.forEpoch, initiativeVoteSnapshot.forEpoch, "forEpoch");
eq(initiativeSnapshot_view.lastCountedEpoch, initiativeVoteSnapshot.lastCountedEpoch, "lastCountedEpoch");
eq(initiativeSnapshot_view.vetos, initiativeVoteSnapshot.vetos, "vetos");
}
}

function property_viewCalculateVotingThreshold() public {
(, , bool shouldUpdate) = governance.getTotalVotesAndState();

if(!shouldUpdate) {
// If it's already synched it must match
uint256 latestKnownThreshold = governance.getLatestVotingThreshold();
uint256 calculated = governance.calculateVotingThreshold();
eq(latestKnownThreshold, calculated, "match");
}
}


}

0 comments on commit 3d192fa

Please sign in to comment.