Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
0f8fc58a
Unverified
Commit
0f8fc58a
authored
Dec 01, 2022
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ctb: Add echidna tests for Burn
parent
1594678e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
0 deletions
+69
-0
pretty-chicken-rest.md
.changeset/pretty-chicken-rest.md
+6
-0
config.yml
.circleci/config.yml
+4
-0
FuzzBurn.sol
packages/contracts-bedrock/contracts/echidna/FuzzBurn.sol
+59
-0
No files found.
.changeset/pretty-chicken-rest.md
0 → 100644
View file @
0f8fc58a
---
'
@eth-optimism/ci-builder'
:
patch
'
@eth-optimism/contracts-bedrock'
:
patch
---
Add echidna tests for Burn
.circleci/config.yml
View file @
0f8fc58a
...
@@ -817,6 +817,10 @@ workflows:
...
@@ -817,6 +817,10 @@ workflows:
echidna_target
:
aliasing
echidna_target
:
aliasing
requires
:
requires
:
-
bedrock-echidna-build
-
bedrock-echidna-build
-
bedrock-echidna-run
:
echidna_target
:
burn
requires
:
-
bedrock-echidna-build
-
op-bindings-build
:
-
op-bindings-build
:
requires
:
requires
:
-
yarn-monorepo
-
yarn-monorepo
...
...
packages/contracts-bedrock/contracts/echidna/FuzzBurn.sol
0 → 100644
View file @
0f8fc58a
pragma solidity 0.8.15;
import { Burn } from "../libraries/Burn.sol";
contract EchidnaFuzzBurn {
bool failedEthBurn;
bool failedGasBurn;
/**
* @notice Takes an integer amount of eth to burn through the Burn library and
* updates the contract state if an incorrect amount of eth moved from the contract
*/
function testBurn(uint256 _value) public {
// cache the contract's eth balance
uint256 preBurnBalance = address(this).balance;
// execute a burn of _value eth
// (may way to add guardrails to this value rather than a truly unbounded uint256)
Burn.eth(_value);
// check that exactly _value eth was transfered from the contract
if (address(this).balance != preBurnBalance - _value) {
failedEthBurn = true;
}
}
/**
* @notice Takes an integer amount of gas to burn through the Burn library and
* updates the contract state if at least that amount of gas was not burned
* by the library
*/
function testGas(uint256 _value) public {
// cache the contract's current remaining gas
uint256 preBurnGas = gasleft();
// execute the gas burn
Burn.gas(_value);
// cache the remaining gas post burn
uint256 postBurnGas = gasleft();
// check that at least _value gas was burnt
if (postBurnGas > preBurnGas - _value) {
failedGasBurn = true;
}
}
function echidna_burn_eth() public view returns (bool) {
// ASSERTION: The amount burned should always match the amount passed exactly
return !failedEthBurn;
}
function echidna_burn_gas() public view returns (bool) {
// ASSERTION: The amount of gas burned should be strictly greater than the
// the amount passed as _value (minimum _value + whatever minor overhead to
// the value after the call)
return !failedGasBurn;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment