mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-23 15:33:08 +00:00
marketplace: remove fuzzing
replaced by formal verification with certora
This commit is contained in:
parent
13b4038d35
commit
d95863bce8
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@ -32,11 +32,6 @@ jobs:
|
||||
node-version: 18.15
|
||||
- run: npm install
|
||||
- run: npm test
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: fuzzing/corpus
|
||||
key: fuzzing
|
||||
- run: npm run fuzz
|
||||
|
||||
verify:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@ -14,10 +14,6 @@ To run the tests, execute the following commands:
|
||||
npm install
|
||||
npm test
|
||||
|
||||
You can also run fuzzing tests (using [Echidna][echidna]) on the contracts:
|
||||
|
||||
npm run fuzz
|
||||
|
||||
To start a local Ethereum node with the contracts deployed, execute:
|
||||
|
||||
npm start
|
||||
|
||||
@ -1,37 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.28;
|
||||
|
||||
import "./TestToken.sol";
|
||||
import "./Marketplace.sol";
|
||||
import "./Vault.sol";
|
||||
import "./TestVerifier.sol";
|
||||
|
||||
contract FuzzMarketplace is Marketplace {
|
||||
constructor()
|
||||
Marketplace(
|
||||
MarketplaceConfig(
|
||||
CollateralConfig(10, 5, 10, 20),
|
||||
ProofConfig(10, 5, 64, 67, ""),
|
||||
SlotReservationsConfig(20),
|
||||
Duration.wrap(60 * 60 * 24 * 30) // 30 days
|
||||
),
|
||||
new Vault(new TestToken()),
|
||||
new TestVerifier()
|
||||
)
|
||||
{}
|
||||
|
||||
// Properties to be tested through fuzzing
|
||||
|
||||
MarketplaceTotals private _lastSeenTotals;
|
||||
|
||||
function neverDecreaseTotals() public {
|
||||
assert(_marketplaceTotals.received >= _lastSeenTotals.received);
|
||||
assert(_marketplaceTotals.sent >= _lastSeenTotals.sent);
|
||||
_lastSeenTotals = _marketplaceTotals;
|
||||
}
|
||||
|
||||
function neverLoseFunds() public view {
|
||||
uint256 total = _marketplaceTotals.received - _marketplaceTotals.sent;
|
||||
assert(token().balanceOf(address(this)) >= total);
|
||||
}
|
||||
}
|
||||
3
fuzzing/corpus/.gitignore
vendored
3
fuzzing/corpus/.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
*
|
||||
!.gitignore
|
||||
!.keep
|
||||
@ -1,11 +0,0 @@
|
||||
# configure Echidna fuzzing tests
|
||||
|
||||
testMode: "assertion" # check that solidity asserts are never triggered
|
||||
allContracts: true # allow calls to e.g. TestToken in test scenarios
|
||||
format: "text" # disable interactive ui
|
||||
|
||||
# For a longer test run, consider these options:
|
||||
# timeout: 3600 # limit test run to one hour
|
||||
# testLimit: 100000000000 # do not limit the amount of test sequences
|
||||
# stopOnFail: true # stop on first failure
|
||||
# workers: 8 # use more cpu cores
|
||||
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
root=$(cd $(dirname "$0")/.. && pwd)
|
||||
arch=$(arch)
|
||||
|
||||
if command -v echidna; then
|
||||
fuzz () {
|
||||
echidna ${root} \
|
||||
--config ${root}/fuzzing/echidna.yaml \
|
||||
--corpus-dir ${root}/fuzzing/corpus \
|
||||
--crytic-args --ignore-compile \
|
||||
--contract $1
|
||||
}
|
||||
elif [ "${arch}" = "x86_64" ]; then
|
||||
fuzz () {
|
||||
docker run \
|
||||
--rm \
|
||||
-v ${root}:/src ghcr.io/crytic/echidna/echidna \
|
||||
bash -c \
|
||||
"cd /src && echidna . \
|
||||
--config fuzzing/echidna.yaml \
|
||||
--corpus-dir fuzzing/corpus \
|
||||
--crytic-args --ignore-compile \
|
||||
--contract $1"
|
||||
}
|
||||
else
|
||||
echo "Error: echidna not found, and the docker image does not support ${arch}"
|
||||
echo "Please install echidna: https://github.com/crytic/echidna#installation"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fuzz FuzzMarketplace
|
||||
@ -3,7 +3,6 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "npm run lint && hardhat test",
|
||||
"fuzz": "hardhat compile && fuzzing/fuzz.sh",
|
||||
"start": "hardhat node --export deployment-localhost.json",
|
||||
"compile": "hardhat compile",
|
||||
"format": "prettier --write contracts/*.sol contracts/**/*.sol test/**/*.js",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user