forked from codex-storage/codex-contracts-eth
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add harness and marketplace totals rules
- Loading branch information
1 parent
0211ea2
commit 9a342eb
Showing
3 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.8; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import {Marketplace} from "../../contracts/Marketplace.sol"; | ||
import {MarketplaceConfig} from "../../contracts/Configuration.sol"; | ||
|
||
contract MarketplaceHarness is Marketplace { | ||
constructor(IERC20 token_, MarketplaceConfig memory configuration) Marketplace(token_, configuration) {} | ||
|
||
function totalReceived() public view returns (uint256) { | ||
return _marketplaceTotals.received; | ||
} | ||
|
||
function totalSent() public view returns (uint256) { | ||
return _marketplaceTotals.sent; | ||
} | ||
|
||
function tokenBalance() public view returns (uint256) { | ||
return token.balanceOf(address(this)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
rule test { | ||
assert(true); | ||
methods { | ||
function totalReceived() external returns (uint) envfree; | ||
function totalSent() external returns (uint) envfree; | ||
function tokenBalance() external returns (uint) envfree; | ||
} | ||
|
||
rule sanity(env e, method f) { | ||
calldataarg args; | ||
f(e, args); | ||
satisfy true; | ||
} | ||
|
||
rule totalReceivedCannotDecrease(env e, method f) { | ||
mathint total_before = totalReceived(); | ||
|
||
calldataarg args; | ||
f(e, args); | ||
|
||
mathint total_after = totalReceived(); | ||
|
||
assert total_after >= total_before; | ||
} | ||
|
||
rule totalSentCannotDecrease(env e, method f) { | ||
mathint total_before = totalSent(); | ||
|
||
calldataarg args; | ||
f(e, args); | ||
|
||
mathint total_after = totalSent(); | ||
|
||
assert total_after >= total_before; | ||
} |