├── .cargo └── config.toml ├── .config └── nextest.toml ├── .dockerignore ├── .git-blame-ignore-revs ├── .gitattributes ├── .github ├── CODEOWNERS ├── INTEGRATION_FAILURE.md ├── ISSUE_TEMPLATE │ ├── BUG-FORM.yml │ ├── FEATURE-FORM.yml │ └── config.yml ├── PULL_REQUEST_TEMPLATE.md ├── RELEASE_FAILURE_ISSUE_TEMPLATE.md ├── changelog.json ├── compilation-benchmark.png ├── demo.gif ├── logo.png ├── scripts │ ├── create-tag.js │ ├── matrices.py │ ├── move-tag.js │ └── prune-prereleases.js └── workflows │ ├── bump-forge-std.yml │ ├── deny.yml │ ├── dependencies.yml │ ├── docker-publish.yml │ ├── nextest.yml │ ├── release.yml │ ├── test-isolate.yml │ └── test.yml ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── Dockerfile ├── FUNDING.json ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── clippy.toml ├── crates ├── anvil │ ├── Cargo.toml │ ├── README.md │ ├── build.rs │ ├── core │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── eth │ │ │ ├── block.rs │ │ │ ├── bundle.rs │ │ │ ├── mod.rs │ │ │ ├── proof.rs │ │ │ ├── serde_helpers.rs │ │ │ ├── subscription.rs │ │ │ ├── transaction │ │ │ │ ├── mod.rs │ │ │ │ └── optimism.rs │ │ │ ├── trie.rs │ │ │ └── utils.rs │ │ │ ├── lib.rs │ │ │ └── types.rs │ ├── rpc │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── error.rs │ │ │ ├── lib.rs │ │ │ ├── request.rs │ │ │ └── response.rs │ ├── server │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── config.rs │ │ │ ├── error.rs │ │ │ ├── handler.rs │ │ │ ├── ipc.rs │ │ │ ├── lib.rs │ │ │ ├── pubsub.rs │ │ │ └── ws.rs │ ├── src │ │ ├── anvil.rs │ │ ├── cmd.rs │ │ ├── config.rs │ │ ├── eth │ │ │ ├── api.rs │ │ │ ├── backend │ │ │ │ ├── cheats.rs │ │ │ │ ├── db.rs │ │ │ │ ├── executor.rs │ │ │ │ ├── fork.rs │ │ │ │ ├── genesis.rs │ │ │ │ ├── info.rs │ │ │ │ ├── mem │ │ │ │ │ ├── cache.rs │ │ │ │ │ ├── fork_db.rs │ │ │ │ │ ├── in_memory_db.rs │ │ │ │ │ ├── inspector.rs │ │ │ │ │ ├── mod.rs │ │ │ │ │ ├── state.rs │ │ │ │ │ └── storage.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── notifications.rs │ │ │ │ ├── time.rs │ │ │ │ └── validate.rs │ │ │ ├── error.rs │ │ │ ├── fees.rs │ │ │ ├── macros.rs │ │ │ ├── miner.rs │ │ │ ├── mod.rs │ │ │ ├── otterscan │ │ │ │ ├── api.rs │ │ │ │ └── mod.rs │ │ │ ├── pool │ │ │ │ ├── mod.rs │ │ │ │ └── transactions.rs │ │ │ ├── sign.rs │ │ │ └── util.rs │ │ ├── evm.rs │ │ ├── filter.rs │ │ ├── hardfork.rs │ │ ├── lib.rs │ │ ├── logging.rs │ │ ├── pubsub.rs │ │ ├── server │ │ │ ├── error.rs │ │ │ ├── handler.rs │ │ │ └── mod.rs │ │ ├── service.rs │ │ ├── shutdown.rs │ │ └── tasks │ │ │ ├── block_listener.rs │ │ │ └── mod.rs │ ├── test-data │ │ ├── SimpleStorage.json │ │ ├── SimpleStorage.sol │ │ ├── emit_logs.json │ │ ├── emit_logs.sol │ │ ├── greeter.json │ │ ├── multicall.json │ │ ├── multicall.sol │ │ └── storage_sample.json │ └── tests │ │ └── it │ │ ├── abi.rs │ │ ├── anvil.rs │ │ ├── anvil_api.rs │ │ ├── api.rs │ │ ├── eip4844.rs │ │ ├── fork.rs │ │ ├── gas.rs │ │ ├── genesis.rs │ │ ├── ipc.rs │ │ ├── logs.rs │ │ ├── main.rs │ │ ├── optimism.rs │ │ ├── otterscan.rs │ │ ├── proof.rs │ │ ├── pubsub.rs │ │ ├── revert.rs │ │ ├── sign.rs │ │ ├── state.rs │ │ ├── traces.rs │ │ ├── transaction.rs │ │ ├── txpool.rs │ │ ├── utils.rs │ │ └── wsapi.rs ├── cast │ ├── Cargo.toml │ ├── README.md │ ├── benches │ │ └── vanity.rs │ ├── bin │ │ ├── cmd │ │ │ ├── access_list.rs │ │ │ ├── bind.rs │ │ │ ├── call.rs │ │ │ ├── create2.rs │ │ │ ├── estimate.rs │ │ │ ├── find_block.rs │ │ │ ├── interface.rs │ │ │ ├── logs.rs │ │ │ ├── mktx.rs │ │ │ ├── mod.rs │ │ │ ├── rpc.rs │ │ │ ├── run.rs │ │ │ ├── send.rs │ │ │ ├── storage.rs │ │ │ └── wallet │ │ │ │ ├── list.rs │ │ │ │ ├── mod.rs │ │ │ │ └── vanity.rs │ │ ├── main.rs │ │ ├── opts.rs │ │ └── tx.rs │ ├── build.rs │ ├── src │ │ ├── base.rs │ │ ├── errors.rs │ │ ├── lib.rs │ │ └── rlp_converter.rs │ └── tests │ │ ├── cli │ │ └── main.rs │ │ └── fixtures │ │ ├── ERC20Artifact.json │ │ ├── cast_logs.stdout │ │ ├── interface.json │ │ ├── keystore │ │ ├── UTC--2022-10-30T06-51-20.130356000Z--560d246fcddc9ea98a8b032c9a2f474efb493c28 │ │ ├── UTC--2022-12-20T10-30-43.591916000Z--ec554aeafe75601aaab43bd4621a22284db566c2 │ │ ├── password │ │ └── password-ec554 │ │ └── sign_typed_data.json ├── cheatcodes │ ├── Cargo.toml │ ├── README.md │ ├── assets │ │ ├── cheatcodes.json │ │ └── cheatcodes.schema.json │ ├── spec │ │ ├── Cargo.toml │ │ ├── README.md │ │ └── src │ │ │ ├── cheatcode.rs │ │ │ ├── function.rs │ │ │ ├── items.rs │ │ │ ├── lib.rs │ │ │ └── vm.rs │ └── src │ │ ├── base64.rs │ │ ├── config.rs │ │ ├── env.rs │ │ ├── error.rs │ │ ├── evm.rs │ │ ├── evm │ │ ├── fork.rs │ │ ├── mapping.rs │ │ ├── mock.rs │ │ └── prank.rs │ │ ├── fs.rs │ │ ├── inspector.rs │ │ ├── inspector │ │ └── utils.rs │ │ ├── json.rs │ │ ├── lib.rs │ │ ├── script.rs │ │ ├── string.rs │ │ ├── test.rs │ │ ├── test │ │ ├── assert.rs │ │ └── expect.rs │ │ ├── toml.rs │ │ └── utils.rs ├── chisel │ ├── Cargo.toml │ ├── README.md │ ├── assets │ │ ├── preview.gif │ │ └── preview.tape │ ├── benches │ │ └── session_source.rs │ ├── bin │ │ └── main.rs │ ├── build.rs │ ├── src │ │ ├── cmd.rs │ │ ├── dispatcher.rs │ │ ├── executor.rs │ │ ├── history.rs │ │ ├── lib.rs │ │ ├── runner.rs │ │ ├── session.rs │ │ ├── session_source.rs │ │ └── solidity_helper.rs │ └── tests │ │ └── cache.rs ├── cli │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── handler.rs │ │ ├── lib.rs │ │ ├── opts │ │ ├── build │ │ │ ├── core.rs │ │ │ ├── mod.rs │ │ │ └── paths.rs │ │ ├── chain.rs │ │ ├── dependency.rs │ │ ├── ethereum.rs │ │ ├── mod.rs │ │ └── transaction.rs │ │ ├── stdin.rs │ │ └── utils │ │ ├── abi.rs │ │ ├── cmd.rs │ │ ├── mod.rs │ │ └── suggestions.rs ├── common │ ├── Cargo.toml │ ├── README.md │ ├── fmt │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── console.rs │ │ │ ├── dynamic.rs │ │ │ ├── exp.rs │ │ │ ├── lib.rs │ │ │ └── ui.rs │ └── src │ │ ├── abi.rs │ │ ├── calc.rs │ │ ├── compile.rs │ │ ├── constants.rs │ │ ├── contracts.rs │ │ ├── ens.rs │ │ ├── errors │ │ ├── artifacts.rs │ │ ├── fs.rs │ │ └── mod.rs │ │ ├── evm.rs │ │ ├── fs.rs │ │ ├── lib.rs │ │ ├── provider │ │ ├── mod.rs │ │ └── runtime_transport.rs │ │ ├── retry.rs │ │ ├── selectors.rs │ │ ├── serde_helpers.rs │ │ ├── shell.rs │ │ ├── term.rs │ │ ├── traits.rs │ │ ├── transactions.rs │ │ └── utils.rs ├── config │ ├── Cargo.toml │ ├── README.md │ └── src │ │ ├── bind_json.rs │ │ ├── cache.rs │ │ ├── doc.rs │ │ ├── endpoints.rs │ │ ├── error.rs │ │ ├── etherscan.rs │ │ ├── filter.rs │ │ ├── fix.rs │ │ ├── fmt.rs │ │ ├── fs_permissions.rs │ │ ├── fuzz.rs │ │ ├── inline │ │ ├── conf_parser.rs │ │ ├── error.rs │ │ ├── mod.rs │ │ └── natspec.rs │ │ ├── invariant.rs │ │ ├── lib.rs │ │ ├── macros.rs │ │ ├── providers │ │ ├── mod.rs │ │ └── remappings.rs │ │ ├── resolve.rs │ │ ├── soldeer.rs │ │ ├── utils.rs │ │ ├── vyper.rs │ │ └── warning.rs ├── debugger │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ ├── node.rs │ │ ├── op.rs │ │ └── tui │ │ ├── builder.rs │ │ ├── context.rs │ │ ├── draw.rs │ │ └── mod.rs ├── doc │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── builder.rs │ │ ├── document.rs │ │ ├── helpers.rs │ │ ├── lib.rs │ │ ├── parser │ │ │ ├── comment.rs │ │ │ ├── error.rs │ │ │ ├── item.rs │ │ │ └── mod.rs │ │ ├── preprocessor │ │ │ ├── contract_inheritance.rs │ │ │ ├── deployments.rs │ │ │ ├── git_source.rs │ │ │ ├── infer_hyperlinks.rs │ │ │ ├── inheritdoc.rs │ │ │ └── mod.rs │ │ └── writer │ │ │ ├── as_doc.rs │ │ │ ├── buf_writer.rs │ │ │ ├── markdown.rs │ │ │ ├── mod.rs │ │ │ └── traits.rs │ └── static │ │ ├── book.css │ │ ├── book.toml │ │ └── solidity.min.js ├── evm │ ├── abi │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── HardhatConsole.json │ │ │ ├── console.py │ │ │ ├── console │ │ │ ├── hardhat.rs │ │ │ ├── mod.rs │ │ │ └── patches.rs │ │ │ └── lib.rs │ ├── core │ │ ├── Cargo.toml │ │ ├── src │ │ │ ├── backend │ │ │ │ ├── cow.rs │ │ │ │ ├── diagnostic.rs │ │ │ │ ├── error.rs │ │ │ │ ├── in_memory_db.rs │ │ │ │ ├── mod.rs │ │ │ │ └── snapshot.rs │ │ │ ├── constants.rs │ │ │ ├── decode.rs │ │ │ ├── fork │ │ │ │ ├── database.rs │ │ │ │ ├── init.rs │ │ │ │ ├── mod.rs │ │ │ │ └── multi.rs │ │ │ ├── ic.rs │ │ │ ├── lib.rs │ │ │ ├── opcodes.rs │ │ │ ├── opts.rs │ │ │ ├── precompiles.rs │ │ │ ├── snapshot.rs │ │ │ └── utils.rs │ │ └── test-data │ │ │ └── storage.json │ ├── coverage │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── analysis.rs │ │ │ ├── anchors.rs │ │ │ ├── inspector.rs │ │ │ └── lib.rs │ ├── evm │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── executors │ │ │ ├── builder.rs │ │ │ ├── fuzz │ │ │ │ ├── mod.rs │ │ │ │ └── types.rs │ │ │ ├── invariant │ │ │ │ ├── error.rs │ │ │ │ ├── mod.rs │ │ │ │ ├── replay.rs │ │ │ │ ├── result.rs │ │ │ │ └── shrink.rs │ │ │ ├── mod.rs │ │ │ └── trace.rs │ │ │ ├── inspectors │ │ │ ├── chisel_state.rs │ │ │ ├── logs.rs │ │ │ ├── mod.rs │ │ │ └── stack.rs │ │ │ └── lib.rs │ ├── fuzz │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── error.rs │ │ │ ├── inspector.rs │ │ │ ├── invariant │ │ │ ├── call_override.rs │ │ │ ├── filters.rs │ │ │ └── mod.rs │ │ │ ├── lib.rs │ │ │ └── strategies │ │ │ ├── calldata.rs │ │ │ ├── int.rs │ │ │ ├── invariants.rs │ │ │ ├── mod.rs │ │ │ ├── param.rs │ │ │ ├── state.rs │ │ │ └── uint.rs │ ├── test-data │ │ └── solc-obj.json │ └── traces │ │ ├── Cargo.toml │ │ └── src │ │ ├── debug │ │ ├── mod.rs │ │ └── sources.rs │ │ ├── decoder │ │ ├── mod.rs │ │ └── precompiles.rs │ │ ├── identifier │ │ ├── etherscan.rs │ │ ├── local.rs │ │ ├── mod.rs │ │ └── signatures.rs │ │ └── lib.rs ├── fmt │ ├── Cargo.toml │ ├── README.md │ ├── src │ │ ├── buffer.rs │ │ ├── chunk.rs │ │ ├── comments.rs │ │ ├── formatter.rs │ │ ├── helpers.rs │ │ ├── inline_config.rs │ │ ├── lib.rs │ │ ├── macros.rs │ │ ├── solang_ext │ │ │ ├── ast_eq.rs │ │ │ ├── loc.rs │ │ │ ├── mod.rs │ │ │ └── safe_unwrap.rs │ │ ├── string.rs │ │ └── visit.rs │ ├── testdata │ │ ├── Annotation │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ArrayExpressions │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── BlockComments │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── BlockCommentsFunction │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ConditionalOperatorExpression │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ConstructorDefinition │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ConstructorModifierStyle │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ContractDefinition │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── contract-new-lines.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── DoWhileStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── DocComments │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ └── wrap-comments.fmt.sol │ │ ├── EmitStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── EnumDefinition │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── EnumVariants │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ErrorDefinition │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── EventDefinition │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ForStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── FunctionCall │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── FunctionCallArgsStatement │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── FunctionDefinition │ │ │ ├── all.fmt.sol │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── override-spacing.fmt.sol │ │ │ └── params-first.fmt.sol │ │ ├── FunctionDefinitionWithFunctionReturns │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── FunctionType │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── HexUnderscore │ │ │ ├── bytes.fmt.sol │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── preserve.fmt.sol │ │ │ └── remove.fmt.sol │ │ ├── IfStatement │ │ │ ├── block-multi.fmt.sol │ │ │ ├── block-single.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── IfStatement2 │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ImportDirective │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── preserve-quote.fmt.sol │ │ │ └── single-quote.fmt.sol │ │ ├── InlineDisable │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── IntTypes │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── preserve.fmt.sol │ │ │ └── short.fmt.sol │ │ ├── LiteralExpression │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── preserve-quote.fmt.sol │ │ │ └── single-quote.fmt.sol │ │ ├── MappingType │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ModifierDefinition │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ └── override-spacing.fmt.sol │ │ ├── NamedFunctionCallExpression │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── NumberLiteralUnderscore │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── preserve.fmt.sol │ │ │ ├── remove.fmt.sol │ │ │ └── thousands.fmt.sol │ │ ├── OperatorExpressions │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── PragmaDirective │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── Repros │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ReturnStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── RevertNamedArgsStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── RevertStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── SimpleComments │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ └── wrap-comments.fmt.sol │ │ ├── SortedImports │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── StatementBlock │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── StructDefinition │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── ThisExpression │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── TrailingComma │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── TryStatement │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── TypeDefinition │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── UnitExpression │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── UsingDirective │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── VariableAssignment │ │ │ ├── bracket-spacing.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── VariableDefinition │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ └── override-spacing.fmt.sol │ │ ├── WhileStatement │ │ │ ├── block-multi.fmt.sol │ │ │ ├── block-single.fmt.sol │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ ├── Yul │ │ │ ├── fmt.sol │ │ │ └── original.sol │ │ └── YulStrings │ │ │ ├── fmt.sol │ │ │ ├── original.sol │ │ │ ├── preserve-quote.fmt.sol │ │ │ └── single-quote.fmt.sol │ └── tests │ │ └── formatter.rs ├── forge │ ├── Cargo.toml │ ├── README.md │ ├── assets │ │ ├── .gitignoreTemplate │ │ ├── CounterTemplate.s.sol │ │ ├── CounterTemplate.sol │ │ ├── CounterTemplate.t.sol │ │ ├── README.md │ │ ├── generated │ │ │ └── TestTemplate.t.sol │ │ └── workflowTemplate.yml │ ├── benches │ │ └── test.rs │ ├── bin │ │ ├── cmd │ │ │ ├── bind.rs │ │ │ ├── bind_json.rs │ │ │ ├── build.rs │ │ │ ├── cache.rs │ │ │ ├── clone.rs │ │ │ ├── config.rs │ │ │ ├── coverage.rs │ │ │ ├── create.rs │ │ │ ├── debug.rs │ │ │ ├── doc │ │ │ │ ├── mod.rs │ │ │ │ └── server.rs │ │ │ ├── eip712.rs │ │ │ ├── flatten.rs │ │ │ ├── fmt.rs │ │ │ ├── geiger │ │ │ │ ├── error.rs │ │ │ │ ├── find.rs │ │ │ │ ├── mod.rs │ │ │ │ └── visitor.rs │ │ │ ├── generate │ │ │ │ └── mod.rs │ │ │ ├── init.rs │ │ │ ├── inspect.rs │ │ │ ├── install.rs │ │ │ ├── mod.rs │ │ │ ├── remappings.rs │ │ │ ├── remove.rs │ │ │ ├── script │ │ │ │ ├── build.rs │ │ │ │ ├── cmd.rs │ │ │ │ └── executor.rs │ │ │ ├── selectors.rs │ │ │ ├── snapshot.rs │ │ │ ├── soldeer.rs │ │ │ ├── test │ │ │ │ ├── filter.rs │ │ │ │ ├── mod.rs │ │ │ │ └── summary.rs │ │ │ ├── tree.rs │ │ │ ├── update.rs │ │ │ └── watch.rs │ │ ├── main.rs │ │ └── opts.rs │ ├── build.rs │ ├── src │ │ ├── coverage.rs │ │ ├── gas_report.rs │ │ ├── lib.rs │ │ ├── multi_runner.rs │ │ ├── progress.rs │ │ ├── result.rs │ │ └── runner.rs │ └── tests │ │ ├── cli │ │ ├── bind_json.rs │ │ ├── build.rs │ │ ├── cache.rs │ │ ├── cmd.rs │ │ ├── config.rs │ │ ├── constants.rs │ │ ├── context.rs │ │ ├── coverage.rs │ │ ├── create.rs │ │ ├── debug.rs │ │ ├── doc.rs │ │ ├── ext_integration.rs │ │ ├── main.rs │ │ ├── multi_script.rs │ │ ├── script.rs │ │ ├── soldeer.rs │ │ ├── svm.rs │ │ ├── test_cmd.rs │ │ ├── utils.rs │ │ └── verify.rs │ │ ├── fixtures │ │ ├── ScriptVerify.sol │ │ ├── can_build_path_with_one_file.stdout │ │ ├── can_build_path_with_three_files.stdout │ │ ├── can_build_path_with_two_files.stdout │ │ ├── can_build_skip_contracts.stdout │ │ ├── can_build_skip_glob.stdout │ │ ├── can_check_snapshot.stdout │ │ ├── can_detect_dirty_git_status_on_init.stderr │ │ ├── can_execute_script_and_skip_contracts.stdout │ │ ├── can_execute_script_command.stdout │ │ ├── can_execute_script_command_fqn.stdout │ │ ├── can_execute_script_command_with_args.stdout │ │ ├── can_execute_script_command_with_returned.stdout │ │ ├── can_execute_script_command_with_sig.stdout │ │ ├── can_run_test_in_custom_test_folder.stdout │ │ ├── can_set_yul_optimizer.stderr │ │ ├── can_test_repeatedly.stdout │ │ ├── can_use_libs_in_multi_fork.stdout │ │ ├── compile_json.stdout │ │ ├── include_custom_types_in_traces.stdout │ │ ├── replay_last_run_failures.stdout │ │ ├── repro_6531.stdout │ │ ├── runs_tests_exactly_once_with_changed_versions.1.stdout │ │ ├── runs_tests_exactly_once_with_changed_versions.2.stdout │ │ ├── suggest_when_no_tests_match.stdout │ │ ├── warn_no_tests.stdout │ │ └── warn_no_tests_match.stdout │ │ ├── it │ │ ├── cheats.rs │ │ ├── config.rs │ │ ├── core.rs │ │ ├── fork.rs │ │ ├── fs.rs │ │ ├── fuzz.rs │ │ ├── inline.rs │ │ ├── invariant.rs │ │ ├── main.rs │ │ ├── repros.rs │ │ ├── spec.rs │ │ ├── test_helpers.rs │ │ └── vyper.rs │ │ └── rpc-cache-keyfile ├── linking │ ├── Cargo.toml │ └── src │ │ └── lib.rs ├── macros │ ├── Cargo.toml │ └── src │ │ ├── cheatcodes.rs │ │ ├── console_fmt.rs │ │ └── lib.rs ├── script │ ├── Cargo.toml │ └── src │ │ ├── broadcast.rs │ │ ├── build.rs │ │ ├── execute.rs │ │ ├── lib.rs │ │ ├── multi_sequence.rs │ │ ├── progress.rs │ │ ├── providers.rs │ │ ├── receipts.rs │ │ ├── runner.rs │ │ ├── sequence.rs │ │ ├── simulate.rs │ │ ├── transaction.rs │ │ └── verify.rs ├── sol-macro-gen │ ├── Cargo.toml │ └── src │ │ ├── lib.rs │ │ └── sol_macro_gen.rs ├── test-utils │ ├── Cargo.toml │ └── src │ │ ├── fd_lock.rs │ │ ├── filter.rs │ │ ├── lib.rs │ │ ├── macros.rs │ │ ├── rpc.rs │ │ ├── script.rs │ │ └── util.rs ├── verify │ ├── Cargo.toml │ └── src │ │ ├── bytecode.rs │ │ ├── etherscan │ │ ├── flatten.rs │ │ ├── mod.rs │ │ └── standard_json.rs │ │ ├── lib.rs │ │ ├── provider.rs │ │ ├── retry.rs │ │ └── sourcify.rs └── wallets │ ├── Cargo.toml │ └── src │ ├── error.rs │ ├── lib.rs │ ├── multi_wallet.rs │ ├── raw_wallet.rs │ ├── utils.rs │ ├── wallet.rs │ └── wallet_signer.rs ├── deny.toml ├── docs └── dev │ ├── README.md │ ├── architecture.md │ ├── cheatcodes.md │ ├── debugging.md │ └── scripting.md ├── flake.lock ├── flake.nix ├── foundryup ├── README.md ├── foundryup └── install ├── rustfmt.toml └── testdata ├── .gitignore ├── README.md ├── cancun └── cheats │ ├── BlobBaseFee.t.sol │ └── Blobhashes.t.sol ├── cheats └── Vm.sol ├── default ├── cheats │ ├── Addr.t.sol │ ├── Assert.t.sol │ ├── Assume.t.sol │ ├── Bank.t.sol │ ├── Base64.t.sol │ ├── Broadcast.t.sol │ ├── ChainId.t.sol │ ├── Cool.t.sol │ ├── Deal.t.sol │ ├── DeployCode.t.sol │ ├── Derive.t.sol │ ├── EnsNamehash.t.sol │ ├── Env.t.sol │ ├── Etch.t.sol │ ├── ExpectCall.t.sol │ ├── ExpectEmit.t.sol │ ├── ExpectRevert.t.sol │ ├── Fee.t.sol │ ├── Ffi.t.sol │ ├── Fork.t.sol │ ├── Fork2.t.sol │ ├── Fs.t.sol │ ├── GasMetering.t.sol │ ├── GetBlockTimestamp.t.sol │ ├── GetCode.t.sol │ ├── GetDeployedCode.t.sol │ ├── GetLabel.t.sol │ ├── GetNonce.t.sol │ ├── Json.t.sol │ ├── Label.t.sol │ ├── LastCallGas.t.sol │ ├── Load.t.sol │ ├── Mapping.t.sol │ ├── MemSafety.t.sol │ ├── MockCall.t.sol │ ├── Parse.t.sol │ ├── Prank.t.sol │ ├── Prevrandao.t.sol │ ├── ProjectRoot.t.sol │ ├── Prompt.t.sol │ ├── RandomUint.t.sol │ ├── ReadCallers.t.sol │ ├── Record.t.sol │ ├── RecordAccountAccesses.t.sol │ ├── RecordLogs.t.sol │ ├── Remember.t.sol │ ├── ResetNonce.t.sol │ ├── Roll.t.sol │ ├── RpcUrls.t.sol │ ├── SetBlockhash.t.sol │ ├── SetNonce.t.sol │ ├── SetNonceUnsafe.t.sol │ ├── Setup.t.sol │ ├── Sign.t.sol │ ├── SignP256.t.sol │ ├── Skip.t.sol │ ├── Sleep.t.sol │ ├── Snapshots.t.sol │ ├── Store.t.sol │ ├── StringUtils.t.sol │ ├── ToString.t.sol │ ├── Toml.t.sol │ ├── Travel.t.sol │ ├── TryFfi.sol │ ├── UnixTime.t.sol │ ├── Wallet.t.sol │ ├── Warp.t.sol │ ├── dumpState.t.sol │ ├── getBlockNumber.t.sol │ └── loadAllocs.t.sol ├── core │ ├── Abstract.t.sol │ ├── BadSigAfterInvariant.t.sol │ ├── ContractEnvironment.t.sol │ ├── DSStyle.t.sol │ ├── FailingSetup.t.sol │ ├── FailingTestAfterFailedSetup.t.sol │ ├── LegacyAssertions.t.sol │ ├── MultipleAfterInvariant.t.sol │ ├── MultipleSetup.t.sol │ ├── PaymentFailure.t.sol │ ├── Reverting.t.sol │ └── SetupConsistency.t.sol ├── fork │ ├── DssExecLib.sol │ ├── ForkSame_1.t.sol │ ├── ForkSame_2.t.sol │ ├── LaunchFork.t.sol │ └── Transact.t.sol ├── fs │ ├── Default.t.sol │ └── Disabled.t.sol ├── fuzz │ ├── Fuzz.t.sol │ ├── FuzzCollection.t.sol │ ├── FuzzFailurePersist.t.sol │ ├── FuzzInt.t.sol │ ├── FuzzPositive.t.sol │ ├── FuzzScrapeBytecode.t.sol │ ├── FuzzUint.t.sol │ └── invariant │ │ ├── common │ │ ├── InvariantAfterInvariant.t.sol │ │ ├── InvariantAssume.t.sol │ │ ├── InvariantCalldataDictionary.t.sol │ │ ├── InvariantCustomError.t.sol │ │ ├── InvariantExcludedSenders.t.sol │ │ ├── InvariantFixtures.t.sol │ │ ├── InvariantHandlerFailure.t.sol │ │ ├── InvariantInnerContract.t.sol │ │ ├── InvariantPreserveState.t.sol │ │ ├── InvariantReentrancy.t.sol │ │ ├── InvariantRollFork.t.sol │ │ ├── InvariantScrapeValues.t.sol │ │ ├── InvariantSelectorsWeight.t.sol │ │ ├── InvariantSequenceNoReverts.t.sol │ │ ├── InvariantShrinkBigSequence.t.sol │ │ ├── InvariantShrinkFailOnRevert.t.sol │ │ ├── InvariantShrinkWithAssert.t.sol │ │ └── InvariantTest1.t.sol │ │ ├── storage │ │ └── InvariantStorageTest.t.sol │ │ ├── target │ │ ├── ExcludeContracts.t.sol │ │ ├── ExcludeSelectors.t.sol │ │ ├── ExcludeSenders.t.sol │ │ ├── FuzzedTargetContracts.t.sol │ │ ├── TargetContracts.t.sol │ │ ├── TargetInterfaces.t.sol │ │ ├── TargetSelectors.t.sol │ │ └── TargetSenders.t.sol │ │ └── targetAbi │ │ ├── ExcludeArtifacts.t.sol │ │ ├── TargetArtifactSelectors.t.sol │ │ ├── TargetArtifactSelectors2.t.sol │ │ └── TargetArtifacts.t.sol ├── inline │ ├── FuzzInlineConf.t.sol │ └── InvariantInlineConf.t.sol ├── linking │ ├── cycle │ │ └── Cycle.t.sol │ ├── duplicate │ │ └── Duplicate.t.sol │ ├── nested │ │ └── Nested.t.sol │ └── simple │ │ └── Simple.t.sol ├── logs │ ├── DebugLogs.t.sol │ ├── HardhatLogs.t.sol │ └── console.sol ├── repros │ ├── Issue2623.t.sol │ ├── Issue2629.t.sol │ ├── Issue2723.t.sol │ ├── Issue2851.t.sol │ ├── Issue2898.t.sol │ ├── Issue2956.t.sol │ ├── Issue2984.t.sol │ ├── Issue3055.t.sol │ ├── Issue3077.t.sol │ ├── Issue3110.t.sol │ ├── Issue3119.t.sol │ ├── Issue3189.t.sol │ ├── Issue3190.t.sol │ ├── Issue3192.t.sol │ ├── Issue3220.t.sol │ ├── Issue3221.t.sol │ ├── Issue3223.t.sol │ ├── Issue3347.t.sol │ ├── Issue3437.t.sol │ ├── Issue3596.t.sol │ ├── Issue3653.t.sol │ ├── Issue3661.t.sol │ ├── Issue3674.t.sol │ ├── Issue3685.t.sol │ ├── Issue3703.t.sol │ ├── Issue3708.t.sol │ ├── Issue3723.t.sol │ ├── Issue3753.t.sol │ ├── Issue3792.t.sol │ ├── Issue4402.t.sol │ ├── Issue4586.t.sol │ ├── Issue4630.t.sol │ ├── Issue4640.t.sol │ ├── Issue4832.t.sol │ ├── Issue5038.t.sol │ ├── Issue5529.t.sol │ ├── Issue5739.t.sol │ ├── Issue5808.t.sol │ ├── Issue5929.t.sol │ ├── Issue5935.t.sol │ ├── Issue5948.t.sol │ ├── Issue6006.t.sol │ ├── Issue6032.t.sol │ ├── Issue6070.t.sol │ ├── Issue6115.t.sol │ ├── Issue6170.t.sol │ ├── Issue6180.t.sol │ ├── Issue6293.t.sol │ ├── Issue6355.t.sol │ ├── Issue6437.t.sol │ ├── Issue6501.t.sol │ ├── Issue6538.t.sol │ ├── Issue6554.t.sol │ ├── Issue6616.t.sol │ ├── Issue6634.t.sol │ ├── Issue6759.t.sol │ ├── Issue6966.t.sol │ ├── Issue7457.t.sol │ ├── Issue7481.t.sol │ ├── Issue8004.t.sol │ ├── Issue8006.t.sol │ ├── Issue8277.t.sol │ └── Issue8287.t.sol ├── script │ ├── broadcast │ │ └── deploy.sol │ │ │ └── 31337 │ │ │ └── run-latest.json │ └── deploy.sol ├── spec │ └── ShanghaiCompat.t.sol ├── trace │ ├── ConflictingSignatures.t.sol │ └── Trace.t.sol └── vyper │ ├── Counter.vy │ ├── CounterTest.vy │ └── ICounter.vyi ├── etherscan ├── 0x044b75f554b886A065b9567891e45c79542d7357 │ ├── creation_data.json │ └── metadata.json ├── 0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193 │ ├── creation_data.json │ └── metadata.json ├── 0x3a23F943181408EAC424116Af7b7790c94Cb97a5 │ ├── creation_data.json │ └── metadata.json ├── 0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05 │ ├── creation_data.json │ └── metadata.json ├── 0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545 │ ├── creation_data.json │ └── metadata.json ├── 0x9AB6b21cDF116f611110b048987E58894786C244 │ ├── creation_data.json │ └── metadata.json ├── 0x9d27527Ada2CF29fBDAB2973cfa243845a08Bd3F │ ├── creation_data.json │ └── metadata.json └── 0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec │ ├── creation_data.json │ └── metadata.json ├── fixtures ├── Derive │ ├── mnemonic_chinese_simplified.txt │ ├── mnemonic_chinese_traditional.txt │ ├── mnemonic_czech.txt │ ├── mnemonic_english.txt │ ├── mnemonic_french.txt │ ├── mnemonic_italian.txt │ ├── mnemonic_japanese.txt │ ├── mnemonic_korean.txt │ ├── mnemonic_portuguese.txt │ └── mnemonic_spanish.txt ├── Dir │ ├── depth1 │ └── nested │ │ ├── depth2 │ │ └── nested2 │ │ └── depth3 ├── File │ ├── read.txt │ └── symlink ├── GetCode │ ├── HardhatWorkingContract.json │ ├── HuffWorkingContract.json │ ├── Override.json │ ├── Override.sol │ ├── UnlinkedContract.sol │ ├── WorkingContract.json │ └── WorkingContract.sol ├── Json │ ├── Issue4402.json │ ├── Issue4630.json │ ├── nested_json_struct.json │ ├── test.json │ ├── test_allocs.json │ ├── whole_json.json │ ├── write_complex_test.json │ └── write_test.json ├── Rpc │ ├── README.md │ ├── balance_params.json │ └── eth_getLogs.json ├── SolidityGeneration │ ├── Fastlane.json │ ├── GaugeController.json │ ├── GeneratedFastLane.sol │ ├── GeneratedGaugeController.sol │ ├── GeneratedLiquidityGaugeV4.sol │ ├── GeneratedNamedInterface.sol │ ├── GeneratedUnnamedInterface.sol │ ├── InterfaceABI.json │ ├── LiquidityGaugeV4.json │ ├── WithStructs.json │ └── WithStructs.sol ├── Toml │ ├── Issue4402.toml │ ├── test.toml │ ├── whole_toml.toml │ ├── write_complex_test.toml │ └── write_test.toml ├── broadcast.log.json └── broadcast.sensitive.log.json ├── forge-std-rev ├── foundry.toml ├── lib └── ds-test │ └── src │ └── test.sol └── multi-version ├── Counter.sol ├── Importer.sol └── cheats ├── GetCode.t.sol └── GetCode17.t.sol /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | cheats = "test -p foundry-cheatcodes-spec --features schema tests::" 3 | test-debugger = "test -p forge --test cli manual_debug_setup -- --include-ignored --nocapture" 4 | 5 | # Increase the stack size to 10MB for Windows targets, which is in line with Linux 6 | # (whereas default for Windows is 1MB). 7 | [target.x86_64-pc-windows-msvc] 8 | rustflags = ["-Clink-arg=/STACK:10000000"] 9 | 10 | [target.i686-pc-windows-msvc] 11 | rustflags = ["-Clink-arg=/STACK:10000000"] 12 | -------------------------------------------------------------------------------- /.config/nextest.toml: -------------------------------------------------------------------------------- 1 | [profile.default] 2 | retries = { backoff = "exponential", count = 2, delay = "2s", jitter = true } 3 | slow-timeout = { period = "1m", terminate-after = 3 } 4 | 5 | [[profile.default.overrides]] 6 | filter = "test(/ext_integration|can_test_forge_std/)" 7 | slow-timeout = { period = "5m", terminate-after = 4 } 8 | 9 | [[profile.default.overrides]] 10 | filter = "package(foundry-cheatcodes-spec)" 11 | retries = 0 12 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | target 2 | .github 3 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Since version 2.23 (released in August 2019), git-blame has a feature 2 | # to ignore or bypass certain commits. 3 | # 4 | # This file contains a list of commits that are not likely what you 5 | # are looking for in a blame, such as mass reformatting or renaming. 6 | # You can set this file as a default ignore file for blame by running 7 | # the following command. 8 | # 9 | # $ git config blame.ignoreRevsFile .git-blame-ignore-revs 10 | 11 | # fmt: all (#3398) 12 | 860d083183b51a6f8d865408ef1a44aa694d6862 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | crates/cheatcodes/assets/*.json linguist-generated 2 | testdata/cheats/Vm.sol linguist-generated 3 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @danipopes @evalir @mattsse 2 | 3 | crates/anvil/ @danipopes @mattsse @evalir 4 | crates/cheatcodes/ @danipopes @mattsse @klkvr @evalir 5 | crates/evm/coverage/ @onbjerg 6 | crates/fmt/ @rkrasiuk 7 | crates/linking/ @klkvr 8 | crates/macros/ @danipopes 9 | crates/script/ @danipopes @mattsse @klkvr 10 | crates/wallets/ @klkvr 11 | -------------------------------------------------------------------------------- /.github/INTEGRATION_FAILURE.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "bug: long-running integration tests failed" 3 | labels: P-high, T-bug 4 | --- 5 | 6 | The heavy (long-running) integration tests have failed. This indicates a regression in Foundry. 7 | 8 | Check the [heavy integration tests workflow page]({{ env.WORKFLOW_URL }}) for details. 9 | 10 | This issue was raised by the workflow at `.github/workflows/heavy-integration.yml`. 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Support 4 | url: https://t.me/foundry_support 5 | about: This issue tracker is only for bugs and feature requests. Support is available on Telegram! 6 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | ## Motivation 9 | 10 | 15 | 16 | ## Solution 17 | 18 | 22 | -------------------------------------------------------------------------------- /.github/RELEASE_FAILURE_ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "bug: release workflow failed" 3 | labels: P-high, T-bug 4 | --- 5 | 6 | The release workflow has failed. Some or all binaries might have not been published correctly. 7 | 8 | Check the [release workflow page]({{ env.WORKFLOW_URL }}) for details. 9 | 10 | This issue was raised by the workflow at `.github/workflows/release.yml`. 11 | -------------------------------------------------------------------------------- /.github/changelog.json: -------------------------------------------------------------------------------- 1 | { 2 | "categories": [ 3 | { 4 | "title": "## Features", 5 | "labels": ["T-feature"] 6 | }, 7 | { 8 | "title": "## Fixes", 9 | "labels": ["T-bug", "T-fix"] 10 | } 11 | ], 12 | "ignore_labels": ["L-ignore"], 13 | "template": "${{CHANGELOG}}\n## Other\n\n${{UNCATEGORIZED}}", 14 | "pr_template": "- ${{TITLE}} (#${{NUMBER}})", 15 | "empty_template": "- No changes" 16 | } 17 | -------------------------------------------------------------------------------- /.github/compilation-benchmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flashbots/suavex-foundry/76966b85de7bc6413e2faefbcc5a171b2a606d58/.github/compilation-benchmark.png -------------------------------------------------------------------------------- /.github/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flashbots/suavex-foundry/76966b85de7bc6413e2faefbcc5a171b2a606d58/.github/demo.gif -------------------------------------------------------------------------------- /.github/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flashbots/suavex-foundry/76966b85de7bc6413e2faefbcc5a171b2a606d58/.github/logo.png -------------------------------------------------------------------------------- /.github/scripts/create-tag.js: -------------------------------------------------------------------------------- 1 | module.exports = async ({ github, context }, tagName) => { 2 | try { 3 | await github.rest.git.createRef({ 4 | owner: context.repo.owner, 5 | repo: context.repo.repo, 6 | ref: `refs/tags/${tagName}`, 7 | sha: context.sha, 8 | force: true, 9 | }); 10 | } catch (err) { 11 | console.error(`Failed to create tag: ${tagName}`); 12 | console.error(err); 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /.github/scripts/move-tag.js: -------------------------------------------------------------------------------- 1 | module.exports = async ({ github, context }, tagName) => { 2 | try { 3 | await github.rest.git.updateRef({ 4 | owner: context.repo.owner, 5 | repo: context.repo.repo, 6 | ref: `tags/${tagName}`, 7 | sha: context.sha, 8 | force: true, 9 | }); 10 | } catch (err) { 11 | console.error(`Failed to move nightly tag.`); 12 | console.error(`This should only happen the first time.`); 13 | console.error(err); 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /.github/workflows/deny.yml: -------------------------------------------------------------------------------- 1 | name: deny 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | paths: [Cargo.lock, deny.toml] 7 | pull_request: 8 | branches: [master] 9 | paths: [Cargo.lock, deny.toml] 10 | 11 | env: 12 | CARGO_TERM_COLOR: always 13 | 14 | jobs: 15 | cargo-deny: 16 | name: cargo deny check 17 | runs-on: ubuntu-latest 18 | timeout-minutes: 30 19 | steps: 20 | - uses: actions/checkout@v4 21 | - uses: EmbarkStudios/cargo-deny-action@v1 22 | with: 23 | command: check all 24 | # Clear out arguments to not pass `--all-features` to `cargo deny`. 25 | # many crates have an `openssl` feature which enables banned dependencies 26 | arguments: "" 27 | -------------------------------------------------------------------------------- /.github/workflows/test-isolate.yml: -------------------------------------------------------------------------------- 1 | # # Daily CI job to run tests with isolation mode enabled by default 2 | 3 | # name: test-isolate 4 | 5 | # on: 6 | # schedule: 7 | # - cron: "0 0 * * *" 8 | # workflow_dispatch: 9 | 10 | # jobs: 11 | # nextest: 12 | # uses: ./.github/workflows/nextest.yml 13 | # with: 14 | # profile: isolate 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_STORE 2 | /target 3 | out/ 4 | out.json 5 | .idea 6 | .vscode 7 | bloat* 8 | -------------------------------------------------------------------------------- /FUNDING.json: -------------------------------------------------------------------------------- 1 | { 2 | "drips": { 3 | "ethereum": { 4 | "ownedBy": "0x86308c59a6005d012C51Eef104bBc21786aC5D2E" 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /clippy.toml: -------------------------------------------------------------------------------- 1 | msrv = "1.79" 2 | # bytes::Bytes is included by default and alloy_primitives::Bytes is a wrapper around it, 3 | # so it is safe to ignore it as well 4 | ignore-interior-mutability = ["bytes::Bytes", "alloy_primitives::Bytes"] 5 | -------------------------------------------------------------------------------- /crates/anvil/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | vergen::EmitBuilder::builder().build_timestamp().git_sha(true).emit().unwrap(); 3 | } 4 | -------------------------------------------------------------------------------- /crates/anvil/core/src/eth/bundle.rs: -------------------------------------------------------------------------------- 1 | use alloy_primitives::{Bytes, B256, U256}; 2 | use serde::{Deserialize, Serialize}; 3 | 4 | #[derive(Debug, Clone, Default, Eq, PartialEq, Serialize, Deserialize)] 5 | #[serde(default, rename_all = "camelCase")] 6 | pub struct SBundle { 7 | pub block_number: Option, // // if BlockNumber is set it must match DecryptionCondition 8 | pub max_block: Option, 9 | #[serde(rename = "txs")] 10 | pub transactions: Vec, 11 | pub reverting_hashes: Option>, 12 | } 13 | -------------------------------------------------------------------------------- /crates/anvil/core/src/eth/proof.rs: -------------------------------------------------------------------------------- 1 | //! Return types for `eth_getProof` 2 | 3 | use crate::eth::trie::KECCAK_NULL_RLP; 4 | use alloy_primitives::{B256, U256}; 5 | use revm::primitives::KECCAK_EMPTY; 6 | 7 | #[derive(Clone, Debug, PartialEq, Eq, alloy_rlp::RlpEncodable, alloy_rlp::RlpDecodable)] 8 | pub struct BasicAccount { 9 | pub nonce: U256, 10 | pub balance: U256, 11 | pub storage_root: B256, 12 | pub code_hash: B256, 13 | } 14 | 15 | impl Default for BasicAccount { 16 | fn default() -> Self { 17 | Self { 18 | balance: U256::ZERO, 19 | nonce: U256::ZERO, 20 | code_hash: KECCAK_EMPTY, 21 | storage_root: KECCAK_NULL_RLP, 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/anvil/core/src/eth/utils.rs: -------------------------------------------------------------------------------- 1 | use alloy_primitives::Parity; 2 | 3 | /// See 4 | /// > If you do, then the v of the signature MUST be set to {0,1} + CHAIN_ID * 2 + 35 where 5 | /// > {0,1} is the parity of the y value of the curve point for which r is the x-value in the 6 | /// > secp256k1 signing process. 7 | pub fn meets_eip155(chain_id: u64, v: Parity) -> bool { 8 | let double_chain_id = chain_id.saturating_mul(2); 9 | match v { 10 | Parity::Eip155(v) => v == double_chain_id + 35 || v == double_chain_id + 36, 11 | _ => false, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /crates/anvil/core/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # anvil-core 2 | //! 3 | //! Core Ethereum types for Anvil. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | /// Various Ethereum types 9 | pub mod eth; 10 | 11 | /// Additional useful types 12 | pub mod types; 13 | -------------------------------------------------------------------------------- /crates/anvil/rpc/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "anvil-rpc" 3 | 4 | version.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | authors.workspace = true 8 | license.workspace = true 9 | homepage.workspace = true 10 | repository.workspace = true 11 | 12 | [lints] 13 | workspace = true 14 | 15 | [dependencies] 16 | serde.workspace = true 17 | serde_json.workspace = true 18 | -------------------------------------------------------------------------------- /crates/anvil/rpc/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # anvil-rpc 2 | //! 3 | //! JSON-RPC types. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | /// JSON-RPC request bindings 9 | pub mod request; 10 | 11 | /// JSON-RPC response bindings 12 | pub mod response; 13 | 14 | /// JSON-RPC error bindings 15 | pub mod error; 16 | -------------------------------------------------------------------------------- /crates/anvil/server/src/error.rs: -------------------------------------------------------------------------------- 1 | //! Error variants used to unify different connection streams 2 | 3 | /// An error that can occur when reading an incoming request 4 | #[derive(Debug, thiserror::Error)] 5 | pub enum RequestError { 6 | #[error(transparent)] 7 | Axum(#[from] axum::Error), 8 | #[error(transparent)] 9 | Serde(#[from] serde_json::Error), 10 | #[error(transparent)] 11 | Io(#[from] std::io::Error), 12 | #[error("Disconnect")] 13 | Disconnect, 14 | } 15 | -------------------------------------------------------------------------------- /crates/anvil/src/eth/backend/mod.rs: -------------------------------------------------------------------------------- 1 | //! blockchain Backend 2 | 3 | /// [revm](foundry_evm::revm) related types 4 | pub mod db; 5 | /// In-memory Backend 6 | pub mod mem; 7 | 8 | pub mod cheats; 9 | pub mod time; 10 | 11 | pub mod executor; 12 | pub mod fork; 13 | pub mod genesis; 14 | pub mod info; 15 | pub mod notifications; 16 | pub mod validate; 17 | -------------------------------------------------------------------------------- /crates/anvil/src/eth/backend/notifications.rs: -------------------------------------------------------------------------------- 1 | //! Notifications emitted from the backed 2 | 3 | use alloy_consensus::Header; 4 | use alloy_primitives::B256; 5 | use futures::channel::mpsc::UnboundedReceiver; 6 | use std::sync::Arc; 7 | 8 | /// A notification that's emitted when a new block was imported 9 | #[derive(Clone, Debug)] 10 | pub struct NewBlockNotification { 11 | /// Hash of the imported block 12 | pub hash: B256, 13 | /// block header 14 | pub header: Arc
, 15 | } 16 | 17 | /// Type alias for a receiver that receives [NewBlockNotification] 18 | pub type NewBlockNotifications = UnboundedReceiver; 19 | -------------------------------------------------------------------------------- /crates/anvil/src/eth/macros.rs: -------------------------------------------------------------------------------- 1 | /// A `info!` helper macro that emits to the target, the node logger listens for 2 | macro_rules! node_info { 3 | ($($arg:tt)*) => { 4 | tracing::info!(target: $crate::logging::NODE_USER_LOG_TARGET, $($arg)*); 5 | }; 6 | } 7 | 8 | pub(crate) use node_info; 9 | -------------------------------------------------------------------------------- /crates/anvil/src/eth/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod api; 2 | pub mod otterscan; 3 | pub mod sign; 4 | pub use api::EthApi; 5 | 6 | pub mod backend; 7 | 8 | pub mod error; 9 | 10 | pub mod fees; 11 | pub(crate) mod macros; 12 | pub mod miner; 13 | pub mod pool; 14 | pub mod util; 15 | -------------------------------------------------------------------------------- /crates/anvil/src/eth/otterscan/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod api; 2 | -------------------------------------------------------------------------------- /crates/anvil/src/server/error.rs: -------------------------------------------------------------------------------- 1 | /// Result alias 2 | pub type NodeResult = Result; 3 | 4 | /// An error that can occur when launching a anvil instance 5 | #[derive(Debug, thiserror::Error)] 6 | pub enum NodeError { 7 | #[error(transparent)] 8 | Hyper(#[from] hyper::Error), 9 | #[error(transparent)] 10 | Io(#[from] std::io::Error), 11 | } 12 | -------------------------------------------------------------------------------- /crates/anvil/test-data/emit_logs.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.24; 2 | 3 | contract SimpleStorage { 4 | 5 | event ValueChanged(address indexed author, string oldValue, string newValue); 6 | 7 | string _value; 8 | 9 | constructor(string memory value) public { 10 | _value = value; 11 | } 12 | 13 | function getValue() view public returns (string memory) { 14 | return _value; 15 | } 16 | 17 | function setValue(string memory value) public { 18 | emit ValueChanged(msg.sender, _value, value); 19 | _value = value; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /crates/anvil/tests/it/main.rs: -------------------------------------------------------------------------------- 1 | mod abi; 2 | mod anvil; 3 | mod anvil_api; 4 | mod api; 5 | mod eip4844; 6 | mod fork; 7 | mod gas; 8 | mod genesis; 9 | mod ipc; 10 | mod logs; 11 | mod optimism; 12 | mod otterscan; 13 | mod proof; 14 | mod pubsub; 15 | mod revert; 16 | mod sign; 17 | mod state; 18 | mod traces; 19 | mod transaction; 20 | mod txpool; 21 | pub mod utils; 22 | mod wsapi; 23 | 24 | #[allow(unused)] 25 | pub(crate) fn init_tracing() { 26 | let _ = tracing_subscriber::FmtSubscriber::builder() 27 | .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) 28 | .try_init(); 29 | } 30 | 31 | fn main() {} 32 | -------------------------------------------------------------------------------- /crates/anvil/tests/it/state.rs: -------------------------------------------------------------------------------- 1 | //! general eth api tests 2 | 3 | use anvil::{spawn, NodeConfig}; 4 | 5 | #[tokio::test(flavor = "multi_thread")] 6 | async fn can_load_state() { 7 | let tmp = tempfile::tempdir().unwrap(); 8 | let state_file = tmp.path().join("state.json"); 9 | 10 | let (api, _handle) = spawn(NodeConfig::test()).await; 11 | 12 | api.mine_one().await; 13 | 14 | let num = api.block_number().unwrap(); 15 | 16 | let state = api.serialized_state().await.unwrap(); 17 | foundry_common::fs::write_json_file(&state_file, &state).unwrap(); 18 | 19 | let (api, _handle) = spawn(NodeConfig::test().with_init_state_path(state_file)).await; 20 | 21 | let num2 = api.block_number().unwrap(); 22 | assert_eq!(num, num2); 23 | } 24 | -------------------------------------------------------------------------------- /crates/cast/README.md: -------------------------------------------------------------------------------- 1 | # `cast` 2 | 3 | Cast is a command-line tool for performing Ethereum RPC calls. You can make smart contract calls, send transactions, or retrieve any type of chain data - all from your command-line! 4 | 5 | For more information, see the [📖 Foundry Book (Cast Guide)](https://book.getfoundry.sh/cast/index.html). 6 | -------------------------------------------------------------------------------- /crates/cast/bin/cmd/mod.rs: -------------------------------------------------------------------------------- 1 | //! Subcommands for cast 2 | //! 3 | //! All subcommands should respect the `foundry_config::Config`. 4 | //! If a subcommand accepts values that are supported by the `Config`, then the subcommand should 5 | //! implement `figment::Provider` which allows the subcommand to override the config's defaults, see 6 | //! [`foundry_config::Config`]. 7 | 8 | pub mod access_list; 9 | pub mod bind; 10 | pub mod call; 11 | pub mod create2; 12 | pub mod estimate; 13 | pub mod find_block; 14 | pub mod interface; 15 | pub mod logs; 16 | pub mod mktx; 17 | pub mod rpc; 18 | pub mod run; 19 | pub mod send; 20 | pub mod storage; 21 | pub mod wallet; 22 | -------------------------------------------------------------------------------- /crates/cast/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | vergen::EmitBuilder::builder().build_timestamp().git_sha(true).emit().unwrap(); 3 | } 4 | -------------------------------------------------------------------------------- /crates/cast/tests/fixtures/cast_logs.stdout: -------------------------------------------------------------------------------- 1 | - address: 0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE 2 | blockHash: 0x439b61565dacbc09a6d54378dff60d9b0400496d7a5a060cfdfdd899262f466c 3 | blockNumber: 12421182 4 | data: 0x000000000000000000000000000000000000027fd7b375dda5ef932dac18d302 5 | logIndex: 15 6 | removed: false 7 | topics: [ 8 | 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef 9 | 0x000000000000000000000000ab5801a7d398351b8be11c439e05c5b3259aec9b 10 | 0x00000000000000000000000068a99f89e475a078645f4bac491360afe255dff1 11 | ] 12 | transactionHash: 0xb65bcbb85c1633b0ab4e4886c3cd8eeaeb63edbb39cacdb9223fdcf4454fd2c7 13 | transactionIndex: 8 14 | -------------------------------------------------------------------------------- /crates/cast/tests/fixtures/keystore/UTC--2022-10-30T06-51-20.130356000Z--560d246fcddc9ea98a8b032c9a2f474efb493c28: -------------------------------------------------------------------------------- 1 | {"address":"560d246fcddc9ea98a8b032c9a2f474efb493c28","crypto":{"cipher":"aes-128-ctr","ciphertext":"0b0012edfc7a1b22c7c616a78562807c363482490359ae23858c49d6a369b2ff","cipherparams":{"iv":"9d72960fe04dd987300e91c101c890b8"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"f7d24eae5e746700a1fdc0e0886801b0e7aff7e298f9409f74355a5387827181"},"mac":"981cae42a43ce975b9ff13d19a99ae755ad3f6125c94a4da517c50067ca87f07"},"id":"852dbcfc-726a-416e-9321-29f9b5d7e2de","version":3} -------------------------------------------------------------------------------- /crates/cast/tests/fixtures/keystore/UTC--2022-12-20T10-30-43.591916000Z--ec554aeafe75601aaab43bd4621a22284db566c2: -------------------------------------------------------------------------------- 1 | {"address":"ec554aeafe75601aaab43bd4621a22284db566c2","crypto":{"cipher":"aes-128-ctr","ciphertext":"f4e11a2667d97f42ad820f2aa735cd557ff608f47e2738d763a834b889611e18","cipherparams":{"iv":"99c3e2f1c98ccac50cb19f0a148e02ee"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"81f3033ffcc9fec9939eaec246a4037d9bc0c47cfb33247c98132b7d477b7e64"},"mac":"13bb4eac9a8d8f72905bca0c6f947c440d990baa649b0697b2083f3ab57d2cc5"},"id":"279ce8c3-dd94-43a8-aa46-15c3a45adbd1","version":3} -------------------------------------------------------------------------------- /crates/cast/tests/fixtures/keystore/password: -------------------------------------------------------------------------------- 1 | this is keystore password 2 | -------------------------------------------------------------------------------- /crates/cast/tests/fixtures/keystore/password-ec554: -------------------------------------------------------------------------------- 1 | keystorepassword -------------------------------------------------------------------------------- /crates/cast/tests/fixtures/sign_typed_data.json: -------------------------------------------------------------------------------- 1 | {"types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Message":[{"name":"data","type":"string"}]},"primaryType":"Message","domain":{"name":"example.metamask.io","version":"1","chainId":"1","verifyingContract":"0x0000000000000000000000000000000000000000"},"message":{"data":"Hello!"}} -------------------------------------------------------------------------------- /crates/cheatcodes/spec/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-cheatcodes-spec" 3 | description = "Foundry cheatcodes specification" 4 | 5 | version.workspace = true 6 | edition.workspace = true 7 | rust-version.workspace = true 8 | authors.workspace = true 9 | license.workspace = true 10 | homepage.workspace = true 11 | repository.workspace = true 12 | exclude.workspace = true 13 | 14 | [lints] 15 | workspace = true 16 | 17 | [dependencies] 18 | foundry-macros.workspace = true 19 | alloy-sol-types = { workspace = true, features = ["json"] } 20 | serde.workspace = true 21 | 22 | # schema 23 | schemars = { version = "0.8.15", optional = true } 24 | 25 | [dev-dependencies] 26 | serde_json.workspace = true 27 | 28 | [features] 29 | schema = ["dep:schemars"] 30 | -------------------------------------------------------------------------------- /crates/cheatcodes/spec/README.md: -------------------------------------------------------------------------------- 1 | # foundry-cheatcodes-spec 2 | 3 | Minimal crate to provide a cheatcodes specification. 4 | -------------------------------------------------------------------------------- /crates/chisel/assets/preview.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flashbots/suavex-foundry/76966b85de7bc6413e2faefbcc5a171b2a606d58/crates/chisel/assets/preview.gif -------------------------------------------------------------------------------- /crates/chisel/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | vergen::EmitBuilder::builder().build_timestamp().git_sha(true).emit().unwrap(); 3 | } 4 | -------------------------------------------------------------------------------- /crates/chisel/src/history.rs: -------------------------------------------------------------------------------- 1 | //! chisel history file 2 | 3 | use std::path::PathBuf; 4 | 5 | /// The name of the chisel history file 6 | pub const CHISEL_HISTORY_FILE_NAME: &str = ".chisel_history"; 7 | 8 | /// Returns the path to foundry's global toml file that's stored at `~/.foundry/.chisel_history` 9 | pub fn chisel_history_file() -> Option { 10 | foundry_config::Config::foundry_dir().map(|p| p.join(CHISEL_HISTORY_FILE_NAME)) 11 | } 12 | -------------------------------------------------------------------------------- /crates/chisel/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 3 | 4 | pub mod dispatcher; 5 | 6 | pub mod cmd; 7 | 8 | pub mod history; 9 | 10 | pub mod session; 11 | 12 | pub mod session_source; 13 | 14 | pub mod runner; 15 | 16 | pub mod executor; 17 | 18 | pub mod solidity_helper; 19 | 20 | pub mod prelude { 21 | pub use crate::{ 22 | cmd::*, dispatcher::*, runner::*, session::*, session_source::*, solidity_helper::*, 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /crates/cli/README.md: -------------------------------------------------------------------------------- 1 | # Foundry CLIs 2 | 3 | The CLIs are written using [clap's](https://docs.rs/clap) [derive feature](https://docs.rs/clap/latest/clap/_derive). 4 | 5 | ## Installation 6 | 7 | See [Installation](../../README.md#Installation). 8 | 9 | ## Usage 10 | 11 | Read the [📖 Foundry Book][foundry-book] 12 | 13 | ## Debugging 14 | 15 | Debug logs are printed with 16 | [`tracing`](https://docs.rs/tracing/latest/tracing/). You can configure the 17 | verbosity level via the 18 | [`RUST_LOG`](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/index.html#filtering-events-with-environment-variables) 19 | environment variable, on a per package level, 20 | e.g.:`RUST_LOG=forge,foundry_evm forge test` 21 | 22 | [foundry-book]: https://book.getfoundry.sh 23 | -------------------------------------------------------------------------------- /crates/cli/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # foundry-cli 2 | //! 3 | //! Common CLI utilities. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | #[macro_use] 9 | extern crate tracing; 10 | 11 | pub mod handler; 12 | pub mod opts; 13 | pub mod stdin; 14 | pub mod utils; 15 | -------------------------------------------------------------------------------- /crates/cli/src/opts/mod.rs: -------------------------------------------------------------------------------- 1 | mod build; 2 | mod chain; 3 | mod dependency; 4 | mod ethereum; 5 | mod transaction; 6 | 7 | pub use build::*; 8 | pub use chain::*; 9 | pub use dependency::*; 10 | pub use ethereum::*; 11 | pub use transaction::*; 12 | -------------------------------------------------------------------------------- /crates/common/README.md: -------------------------------------------------------------------------------- 1 | Common utilities for building and using foundry's tools. 2 | -------------------------------------------------------------------------------- /crates/common/fmt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-common-fmt" 3 | description = "Common formatting utilities for Foundry" 4 | 5 | version.workspace = true 6 | edition.workspace = true 7 | rust-version.workspace = true 8 | authors.workspace = true 9 | license.workspace = true 10 | homepage.workspace = true 11 | repository.workspace = true 12 | 13 | [lints] 14 | workspace = true 15 | 16 | [dependencies] 17 | alloy-primitives.workspace = true 18 | alloy-dyn-abi = { workspace = true, features = ["eip712"] } 19 | yansi.workspace = true 20 | 21 | # ui 22 | alloy-consensus.workspace = true 23 | alloy-rpc-types = { workspace = true, features = ["eth"] } 24 | alloy-serde.workspace = true 25 | serde.workspace = true 26 | serde_json.workspace = true 27 | chrono.workspace = true 28 | 29 | [dev-dependencies] 30 | foundry-macros.workspace = true 31 | similar-asserts.workspace = true 32 | -------------------------------------------------------------------------------- /crates/common/fmt/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Helpers for formatting Ethereum types. 2 | 3 | mod console; 4 | pub use console::{console_format, ConsoleFmt, FormatSpec}; 5 | 6 | mod dynamic; 7 | pub use dynamic::{format_token, format_token_raw, format_tokens, parse_tokens}; 8 | 9 | mod exp; 10 | pub use exp::{format_int_exp, format_uint_exp, to_exp_notation}; 11 | 12 | mod ui; 13 | pub use ui::{get_pretty_block_attr, get_pretty_tx_attr, EthValue, UIfmt}; 14 | -------------------------------------------------------------------------------- /crates/common/src/errors/artifacts.rs: -------------------------------------------------------------------------------- 1 | //! Errors that can occur when working with `solc` artifacts 2 | 3 | /// Error when encountering unlinked code 4 | #[derive(Clone, Debug, thiserror::Error)] 5 | pub enum UnlinkedByteCode { 6 | /// `bytecode` is unlinked 7 | #[error("Contract `{0}` has unlinked bytecode. Please check all libraries settings.")] 8 | Bytecode(String), 9 | /// `deployedBytecode` is unlinked 10 | #[error("Contract `{0}` has unlinked deployed Bytecode. Please check all libraries settings.")] 11 | DeployedBytecode(String), 12 | } 13 | -------------------------------------------------------------------------------- /crates/common/src/errors/mod.rs: -------------------------------------------------------------------------------- 1 | //! Commonly used errors 2 | 3 | mod fs; 4 | pub use fs::FsPathError; 5 | 6 | mod artifacts; 7 | pub use artifacts::*; 8 | -------------------------------------------------------------------------------- /crates/common/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # foundry-common 2 | //! 3 | //! Common utilities for building and using foundry's tools. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | #[allow(unused_extern_crates)] // Used by `ConsoleFmt`. 9 | extern crate self as foundry_common; 10 | 11 | #[macro_use] 12 | extern crate tracing; 13 | 14 | pub use foundry_common_fmt as fmt; 15 | 16 | pub mod abi; 17 | pub mod calc; 18 | pub mod compile; 19 | pub mod constants; 20 | pub mod contracts; 21 | pub mod ens; 22 | pub mod errors; 23 | pub mod evm; 24 | pub mod fs; 25 | pub mod provider; 26 | pub mod retry; 27 | pub mod selectors; 28 | pub mod serde_helpers; 29 | pub mod shell; 30 | pub mod term; 31 | pub mod traits; 32 | pub mod transactions; 33 | mod utils; 34 | 35 | pub use constants::*; 36 | pub use contracts::*; 37 | pub use traits::*; 38 | pub use transactions::*; 39 | pub use utils::*; 40 | -------------------------------------------------------------------------------- /crates/config/src/bind_json.rs: -------------------------------------------------------------------------------- 1 | use crate::filter::GlobMatcher; 2 | use serde::{Deserialize, Serialize}; 3 | use std::path::PathBuf; 4 | 5 | /// Contains the config for `forge bind-json` 6 | #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] 7 | pub struct BindJsonConfig { 8 | /// Path for the generated bindings file. 9 | pub out: PathBuf, 10 | /// Globs to include. 11 | /// 12 | /// If provided, only the files matching the globs will be included. Otherwise, defaults to 13 | /// including all project files. 14 | pub include: Vec, 15 | /// Globs to ignore 16 | pub exclude: Vec, 17 | } 18 | 19 | impl Default for BindJsonConfig { 20 | fn default() -> Self { 21 | Self { 22 | out: PathBuf::from("utils/JsonBindings.sol"), 23 | exclude: Vec::new(), 24 | include: Vec::new(), 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /crates/config/src/vyper.rs: -------------------------------------------------------------------------------- 1 | //! Vyper specific configuration types. 2 | 3 | use foundry_compilers::artifacts::vyper::VyperOptimizationMode; 4 | use serde::{Deserialize, Serialize}; 5 | use std::path::PathBuf; 6 | 7 | #[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] 8 | pub struct VyperConfig { 9 | /// Vyper optimization mode. "gas", "none" or "codesize" 10 | #[serde(default, skip_serializing_if = "Option::is_none")] 11 | pub optimize: Option, 12 | /// The Vyper instance to use if any. 13 | #[serde(default, skip_serializing_if = "Option::is_none")] 14 | pub path: Option, 15 | } 16 | -------------------------------------------------------------------------------- /crates/debugger/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-debugger" 3 | 4 | version.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | authors.workspace = true 8 | license.workspace = true 9 | homepage.workspace = true 10 | repository.workspace = true 11 | 12 | [lints] 13 | workspace = true 14 | 15 | [dependencies] 16 | foundry-common.workspace = true 17 | foundry-compilers.workspace = true 18 | foundry-evm-traces.workspace = true 19 | revm-inspectors.workspace = true 20 | 21 | alloy-primitives.workspace = true 22 | 23 | crossterm = "0.27" 24 | eyre.workspace = true 25 | ratatui = { version = "0.26", default-features = false, features = ["crossterm"] } 26 | revm.workspace = true 27 | tracing.workspace = true 28 | serde.workspace = true 29 | -------------------------------------------------------------------------------- /crates/debugger/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # foundry-debugger 2 | //! 3 | //! Interactive Solidity TUI debugger. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | #[macro_use] 9 | extern crate tracing; 10 | 11 | mod op; 12 | 13 | mod tui; 14 | pub use tui::{Debugger, DebuggerBuilder, ExitReason}; 15 | 16 | mod node; 17 | pub use node::DebugNode; 18 | -------------------------------------------------------------------------------- /crates/doc/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! The module for generating Solidity documentation. 2 | //! 3 | //! See [`DocBuilder`]. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | #[macro_use] 9 | extern crate tracing; 10 | 11 | mod builder; 12 | pub use builder::DocBuilder; 13 | 14 | mod document; 15 | pub use document::Document; 16 | 17 | mod helpers; 18 | 19 | mod parser; 20 | pub use parser::{ 21 | error, Comment, CommentTag, Comments, CommentsRef, ParseItem, ParseSource, Parser, 22 | }; 23 | 24 | mod preprocessor; 25 | pub use preprocessor::*; 26 | 27 | mod writer; 28 | pub use writer::{AsDoc, AsDocResult, BufWriter, Markdown}; 29 | 30 | pub use mdbook; 31 | -------------------------------------------------------------------------------- /crates/doc/src/parser/error.rs: -------------------------------------------------------------------------------- 1 | use forge_fmt::FormatterError; 2 | use thiserror::Error; 3 | 4 | /// The parser error. 5 | #[derive(Debug, Error)] 6 | #[error(transparent)] 7 | pub enum ParserError { 8 | /// Formatter error. 9 | #[error(transparent)] 10 | Formatter(#[from] FormatterError), 11 | /// Internal parser error. 12 | #[error(transparent)] 13 | Internal(#[from] eyre::Error), 14 | } 15 | 16 | /// The parser result. 17 | pub type ParserResult = std::result::Result; 18 | -------------------------------------------------------------------------------- /crates/doc/src/writer/mod.rs: -------------------------------------------------------------------------------- 1 | //! The module for writing and formatting various parse tree items. 2 | 3 | mod as_doc; 4 | mod buf_writer; 5 | mod markdown; 6 | 7 | pub use as_doc::{AsDoc, AsDocResult}; 8 | pub use buf_writer::BufWriter; 9 | pub use markdown::Markdown; 10 | 11 | mod traits; 12 | -------------------------------------------------------------------------------- /crates/doc/static/book.css: -------------------------------------------------------------------------------- 1 | table { 2 | margin: 0 auto; 3 | border-collapse: collapse; 4 | width: 100%; 5 | } 6 | 7 | table td:first-child { 8 | width: 15%; 9 | } 10 | 11 | table td:nth-child(2) { 12 | width: 25%; 13 | } -------------------------------------------------------------------------------- /crates/doc/static/book.toml: -------------------------------------------------------------------------------- 1 | # For more configuration see https://rust-lang.github.io/mdBook/format/configuration/index.html 2 | [book] 3 | src = "src" 4 | 5 | [output.html] 6 | no-section-label = true 7 | additional-js = ["solidity.min.js"] 8 | additional-css = ["book.css"] 9 | 10 | [output.html.fold] 11 | enable = true 12 | -------------------------------------------------------------------------------- /crates/evm/abi/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-evm-abi" 3 | description = "Solidity ABI-related utilities and `sol!` definitions" 4 | 5 | version.workspace = true 6 | edition.workspace = true 7 | rust-version.workspace = true 8 | authors.workspace = true 9 | license.workspace = true 10 | homepage.workspace = true 11 | repository.workspace = true 12 | 13 | [lints] 14 | workspace = true 15 | 16 | [dependencies] 17 | foundry-common-fmt.workspace = true 18 | foundry-macros.workspace = true 19 | 20 | alloy-primitives.workspace = true 21 | alloy-sol-types = { workspace = true, features = ["json"] } 22 | 23 | derive_more.workspace = true 24 | itertools.workspace = true 25 | once_cell.workspace = true 26 | rustc-hash.workspace = true 27 | 28 | [dev-dependencies] 29 | foundry-test-utils.workspace = true 30 | -------------------------------------------------------------------------------- /crates/evm/abi/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! Solidity ABI-related utilities and [`sol!`](alloy_sol_types::sol) definitions. 2 | 3 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 4 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 5 | 6 | mod console; 7 | pub use console::*; 8 | -------------------------------------------------------------------------------- /crates/evm/core/src/fork/mod.rs: -------------------------------------------------------------------------------- 1 | use super::opts::EvmOpts; 2 | use revm::primitives::Env; 3 | 4 | mod init; 5 | pub use init::environment; 6 | 7 | pub mod database; 8 | 9 | mod multi; 10 | pub use multi::{ForkId, MultiFork, MultiForkHandler}; 11 | 12 | /// Represents a _fork_ of a remote chain whose data is available only via the `url` endpoint. 13 | #[derive(Clone, Debug)] 14 | pub struct CreateFork { 15 | /// Whether to enable rpc storage caching for this fork 16 | pub enable_caching: bool, 17 | /// The URL to a node for fetching remote state 18 | pub url: String, 19 | /// The env to create this fork, main purpose is to provide some metadata for the fork 20 | pub env: Env, 21 | /// All env settings as configured by the user 22 | pub evm_opts: EvmOpts, 23 | } 24 | -------------------------------------------------------------------------------- /crates/evm/core/src/opcodes.rs: -------------------------------------------------------------------------------- 1 | //! Opcode utils 2 | 3 | use revm::interpreter::OpCode; 4 | 5 | /// Returns true if the opcode modifies memory. 6 | /// 7 | /// 8 | #[inline] 9 | pub const fn modifies_memory(opcode: OpCode) -> bool { 10 | matches!( 11 | opcode, 12 | OpCode::EXTCODECOPY 13 | | OpCode::MLOAD 14 | | OpCode::MSTORE 15 | | OpCode::MSTORE8 16 | | OpCode::MCOPY 17 | | OpCode::CODECOPY 18 | | OpCode::CALLDATACOPY 19 | | OpCode::RETURNDATACOPY 20 | | OpCode::CALL 21 | | OpCode::CALLCODE 22 | | OpCode::DELEGATECALL 23 | | OpCode::STATICCALL 24 | ) 25 | } 26 | -------------------------------------------------------------------------------- /crates/evm/core/test-data/storage.json: -------------------------------------------------------------------------------- 1 | {"meta":{"cfg_env":{"chain_id":1,"spec_id":"LATEST","perf_all_precompiles_have_balance":false,"memory_limit":4294967295,"perf_analyse_created_bytecodes":"Analyse","limit_contract_code_size":24576,"disable_coinbase_tip":false},"block_env":{"number":"0xdc42b8","coinbase":"0x0000000000000000000000000000000000000000","timestamp":"0x1","difficulty":"0x0","basefee":"0x0","gas_limit":"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"},"hosts":["mainnet.infura.io"]},"accounts":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"balance":"0x0","code_hash":"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470","code":null,"nonce":0}},"storage":{"0x63091244180ae240c87d1f528f5f269134cb07b3":{"0x0":"0x0","0x1":"0x0","0x2":"0x0","0x3":"0x0","0x4":"0x0","0x5":"0x0","0x6":"0x0","0x7":"0x0","0x8":"0x0","0x9":"0x0"}},"block_hashes":{}} -------------------------------------------------------------------------------- /crates/evm/coverage/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-evm-coverage" 3 | description = "EVM bytecode coverage analysis" 4 | 5 | version.workspace = true 6 | edition.workspace = true 7 | rust-version.workspace = true 8 | authors.workspace = true 9 | license.workspace = true 10 | homepage.workspace = true 11 | repository.workspace = true 12 | 13 | [lints] 14 | workspace = true 15 | 16 | [dependencies] 17 | foundry-common.workspace = true 18 | foundry-compilers.workspace = true 19 | foundry-evm-core.workspace = true 20 | 21 | alloy-primitives.workspace = true 22 | eyre.workspace = true 23 | revm.workspace = true 24 | semver.workspace = true 25 | tracing.workspace = true 26 | rustc-hash.workspace = true 27 | rayon.workspace = true 28 | -------------------------------------------------------------------------------- /crates/evm/evm/src/inspectors/mod.rs: -------------------------------------------------------------------------------- 1 | //! EVM inspectors. 2 | 3 | pub use foundry_cheatcodes::{self as cheatcodes, Cheatcodes, CheatsConfig}; 4 | pub use foundry_evm_coverage::CoverageCollector; 5 | pub use foundry_evm_fuzz::Fuzzer; 6 | pub use foundry_evm_traces::{StackSnapshotType, TracingInspector, TracingInspectorConfig}; 7 | 8 | pub use revm_inspectors::access_list::AccessListInspector; 9 | 10 | mod chisel_state; 11 | pub use chisel_state::ChiselState; 12 | 13 | mod logs; 14 | pub use logs::LogCollector; 15 | 16 | mod stack; 17 | pub use stack::{InspectorData, InspectorStack, InspectorStackBuilder}; 18 | -------------------------------------------------------------------------------- /crates/evm/evm/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # foundry-evm 2 | //! 3 | //! Main Foundry EVM backend abstractions. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | #[macro_use] 9 | extern crate tracing; 10 | 11 | pub mod executors; 12 | pub mod inspectors; 13 | 14 | pub use foundry_evm_core::{backend, constants, decode, fork, opts, utils, InspectorExt}; 15 | pub use foundry_evm_coverage as coverage; 16 | pub use foundry_evm_fuzz as fuzz; 17 | pub use foundry_evm_traces as traces; 18 | 19 | // TODO: We should probably remove these, but it's a pretty big breaking change. 20 | #[doc(hidden)] 21 | pub use revm; 22 | 23 | #[doc(hidden)] 24 | #[deprecated = "use `{hash_map, hash_set, HashMap, HashSet}` in `std::collections` or `revm::primitives` instead"] 25 | pub mod hashbrown { 26 | pub use revm::primitives::{hash_map, hash_set, HashMap, HashSet}; 27 | } 28 | -------------------------------------------------------------------------------- /crates/evm/fuzz/src/error.rs: -------------------------------------------------------------------------------- 1 | //! errors related to fuzz tests 2 | use proptest::test_runner::Reason; 3 | 4 | /// Possible errors when running fuzz tests 5 | #[derive(Debug, thiserror::Error)] 6 | pub enum FuzzError { 7 | #[error("Couldn't call unknown contract")] 8 | UnknownContract, 9 | #[error("Failed contract call")] 10 | FailedContractCall, 11 | #[error("`vm.assume` reject")] 12 | AssumeReject, 13 | #[error("The `vm.assume` cheatcode rejected too many inputs ({0} allowed)")] 14 | TooManyRejects(u32), 15 | } 16 | 17 | impl From for Reason { 18 | fn from(error: FuzzError) -> Self { 19 | error.to_string().into() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /crates/evm/fuzz/src/strategies/mod.rs: -------------------------------------------------------------------------------- 1 | mod int; 2 | pub use int::IntStrategy; 3 | 4 | mod uint; 5 | pub use uint::UintStrategy; 6 | 7 | mod param; 8 | pub use param::{fuzz_param, fuzz_param_from_state, fuzz_param_with_fixtures}; 9 | 10 | mod calldata; 11 | pub use calldata::{fuzz_calldata, fuzz_calldata_from_state}; 12 | 13 | mod state; 14 | pub use state::EvmFuzzState; 15 | 16 | mod invariants; 17 | pub use invariants::{fuzz_contract_with_calldata, invariant_strat, override_call_strat}; 18 | -------------------------------------------------------------------------------- /crates/fmt/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "forge-fmt" 3 | 4 | version.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | authors.workspace = true 8 | license.workspace = true 9 | homepage.workspace = true 10 | repository.workspace = true 11 | 12 | [lints] 13 | workspace = true 14 | 15 | [dependencies] 16 | foundry-config.workspace = true 17 | 18 | alloy-primitives.workspace = true 19 | 20 | ariadne = "0.4" 21 | itertools.workspace = true 22 | solang-parser.workspace = true 23 | thiserror.workspace = true 24 | tracing.workspace = true 25 | 26 | [dev-dependencies] 27 | itertools.workspace = true 28 | similar-asserts.workspace = true 29 | toml.workspace = true 30 | tracing-subscriber = { workspace = true, features = ["env-filter"] } 31 | -------------------------------------------------------------------------------- /crates/fmt/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 3 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 4 | 5 | #[macro_use] 6 | extern crate tracing; 7 | 8 | mod buffer; 9 | pub mod chunk; 10 | mod comments; 11 | mod formatter; 12 | mod helpers; 13 | pub mod inline_config; 14 | mod macros; 15 | pub mod solang_ext; 16 | mod string; 17 | pub mod visit; 18 | 19 | pub use foundry_config::fmt::*; 20 | 21 | pub use comments::Comments; 22 | pub use formatter::{Formatter, FormatterError}; 23 | pub use helpers::{ 24 | format, format_diagnostics_report, format_to, offset_to_line_column, parse, parse2, Parsed, 25 | }; 26 | pub use inline_config::InlineConfig; 27 | pub use visit::{Visitable, Visitor}; 28 | -------------------------------------------------------------------------------- /crates/fmt/testdata/Annotation/fmt.sol: -------------------------------------------------------------------------------- 1 | // Support for Solana/Substrate annotations 2 | contract A { 3 | @selector([1, 2, 3, 4]) 4 | function foo() public {} 5 | 6 | @selector("another one") 7 | function bar() public {} 8 | 9 | @first("") 10 | @second("") 11 | function foobar() public {} 12 | } 13 | 14 | @topselector(2) 15 | contract B {} 16 | -------------------------------------------------------------------------------- /crates/fmt/testdata/Annotation/original.sol: -------------------------------------------------------------------------------- 1 | // Support for Solana/Substrate annotations 2 | contract A { 3 | @selector([1,2,3,4]) 4 | function foo() public {} 5 | 6 | @selector("another one") 7 | function bar() public {} 8 | 9 | @first("") 10 | @second("") 11 | function foobar() public {} 12 | } 13 | 14 | @topselector(2) 15 | contract B {} 16 | -------------------------------------------------------------------------------- /crates/fmt/testdata/BlockComments/fmt.sol: -------------------------------------------------------------------------------- 1 | contract CounterTest is Test { 2 | /** 3 | * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. 4 | */ 5 | constructor(string memory name_, string memory symbol_) { 6 | _name = name_; 7 | _symbol = symbol_; 8 | } 9 | 10 | /** 11 | * @dev See {IERC721-balanceOf}. 12 | */ 13 | function test_Increment() public { 14 | counter.increment(); 15 | assertEq(counter.number(), 1); 16 | } 17 | 18 | /** 19 | * @dev See {IERC165-supportsInterface}. 20 | */ 21 | function test_Increment() public { 22 | counter.increment(); 23 | assertEq(counter.number(), 1); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/fmt/testdata/BlockComments/original.sol: -------------------------------------------------------------------------------- 1 | contract CounterTest is Test { 2 | /** 3 | * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. 4 | */ 5 | 6 | constructor(string memory name_, string memory symbol_) { 7 | _name = name_; 8 | _symbol = symbol_; 9 | } 10 | 11 | /** 12 | * @dev See {IERC721-balanceOf}. 13 | */ 14 | function test_Increment() public { 15 | counter.increment(); 16 | assertEq(counter.number(), 1); 17 | } 18 | 19 | /** 20 | * @dev See {IERC165-supportsInterface}. 21 | */ function test_Increment() public { 22 | counter.increment(); 23 | assertEq(counter.number(), 1); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/BlockCommentsFunction/fmt.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | Counter public counter; 3 | /** 4 | * TODO: this fuzz use too much time to execute 5 | * function testGetFuzz(bytes[2][] memory kvs) public { 6 | * for (uint256 i = 0; i < kvs.length; i++) { 7 | * bytes32 root = trie.update(kvs[i][0], kvs[i][1]); 8 | * console.logBytes32(root); 9 | * } 10 | * 11 | * for (uint256 i = 0; i < kvs.length; i++) { 12 | * (bool exist, bytes memory value) = trie.get(kvs[i][0]); 13 | * console.logBool(exist); 14 | * console.logBytes(value); 15 | * require(exist); 16 | * require(BytesSlice.equal(value, trie.getRaw(kvs[i][0]))); 17 | * } 18 | * } 19 | */ 20 | } 21 | -------------------------------------------------------------------------------- /crates/fmt/testdata/BlockCommentsFunction/original.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | Counter public counter; 3 | /** 4 | * TODO: this fuzz use too much time to execute 5 | function testGetFuzz(bytes[2][] memory kvs) public { 6 | for (uint256 i = 0; i < kvs.length; i++) { 7 | bytes32 root = trie.update(kvs[i][0], kvs[i][1]); 8 | console.logBytes32(root); 9 | } 10 | 11 | for (uint256 i = 0; i < kvs.length; i++) { 12 | (bool exist, bytes memory value) = trie.get(kvs[i][0]); 13 | console.logBool(exist); 14 | console.logBytes(value); 15 | require(exist); 16 | require(BytesSlice.equal(value, trie.getRaw(kvs[i][0]))); 17 | } 18 | } 19 | */ 20 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/ConstructorDefinition/fmt.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.5.2; 4 | 5 | // comment block starts here 6 | // comment block continues 7 | // 8 | 9 | // comment block 2 starts here 10 | // comment block 2 continues 11 | 12 | contract Constructors is Ownable, Changeable { 13 | function Constructors(variable1) 14 | public 15 | Changeable(variable1) 16 | Ownable() 17 | onlyOwner 18 | {} 19 | 20 | constructor( 21 | variable1, 22 | variable2, 23 | variable3, 24 | variable4, 25 | variable5, 26 | variable6, 27 | variable7 28 | ) 29 | public 30 | Changeable( 31 | variable1, 32 | variable2, 33 | variable3, 34 | variable4, 35 | variable5, 36 | variable6, 37 | variable7 38 | ) 39 | Ownable() 40 | onlyOwner 41 | {} 42 | } 43 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ConstructorDefinition/original.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.5.2; 4 | 5 | // comment block starts here 6 | // comment block continues 7 | // 8 | 9 | // comment block 2 starts here 10 | // comment block 2 continues 11 | 12 | contract Constructors is Ownable, Changeable { 13 | function Constructors(variable1) public Changeable(variable1) Ownable() onlyOwner { 14 | } 15 | 16 | constructor(variable1, variable2, variable3, variable4, variable5, variable6, variable7) public Changeable(variable1, variable2, variable3, variable4, variable5, variable6, variable7) Ownable() onlyOwner {} 17 | } 18 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ConstructorModifierStyle/fmt.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.5.2; 4 | 5 | import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; 6 | import {ERC1155} from "solmate/tokens/ERC1155.sol"; 7 | 8 | import {IAchievements} from "./interfaces/IAchievements.sol"; 9 | import {SoulBound1155} from "./abstracts/SoulBound1155.sol"; 10 | 11 | contract Achievements is IAchievements, SoulBound1155, Ownable { 12 | constructor(address owner) Ownable() ERC1155() {} 13 | } 14 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ConstructorModifierStyle/original.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.5.2; 4 | 5 | import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; 6 | import {ERC1155} from "solmate/tokens/ERC1155.sol"; 7 | 8 | import {IAchievements} from "./interfaces/IAchievements.sol"; 9 | import {SoulBound1155} from "./abstracts/SoulBound1155.sol"; 10 | 11 | contract Achievements is IAchievements, SoulBound1155, Ownable { 12 | constructor(address owner) Ownable() ERC1155() {} 13 | } 14 | -------------------------------------------------------------------------------- /crates/fmt/testdata/DoWhileStatement/fmt.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.8; 2 | 3 | contract DoWhileStatement { 4 | function test() external { 5 | uint256 i; 6 | do { 7 | "test"; 8 | } while (i != 0); 9 | 10 | do {} while (i != 0); 11 | 12 | bool someVeryVeryLongCondition; 13 | do { 14 | "test"; 15 | } while ( 16 | someVeryVeryLongCondition && !someVeryVeryLongCondition 17 | && !someVeryVeryLongCondition && someVeryVeryLongCondition 18 | ); 19 | 20 | do { 21 | i++; 22 | } while (i < 10); 23 | 24 | do { 25 | do { 26 | i++; 27 | } while (i < 30); 28 | } while (i < 20); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /crates/fmt/testdata/DoWhileStatement/original.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.8; 2 | 3 | contract DoWhileStatement { 4 | function test() external { 5 | uint256 i; 6 | do { "test"; } while (i != 0); 7 | 8 | do 9 | {} 10 | while 11 | ( 12 | i != 0); 13 | 14 | bool someVeryVeryLongCondition; 15 | do { "test"; } while( 16 | someVeryVeryLongCondition && !someVeryVeryLongCondition && 17 | !someVeryVeryLongCondition && 18 | someVeryVeryLongCondition); 19 | 20 | do i++; while(i < 10); 21 | 22 | do do i++; while (i < 30); while(i < 20); 23 | } 24 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/EmitStatement/fmt.sol: -------------------------------------------------------------------------------- 1 | // config: line_length = 80 2 | event NewEvent( 3 | address beneficiary, uint256 index, uint64 timestamp, uint64 endTimestamp 4 | ); 5 | 6 | function emitEvent() { 7 | emit NewEvent( 8 | beneficiary, 9 | _vestingBeneficiaries.length - 1, 10 | uint64(block.timestamp), 11 | endTimestamp 12 | ); 13 | 14 | emit NewEvent( 15 | /* beneficiary */ 16 | beneficiary, 17 | /* index */ 18 | _vestingBeneficiaries.length - 1, 19 | /* timestamp */ 20 | uint64(block.timestamp), 21 | /* end timestamp */ 22 | endTimestamp 23 | ); 24 | 25 | emit NewEvent( 26 | beneficiary, // beneficiary 27 | _vestingBeneficiaries.length - 1, // index 28 | uint64(block.timestamp), // timestamp 29 | endTimestamp // end timestamp 30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /crates/fmt/testdata/EmitStatement/original.sol: -------------------------------------------------------------------------------- 1 | event NewEvent(address beneficiary, uint256 index, uint64 timestamp, uint64 endTimestamp); 2 | 3 | function emitEvent() { 4 | emit NewEvent( 5 | beneficiary, 6 | _vestingBeneficiaries.length - 1, 7 | uint64(block.timestamp), 8 | endTimestamp 9 | ); 10 | 11 | emit 12 | NewEvent( 13 | /* beneficiary */ beneficiary, 14 | /* index */ _vestingBeneficiaries.length - 1, 15 | /* timestamp */ uint64(block.timestamp), 16 | /* end timestamp */ endTimestamp); 17 | 18 | emit NewEvent( 19 | beneficiary, // beneficiary 20 | _vestingBeneficiaries.length - 1, // index 21 | uint64(block.timestamp), // timestamp 22 | endTimestamp // end timestamp 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /crates/fmt/testdata/EnumDefinition/bracket-spacing.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: bracket_spacing = true 2 | contract EnumDefinitions { 3 | enum Empty { } 4 | enum ActionChoices { 5 | GoLeft, 6 | GoRight, 7 | GoStraight, 8 | SitStill 9 | } 10 | enum States { 11 | State1, 12 | State2, 13 | State3, 14 | State4, 15 | State5, 16 | State6, 17 | State7, 18 | State8, 19 | State9 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /crates/fmt/testdata/EnumDefinition/fmt.sol: -------------------------------------------------------------------------------- 1 | contract EnumDefinitions { 2 | enum Empty {} 3 | enum ActionChoices { 4 | GoLeft, 5 | GoRight, 6 | GoStraight, 7 | SitStill 8 | } 9 | enum States { 10 | State1, 11 | State2, 12 | State3, 13 | State4, 14 | State5, 15 | State6, 16 | State7, 17 | State8, 18 | State9 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /crates/fmt/testdata/EnumDefinition/original.sol: -------------------------------------------------------------------------------- 1 | contract EnumDefinitions { 2 | enum Empty { 3 | 4 | } 5 | enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill } 6 | enum States { State1, State2, State3, State4, State5, State6, State7, State8, State9 } 7 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/EnumVariants/fmt.sol: -------------------------------------------------------------------------------- 1 | interface I { 2 | enum Empty {} 3 | 4 | /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. 5 | enum CallerMode { 6 | /// No caller modification is currently active. 7 | None 8 | } 9 | 10 | /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. 11 | enum CallerMode2 { 12 | /// No caller modification is currently active. 13 | None, 14 | /// No caller modification is currently active2. 15 | Some 16 | } 17 | 18 | function bar() public {} 19 | } 20 | -------------------------------------------------------------------------------- /crates/fmt/testdata/EnumVariants/original.sol: -------------------------------------------------------------------------------- 1 | interface I { 2 | enum Empty { 3 | 4 | } 5 | 6 | /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. 7 | enum CallerMode 8 | {/// No caller modification is currently active. 9 | None 10 | } 11 | 12 | /// A modification applied to either `msg.sender` or `tx.origin`. Returned by `readCallers`. 13 | enum CallerMode2 14 | {/// No caller modification is currently active. 15 | None,/// No caller modification is currently active2. 16 | 17 | Some 18 | } 19 | 20 | function bar() public { 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/ErrorDefinition/fmt.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.4; 2 | 3 | error TopLevelCustomError(); 4 | error TopLevelCustomErrorWithArg(uint256 x); 5 | error TopLevelCustomErrorArgWithoutName(string); 6 | error Error1( 7 | uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256 8 | ); 9 | 10 | contract Errors { 11 | error ContractCustomError(); 12 | error ContractCustomErrorWithArg(uint256 x); 13 | error ContractCustomErrorArgWithoutName(string); 14 | } 15 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ErrorDefinition/original.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.4; 2 | 3 | error 4 | TopLevelCustomError(); 5 | error TopLevelCustomErrorWithArg(uint x) ; 6 | error TopLevelCustomErrorArgWithoutName (string); 7 | error Error1(uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256); 8 | 9 | contract Errors { 10 | error 11 | ContractCustomError(); 12 | error ContractCustomErrorWithArg(uint x) ; 13 | error ContractCustomErrorArgWithoutName (string); 14 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/ForStatement/fmt.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.8; 2 | 3 | contract ForStatement { 4 | function test() external { 5 | for (uint256 i1; i1 < 10; i1++) { 6 | i1++; 7 | } 8 | 9 | uint256 i2; 10 | for (++i2; i2 < 10; i2++) {} 11 | 12 | uint256 veryLongVariableName = 1000; 13 | for ( 14 | uint256 i3; 15 | i3 < 10 && veryLongVariableName > 999 && veryLongVariableName < 1001; 16 | i3++ 17 | ) { 18 | i3++; 19 | } 20 | 21 | for (type(uint256).min;;) {} 22 | 23 | for (;;) { 24 | "test"; 25 | } 26 | 27 | for (uint256 i4; i4 < 10; i4++) { 28 | i4++; 29 | } 30 | 31 | for (uint256 i5;;) { 32 | for (uint256 i6 = 10; i6 > i5; i6--) { 33 | i5++; 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ForStatement/original.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.8; 2 | 3 | contract ForStatement { 4 | function test() external { 5 | for 6 | (uint256 i1 7 | ; i1 < 10; i1++) 8 | { 9 | i1++; 10 | } 11 | 12 | uint256 i2; 13 | for(++i2;i2<10;i2++) 14 | 15 | {} 16 | 17 | uint256 veryLongVariableName = 1000; 18 | for ( uint256 i3; i3 < 10 19 | && veryLongVariableName>999 && veryLongVariableName< 1001 20 | ; i3++) 21 | { i3 ++ ; } 22 | 23 | for (type(uint256).min;;) {} 24 | 25 | for (;;) { "test" ; } 26 | 27 | for (uint256 i4; i4< 10; i4++) i4++; 28 | 29 | for (uint256 i5; ;) 30 | for (uint256 i6 = 10; i6 > i5; i6--) 31 | i5++; 32 | } 33 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/fmt.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.17; 3 | 4 | contract ReturnFnFormat { 5 | function returnsFunction() 6 | internal 7 | pure 8 | returns ( 9 | function() 10 | internal pure returns (uint256) 11 | ) 12 | {} 13 | } 14 | -------------------------------------------------------------------------------- /crates/fmt/testdata/FunctionDefinitionWithFunctionReturns/original.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.17; 3 | 4 | contract ReturnFnFormat { 5 | function returnsFunction() 6 | internal 7 | pure 8 | returns ( 9 | function() 10 | internal pure returns (uint256) 11 | ) 12 | {} 13 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/FunctionType/fmt.sol: -------------------------------------------------------------------------------- 1 | // config: line_length = 90 2 | library ArrayUtils { 3 | function map(uint256[] memory self, function (uint) pure returns (uint) f) 4 | internal 5 | pure 6 | returns (uint256[] memory r) 7 | { 8 | r = new uint256[](self.length); 9 | for (uint256 i = 0; i < self.length; i++) { 10 | r[i] = f(self[i]); 11 | } 12 | } 13 | 14 | function reduce(uint256[] memory self, function (uint, uint) pure returns (uint) f) 15 | internal 16 | pure 17 | returns (uint256 r) 18 | { 19 | r = self[0]; 20 | for (uint256 i = 1; i < self.length; i++) { 21 | r = f(r, self[i]); 22 | } 23 | } 24 | 25 | function range(uint256 length) internal pure returns (uint256[] memory r) { 26 | r = new uint256[](length); 27 | for (uint256 i = 0; i < r.length; i++) { 28 | r[i] = i; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /crates/fmt/testdata/FunctionType/original.sol: -------------------------------------------------------------------------------- 1 | library ArrayUtils { 2 | function map(uint[] memory self, function (uint) pure returns (uint) f) 3 | internal 4 | pure 5 | returns ( 6 | uint[] memory r 7 | ) 8 | { 9 | r = new uint[]( self.length); 10 | for (uint i = 0; i < self.length; i++) { 11 | r[i] = f(self[i]); 12 | } 13 | } 14 | 15 | function reduce( 16 | uint[] memory self, 17 | function (uint, uint) pure returns (uint) f 18 | ) internal pure returns (uint256 r) { 19 | r = self[0]; 20 | for (uint i = 1; i < self.length; i++) { 21 | r = f(r, self[i]); 22 | } 23 | } 24 | 25 | function range(uint256 length) internal pure returns (uint[] memory r) { 26 | r = new uint256[](length ); 27 | for (uint i = 0; i < r.length; i++) { 28 | r[i] = i; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /crates/fmt/testdata/HexUnderscore/bytes.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: hex_underscore = "bytes" 2 | contract HexLiteral { 3 | function test() external { 4 | hex"01_23_00_00"; 5 | hex"01_23_00_00"; 6 | hex"01_23_00_00"; 7 | hex""; 8 | hex"60_01_60_02_53"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /crates/fmt/testdata/HexUnderscore/fmt.sol: -------------------------------------------------------------------------------- 1 | contract HexLiteral { 2 | function test() external { 3 | hex"01230000"; 4 | hex"01230000"; 5 | hex"01230000"; 6 | hex""; 7 | hex"6001600253"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /crates/fmt/testdata/HexUnderscore/original.sol: -------------------------------------------------------------------------------- 1 | contract HexLiteral { 2 | function test() external { 3 | hex"0123_0000"; 4 | hex"01230000"; 5 | hex"0123_00_00"; 6 | hex""; 7 | hex"6001_6002_53"; 8 | } 9 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/HexUnderscore/preserve.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: hex_underscore = "preserve" 2 | contract HexLiteral { 3 | function test() external { 4 | hex"0123_0000"; 5 | hex"01230000"; 6 | hex"0123_00_00"; 7 | hex""; 8 | hex"6001_6002_53"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /crates/fmt/testdata/HexUnderscore/remove.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: hex_underscore = "remove" 2 | contract HexLiteral { 3 | function test() external { 4 | hex"01230000"; 5 | hex"01230000"; 6 | hex"01230000"; 7 | hex""; 8 | hex"6001600253"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /crates/fmt/testdata/IfStatement2/fmt.sol: -------------------------------------------------------------------------------- 1 | contract IfStatement { 2 | function test() external { 3 | bool anotherLongCondition; 4 | 5 | if (condition && ((condition || anotherLongCondition))) execute(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /crates/fmt/testdata/IfStatement2/original.sol: -------------------------------------------------------------------------------- 1 | contract IfStatement { 2 | 3 | function test() external { 4 | bool anotherLongCondition; 5 | 6 | if (condition && ((condition || anotherLongCondition) 7 | ) 8 | ) execute(); 9 | } 10 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/ImportDirective/bracket-spacing.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: bracket_spacing = true 2 | import "SomeFile.sol"; 3 | import "SomeFile.sol"; 4 | import "SomeFile.sol" as SomeOtherFile; 5 | import "SomeFile.sol" as SomeOtherFile; 6 | import "AnotherFile.sol" as SomeSymbol; 7 | import "AnotherFile.sol" as SomeSymbol; 8 | import { symbol1 as alias, symbol2 } from "File.sol"; 9 | import { symbol1 as alias, symbol2 } from "File.sol"; 10 | import { 11 | symbol1 as alias1, 12 | symbol2 as alias2, 13 | symbol3 as alias3, 14 | symbol4 15 | } from "File2.sol"; 16 | import { 17 | symbol1 as alias1, 18 | symbol2 as alias2, 19 | symbol3 as alias3, 20 | symbol4 21 | } from "File2.sol"; 22 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ImportDirective/fmt.sol: -------------------------------------------------------------------------------- 1 | import "SomeFile.sol"; 2 | import "SomeFile.sol"; 3 | import "SomeFile.sol" as SomeOtherFile; 4 | import "SomeFile.sol" as SomeOtherFile; 5 | import "AnotherFile.sol" as SomeSymbol; 6 | import "AnotherFile.sol" as SomeSymbol; 7 | import {symbol1 as alias, symbol2} from "File.sol"; 8 | import {symbol1 as alias, symbol2} from "File.sol"; 9 | import { 10 | symbol1 as alias1, 11 | symbol2 as alias2, 12 | symbol3 as alias3, 13 | symbol4 14 | } from "File2.sol"; 15 | import { 16 | symbol1 as alias1, 17 | symbol2 as alias2, 18 | symbol3 as alias3, 19 | symbol4 20 | } from "File2.sol"; 21 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ImportDirective/original.sol: -------------------------------------------------------------------------------- 1 | import "SomeFile.sol"; 2 | import 'SomeFile.sol'; 3 | import "SomeFile.sol" as SomeOtherFile; 4 | import 'SomeFile.sol' as SomeOtherFile; 5 | import * as SomeSymbol from "AnotherFile.sol"; 6 | import * as SomeSymbol from 'AnotherFile.sol'; 7 | import {symbol1 as alias, symbol2} from "File.sol"; 8 | import {symbol1 as alias, symbol2} from 'File.sol'; 9 | import {symbol1 as alias1, symbol2 as alias2, symbol3 as alias3, symbol4} from "File2.sol"; 10 | import {symbol1 as alias1, symbol2 as alias2, symbol3 as alias3, symbol4} from 'File2.sol'; 11 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ImportDirective/preserve-quote.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: quote_style = "preserve" 2 | import "SomeFile.sol"; 3 | import 'SomeFile.sol'; 4 | import "SomeFile.sol" as SomeOtherFile; 5 | import 'SomeFile.sol' as SomeOtherFile; 6 | import "AnotherFile.sol" as SomeSymbol; 7 | import 'AnotherFile.sol' as SomeSymbol; 8 | import {symbol1 as alias, symbol2} from "File.sol"; 9 | import {symbol1 as alias, symbol2} from 'File.sol'; 10 | import { 11 | symbol1 as alias1, 12 | symbol2 as alias2, 13 | symbol3 as alias3, 14 | symbol4 15 | } from "File2.sol"; 16 | import { 17 | symbol1 as alias1, 18 | symbol2 as alias2, 19 | symbol3 as alias3, 20 | symbol4 21 | } from 'File2.sol'; 22 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ImportDirective/single-quote.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: quote_style = "single" 2 | import 'SomeFile.sol'; 3 | import 'SomeFile.sol'; 4 | import 'SomeFile.sol' as SomeOtherFile; 5 | import 'SomeFile.sol' as SomeOtherFile; 6 | import 'AnotherFile.sol' as SomeSymbol; 7 | import 'AnotherFile.sol' as SomeSymbol; 8 | import {symbol1 as alias, symbol2} from 'File.sol'; 9 | import {symbol1 as alias, symbol2} from 'File.sol'; 10 | import { 11 | symbol1 as alias1, 12 | symbol2 as alias2, 13 | symbol3 as alias3, 14 | symbol4 15 | } from 'File2.sol'; 16 | import { 17 | symbol1 as alias1, 18 | symbol2 as alias2, 19 | symbol3 as alias3, 20 | symbol4 21 | } from 'File2.sol'; 22 | -------------------------------------------------------------------------------- /crates/fmt/testdata/IntTypes/fmt.sol: -------------------------------------------------------------------------------- 1 | contract Contract { 2 | uint256 constant UINT256_IMPL = 0; 3 | uint8 constant UINT8 = 1; 4 | uint128 constant UINT128 = 2; 5 | uint256 constant UINT256_EXPL = 3; 6 | 7 | int256 constant INT256_IMPL = 4; 8 | int8 constant INT8 = 5; 9 | int128 constant INT128 = 6; 10 | int256 constant INT256_EXPL = 7; 11 | 12 | function test( 13 | uint256 uint256_impl, 14 | uint8 uint8_var, 15 | uint128 uint128_var, 16 | uint256 uint256_expl, 17 | int256 int256_impl, 18 | int8 int8_var, 19 | int128 int128_var, 20 | int256 int256_expl 21 | ) public { 22 | // do something 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/fmt/testdata/IntTypes/original.sol: -------------------------------------------------------------------------------- 1 | contract Contract { 2 | uint constant UINT256_IMPL = 0; 3 | uint8 constant UINT8 = 1; 4 | uint128 constant UINT128 = 2; 5 | uint256 constant UINT256_EXPL = 3; 6 | 7 | int constant INT256_IMPL = 4; 8 | int8 constant INT8 = 5; 9 | int128 constant INT128 = 6; 10 | int256 constant INT256_EXPL = 7; 11 | 12 | function test( 13 | uint uint256_impl, 14 | uint8 uint8_var, 15 | uint128 uint128_var, 16 | uint256 uint256_expl, 17 | int int256_impl, 18 | int8 int8_var, 19 | int128 int128_var, 20 | int256 int256_expl 21 | ) public { 22 | // do something 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/fmt/testdata/IntTypes/preserve.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: int_types = "preserve" 2 | contract Contract { 3 | uint constant UINT256_IMPL = 0; 4 | uint8 constant UINT8 = 1; 5 | uint128 constant UINT128 = 2; 6 | uint256 constant UINT256_EXPL = 3; 7 | 8 | int constant INT256_IMPL = 4; 9 | int8 constant INT8 = 5; 10 | int128 constant INT128 = 6; 11 | int256 constant INT256_EXPL = 7; 12 | 13 | function test( 14 | uint uint256_impl, 15 | uint8 uint8_var, 16 | uint128 uint128_var, 17 | uint256 uint256_expl, 18 | int int256_impl, 19 | int8 int8_var, 20 | int128 int128_var, 21 | int256 int256_expl 22 | ) public { 23 | // do something 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/fmt/testdata/IntTypes/short.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: int_types = "short" 2 | contract Contract { 3 | uint constant UINT256_IMPL = 0; 4 | uint8 constant UINT8 = 1; 5 | uint128 constant UINT128 = 2; 6 | uint constant UINT256_EXPL = 3; 7 | 8 | int constant INT256_IMPL = 4; 9 | int8 constant INT8 = 5; 10 | int128 constant INT128 = 6; 11 | int constant INT256_EXPL = 7; 12 | 13 | function test( 14 | uint uint256_impl, 15 | uint8 uint8_var, 16 | uint128 uint128_var, 17 | uint uint256_expl, 18 | int int256_impl, 19 | int8 int8_var, 20 | int128 int128_var, 21 | int int256_expl 22 | ) public { 23 | // do something 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/fmt/testdata/MappingType/original.sol: -------------------------------------------------------------------------------- 1 | contract X { 2 | type Y is bytes32; 3 | } 4 | 5 | type SomeVeryLongTypeName is uint256; 6 | 7 | contract Mapping { 8 | mapping(uint256 => X.Y) mapping1; 9 | mapping(uint256 key => uint256 value) mapping2; 10 | mapping(uint256 veryLongKeyName => uint256 veryLongValueName) mapping3; 11 | mapping(string anotherVeryLongKeyName => uint256 anotherVeryLongValueName) mapping4; 12 | mapping(SomeVeryLongTypeName anotherVeryLongKeyName => uint256 anotherVeryLongValueName) mapping5; 13 | 14 | mapping( 15 | 16 | // comment1 17 | uint256 key => uint256 value 18 | // comment2 19 | ) mapping6; 20 | mapping( /* comment3 */ 21 | uint256 /* comment4 */ key /* comment5 */ => /* comment6 */ uint256 /* comment7 */ value /* comment8 */ /* comment9 */ 22 | ) /* comment10 */ mapping7; 23 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/ModifierDefinition/fmt.sol: -------------------------------------------------------------------------------- 1 | // config: line_length = 60 2 | contract ModifierDefinitions { 3 | modifier noParams() {} 4 | modifier oneParam(uint256 a) {} 5 | modifier twoParams(uint256 a, uint256 b) {} 6 | modifier threeParams(uint256 a, uint256 b, uint256 c) {} 7 | modifier fourParams( 8 | uint256 a, 9 | uint256 b, 10 | uint256 c, 11 | uint256 d 12 | ) {} 13 | modifier overridden() override(Base1, Base2) {} 14 | } 15 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ModifierDefinition/original.sol: -------------------------------------------------------------------------------- 1 | contract ModifierDefinitions { 2 | modifier noParams() {} 3 | modifier oneParam(uint a) {} 4 | modifier twoParams(uint a,uint b) {} 5 | modifier threeParams(uint a,uint b ,uint c) {} 6 | modifier fourParams(uint a,uint b ,uint c, uint d) {} 7 | modifier overridden ( 8 | ) override ( Base1 , Base2) {} 9 | } 10 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ModifierDefinition/override-spacing.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: line_length = 60 2 | // config: override_spacing = true 3 | contract ModifierDefinitions { 4 | modifier noParams() {} 5 | modifier oneParam(uint256 a) {} 6 | modifier twoParams(uint256 a, uint256 b) {} 7 | modifier threeParams(uint256 a, uint256 b, uint256 c) {} 8 | modifier fourParams( 9 | uint256 a, 10 | uint256 b, 11 | uint256 c, 12 | uint256 d 13 | ) {} 14 | modifier overridden() override (Base1, Base2) {} 15 | } 16 | -------------------------------------------------------------------------------- /crates/fmt/testdata/NumberLiteralUnderscore/fmt.sol: -------------------------------------------------------------------------------- 1 | contract NumberLiteral { 2 | function test() external { 3 | 1; 4 | 123_000; 5 | 1_2e345_678; 6 | -1; 7 | 2e-10; 8 | 0.1; 9 | 1.3; 10 | 2.5e1; 11 | 1.23454; 12 | 1.2e34_5_678; 13 | 134411.2e34_5_678; 14 | 13431.134112e34_135_678; 15 | 13431.0134112; 16 | 13431.134112e-139_3141340; 17 | 134411.2e34_5_6780; 18 | 13431.134112e34_135_6780; 19 | 0.134112; 20 | 1.0; 21 | 13431.134112e-139_3141340; 22 | 123e456; 23 | 1_000; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/fmt/testdata/NumberLiteralUnderscore/original.sol: -------------------------------------------------------------------------------- 1 | contract NumberLiteral { 2 | function test() external { 3 | 1; 4 | 123_000; 5 | 1_2e345_678; 6 | -1; 7 | 2e-10; 8 | .1; 9 | 1.3; 10 | 2.5e1; 11 | 1.23454e0; 12 | 1.2e34_5_678; 13 | 134411.2e34_5_678; 14 | 13431.134112e34_135_678; 15 | 13431.0134112; 16 | 13431.134112e-139_3141340; 17 | 00134411.200e0034_5_6780; 18 | 013431.13411200e34_135_6780; 19 | 00.1341120000; 20 | 1.0000; 21 | 0013431.13411200e-00139_3141340; 22 | 123E456; 23 | 1_000; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /crates/fmt/testdata/NumberLiteralUnderscore/preserve.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: number_underscore = "preserve" 2 | contract NumberLiteral { 3 | function test() external { 4 | 1; 5 | 123_000; 6 | 1_2e345_678; 7 | -1; 8 | 2e-10; 9 | 0.1; 10 | 1.3; 11 | 2.5e1; 12 | 1.23454; 13 | 1.2e34_5_678; 14 | 134411.2e34_5_678; 15 | 13431.134112e34_135_678; 16 | 13431.0134112; 17 | 13431.134112e-139_3141340; 18 | 134411.2e34_5_6780; 19 | 13431.134112e34_135_6780; 20 | 0.134112; 21 | 1.0; 22 | 13431.134112e-139_3141340; 23 | 123e456; 24 | 1_000; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /crates/fmt/testdata/NumberLiteralUnderscore/remove.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: number_underscore = "remove" 2 | contract NumberLiteral { 3 | function test() external { 4 | 1; 5 | 123000; 6 | 12e345678; 7 | -1; 8 | 2e-10; 9 | 0.1; 10 | 1.3; 11 | 2.5e1; 12 | 1.23454; 13 | 1.2e345678; 14 | 134411.2e345678; 15 | 13431.134112e34135678; 16 | 13431.0134112; 17 | 13431.134112e-1393141340; 18 | 134411.2e3456780; 19 | 13431.134112e341356780; 20 | 0.134112; 21 | 1.0; 22 | 13431.134112e-1393141340; 23 | 123e456; 24 | 1000; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /crates/fmt/testdata/NumberLiteralUnderscore/thousands.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: number_underscore = "thousands" 2 | contract NumberLiteral { 3 | function test() external { 4 | 1; 5 | 123_000; 6 | 12e345_678; 7 | -1; 8 | 2e-10; 9 | 0.1; 10 | 1.3; 11 | 2.5e1; 12 | 1.23454; 13 | 1.2e345_678; 14 | 134_411.2e345_678; 15 | 13_431.134112e34_135_678; 16 | 13_431.0134112; 17 | 13_431.134112e-1_393_141_340; 18 | 134_411.2e3_456_780; 19 | 13_431.134112e341_356_780; 20 | 0.134112; 21 | 1.0; 22 | 13_431.134112e-1_393_141_340; 23 | 123e456; 24 | 1000; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /crates/fmt/testdata/PragmaDirective/fmt.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.17; 2 | pragma experimental ABIEncoderV2; 3 | 4 | contract Contract {} 5 | 6 | // preserves lines 7 | pragma solidity 0.8.17; 8 | 9 | pragma experimental ABIEncoderV2; 10 | -------------------------------------------------------------------------------- /crates/fmt/testdata/PragmaDirective/original.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.17; 2 | pragma experimental ABIEncoderV2; 3 | 4 | contract Contract {} 5 | 6 | // preserves lines 7 | pragma solidity 0.8.17; 8 | 9 | pragma experimental ABIEncoderV2; -------------------------------------------------------------------------------- /crates/fmt/testdata/Repros/fmt.sol: -------------------------------------------------------------------------------- 1 | // Repros of fmt issues 2 | 3 | // https://github.com/foundry-rs/foundry/issues/4403 4 | function errorIdentifier() { 5 | bytes memory error = bytes(""); 6 | if (error.length > 0) {} 7 | } 8 | 9 | // https://github.com/foundry-rs/foundry/issues/7549 10 | function one() external { 11 | this.other({ 12 | data: abi.encodeCall( 13 | this.other, 14 | ( 15 | "bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla" 16 | ) 17 | ) 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /crates/fmt/testdata/Repros/original.sol: -------------------------------------------------------------------------------- 1 | // Repros of fmt issues 2 | 3 | // https://github.com/foundry-rs/foundry/issues/4403 4 | function errorIdentifier() { 5 | bytes memory error = bytes(""); 6 | if (error.length > 0) {} 7 | } 8 | 9 | // https://github.com/foundry-rs/foundry/issues/7549 10 | function one() external { 11 | this.other({ 12 | data: abi.encodeCall( 13 | this.other, 14 | ( 15 | "bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla" 16 | ) 17 | ) 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /crates/fmt/testdata/SortedImports/original.sol: -------------------------------------------------------------------------------- 1 | import "SomeFile3.sol"; 2 | import "SomeFile2.sol"; 3 | import "SomeFile1.sol" as SomeOtherFile; 4 | import "SomeFile0.sol" as SomeOtherFile; 5 | 6 | import "AnotherFile2.sol" as SomeSymbol; 7 | import "AnotherFile1.sol" as SomeSymbol; 8 | 9 | import {symbol2, symbol1 as alias} from "File3.sol"; 10 | import {symbol2, symbol1 as alias} from "File2.sol"; 11 | import {symbol2 as alias2, symbol1 as alias1, symbol3 as alias3, symbol4} from "File6.sol"; 12 | import {symbol3 as alias1, symbol2 as alias2, symbol1 as alias3, symbol4} from "File0.sol"; 13 | 14 | uint256 constant someConstant = 10; 15 | 16 | import {Something3, Something2} from "someFile.sol"; 17 | 18 | // This is a comment 19 | import {Something3, Something2} from "someFile.sol"; 20 | 21 | import {symbol2, symbol1 as alias} from "File3.sol"; 22 | // comment inside group is treated as a separator for now 23 | import {symbol2, symbol1 as alias} from "File2.sol"; -------------------------------------------------------------------------------- /crates/fmt/testdata/StatementBlock/bracket-spacing.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: bracket_spacing = true 2 | contract Contract { 3 | function test() { 4 | unchecked { 5 | a += 1; 6 | } 7 | 8 | unchecked { 9 | a += 1; 10 | } 11 | 2 + 2; 12 | 13 | unchecked { 14 | a += 1; 15 | } 16 | unchecked { } 17 | 18 | 1 + 1; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /crates/fmt/testdata/StatementBlock/fmt.sol: -------------------------------------------------------------------------------- 1 | contract Contract { 2 | function test() { 3 | unchecked { 4 | a += 1; 5 | } 6 | 7 | unchecked { 8 | a += 1; 9 | } 10 | 2 + 2; 11 | 12 | unchecked { 13 | a += 1; 14 | } 15 | unchecked {} 16 | 17 | 1 + 1; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /crates/fmt/testdata/StatementBlock/original.sol: -------------------------------------------------------------------------------- 1 | contract Contract { 2 | function test() { unchecked { a += 1; } 3 | 4 | unchecked { 5 | a += 1; 6 | } 7 | 2 + 2; 8 | 9 | unchecked { a += 1; 10 | } 11 | unchecked {} 12 | 13 | 1 + 1; 14 | 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/StructDefinition/bracket-spacing.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: bracket_spacing = true 2 | struct Foo { } 3 | 4 | struct Bar { 5 | uint256 foo; 6 | string bar; 7 | } 8 | 9 | struct MyStruct { 10 | // first 1 11 | // first 2 12 | uint256 field1; 13 | // second 14 | uint256 field2; 15 | } 16 | -------------------------------------------------------------------------------- /crates/fmt/testdata/StructDefinition/fmt.sol: -------------------------------------------------------------------------------- 1 | struct Foo {} 2 | 3 | struct Bar { 4 | uint256 foo; 5 | string bar; 6 | } 7 | 8 | struct MyStruct { 9 | // first 1 10 | // first 2 11 | uint256 field1; 12 | // second 13 | uint256 field2; 14 | } 15 | -------------------------------------------------------------------------------- /crates/fmt/testdata/StructDefinition/original.sol: -------------------------------------------------------------------------------- 1 | struct Foo { 2 | } struct Bar { uint foo ;string bar ; } 3 | 4 | struct MyStruct { 5 | // first 1 6 | // first 2 7 | uint256 field1; 8 | // second 9 | uint256 field2; 10 | } 11 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ThisExpression/fmt.sol: -------------------------------------------------------------------------------- 1 | contract ThisExpression { 2 | function someFunc() public {} 3 | function someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword() 4 | public 5 | {} 6 | 7 | function test() external { 8 | this.someFunc(); 9 | this.someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword(); 10 | this // comment1 11 | .someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword(); 12 | address(this).balance; 13 | 14 | address thisAddress = address( 15 | // comment2 16 | /* comment3 */ 17 | this // comment 4 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /crates/fmt/testdata/ThisExpression/original.sol: -------------------------------------------------------------------------------- 1 | contract ThisExpression { 2 | function someFunc() public {} 3 | function someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword() public {} 4 | 5 | function test() external { 6 | this.someFunc(); 7 | this.someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword(); 8 | this // comment1 9 | .someVeryVeryVeryLongVariableNameThatWillBeAccessedByThisKeyword(); 10 | address(this).balance; 11 | 12 | address thisAddress = address( 13 | // comment2 14 | /* comment3 */ this // comment 4 15 | ); 16 | } 17 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/TrailingComma/fmt.sol: -------------------------------------------------------------------------------- 1 | contract C is Contract { 2 | modifier m(uint256) {} 3 | // invalid solidity code, but valid pt 4 | modifier m2(uint256) returns (uint256) {} 5 | 6 | function f(uint256 a) external {} 7 | function f2(uint256 a, bytes32 b) external returns (uint256) {} 8 | 9 | function f3() external { 10 | try some.invoke() returns (uint256, uint256) {} catch {} 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /crates/fmt/testdata/TrailingComma/original.sol: -------------------------------------------------------------------------------- 1 | contract C is Contract { 2 | modifier m(uint256, ,,, ) {} 3 | // invalid solidity code, but valid pt 4 | modifier m2(uint256) returns (uint256,,,) {} 5 | 6 | function f(uint256 a, ) external {} 7 | function f2(uint256 a, , , ,bytes32 b) external returns (uint256,,,,) {} 8 | 9 | function f3() external { 10 | try some.invoke() returns (uint256,,,uint256) {} catch {} 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /crates/fmt/testdata/TypeDefinition/fmt.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.8; 2 | 3 | type Hello is uint256; 4 | 5 | contract TypeDefinition { 6 | event Moon(Hello world); 7 | 8 | function demo(Hello world) public { 9 | world = Hello.wrap(Hello.unwrap(world) + 1337); 10 | emit Moon(world); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /crates/fmt/testdata/TypeDefinition/original.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.8; 2 | 3 | type Hello is uint; 4 | 5 | contract TypeDefinition { 6 | event Moon(Hello world); 7 | 8 | function demo(Hello world) public { 9 | world = Hello.wrap(Hello.unwrap(world) + 1337); 10 | emit Moon(world); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /crates/fmt/testdata/UnitExpression/fmt.sol: -------------------------------------------------------------------------------- 1 | contract UnitExpression { 2 | function test() external { 3 | uint256 timestamp; 4 | timestamp = 1 seconds; 5 | timestamp = 1 minutes; 6 | timestamp = 1 hours; 7 | timestamp = 1 days; 8 | timestamp = 1 weeks; 9 | 10 | uint256 value; 11 | value = 1 wei; 12 | value = 1 gwei; 13 | value = 1 ether; 14 | 15 | uint256 someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue; 16 | 17 | value = someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue 18 | * 1 /* comment1 */ ether; // comment2 19 | 20 | value = 1 // comment3 21 | // comment4 22 | ether; // comment5 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/fmt/testdata/UnitExpression/original.sol: -------------------------------------------------------------------------------- 1 | contract UnitExpression { 2 | function test() external { 3 | uint256 timestamp; 4 | timestamp = 1 seconds; 5 | timestamp = 1 minutes; 6 | timestamp = 1 hours; 7 | timestamp = 1 days; 8 | timestamp = 1 weeks; 9 | 10 | uint256 value; 11 | value = 1 wei; 12 | value = 1 gwei; 13 | value = 1 ether; 14 | 15 | uint256 someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue; 16 | 17 | value = someVeryVeryVeryLongVariableNameForTheMultiplierForEtherValue * 1 /* comment1 */ ether; // comment2 18 | 19 | value = 1 // comment3 20 | // comment4 21 | ether; // comment5 22 | } 23 | } -------------------------------------------------------------------------------- /crates/fmt/testdata/UsingDirective/original.sol: -------------------------------------------------------------------------------- 1 | contract UsingExampleContract { 2 | using UsingExampleLibrary for * ; 3 | using UsingExampleLibrary for uint; 4 | using Example.UsingExampleLibrary for uint; 5 | using { M.g, M.f} for uint; 6 | using UsingExampleLibrary for uint global; 7 | using { These, Are, MultipleLibraries, ThatNeedToBePut, OnSeparateLines } for uint; 8 | using { This.isareally.longmember.access.expression.that.needs.to.besplit.into.lines } for uint; 9 | using {and as &, or as |, xor as ^, cpl as ~} for Bitmap global; 10 | using {eq as ==, ne as !=, lt as <, lte as <=, gt as >, gte as >=} for Bitmap global; 11 | } 12 | -------------------------------------------------------------------------------- /crates/fmt/testdata/VariableAssignment/bracket-spacing.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: bracket_spacing = true 2 | contract TestContract { 3 | function aLongerTestFunctionName(uint256 input) 4 | public 5 | view 6 | returns (uint256 num) 7 | { 8 | (, uint256 second) = (1, 2); 9 | (uint256 listItem001) = 1; 10 | (uint256 listItem002, uint256 listItem003) = (10, 20); 11 | (uint256 listItem004, uint256 listItem005, uint256 listItem006) = 12 | (10, 20, 30); 13 | ( 14 | uint256 listItem007, 15 | uint256 listItem008, 16 | uint256 listItem009, 17 | uint256 listItem010 18 | ) = (10, 20, 30, 40); 19 | return 1; 20 | } 21 | 22 | function test() external { 23 | uint256 value = map[key]; 24 | uint256 allowed = allowance[from][msg.sender]; 25 | allowance[from][msg.sender] = allowed; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /crates/fmt/testdata/VariableAssignment/fmt.sol: -------------------------------------------------------------------------------- 1 | contract TestContract { 2 | function aLongerTestFunctionName(uint256 input) 3 | public 4 | view 5 | returns (uint256 num) 6 | { 7 | (, uint256 second) = (1, 2); 8 | (uint256 listItem001) = 1; 9 | (uint256 listItem002, uint256 listItem003) = (10, 20); 10 | (uint256 listItem004, uint256 listItem005, uint256 listItem006) = 11 | (10, 20, 30); 12 | ( 13 | uint256 listItem007, 14 | uint256 listItem008, 15 | uint256 listItem009, 16 | uint256 listItem010 17 | ) = (10, 20, 30, 40); 18 | return 1; 19 | } 20 | 21 | function test() external { 22 | uint256 value = map[key]; 23 | uint256 allowed = allowance[from][msg.sender]; 24 | allowance[from][msg.sender] = allowed; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /crates/fmt/testdata/VariableAssignment/original.sol: -------------------------------------------------------------------------------- 1 | contract TestContract { 2 | function aLongerTestFunctionName(uint256 input) 3 | public 4 | view 5 | returns (uint256 num) 6 | { 7 | (, uint256 second) = (1, 2); 8 | (uint256 listItem001) = 1; 9 | (uint256 listItem002, uint256 listItem003) = (10, 20); 10 | (uint256 listItem004, uint256 listItem005, uint256 listItem006) = 11 | (10, 20, 30); 12 | ( 13 | uint256 listItem007, 14 | uint256 listItem008, 15 | uint256 listItem009, 16 | uint256 listItem010 17 | ) = (10, 20, 30, 40); 18 | return 1; 19 | } 20 | 21 | function test() external { 22 | uint256 value = map[key]; 23 | uint256 allowed = allowance[from][msg.sender]; 24 | allowance[from][msg.sender] = allowed; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /crates/fmt/testdata/YulStrings/fmt.sol: -------------------------------------------------------------------------------- 1 | contract Yul { 2 | function test() external { 3 | assembly { 4 | let a := "abc" 5 | let b := "abc" 6 | let c := "abc":u32 7 | let d := "abc":u32 8 | let e := hex"deadbeef" 9 | let f := hex"deadbeef" 10 | let g := hex"deadbeef":u32 11 | let h := hex"deadbeef":u32 12 | datacopy(0, dataoffset("runtime"), datasize("runtime")) 13 | return(0, datasize("runtime")) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /crates/fmt/testdata/YulStrings/original.sol: -------------------------------------------------------------------------------- 1 | contract Yul { 2 | function test() external { 3 | assembly { 4 | let a := "abc" 5 | let b := 'abc' 6 | let c := "abc":u32 7 | let d := 'abc':u32 8 | let e := hex"deadbeef" 9 | let f := hex'deadbeef' 10 | let g := hex"deadbeef":u32 11 | let h := hex'deadbeef':u32 12 | datacopy(0, dataoffset('runtime'), datasize("runtime")) 13 | return(0, datasize("runtime")) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /crates/fmt/testdata/YulStrings/preserve-quote.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: quote_style = "preserve" 2 | contract Yul { 3 | function test() external { 4 | assembly { 5 | let a := "abc" 6 | let b := 'abc' 7 | let c := "abc":u32 8 | let d := 'abc':u32 9 | let e := hex"deadbeef" 10 | let f := hex'deadbeef' 11 | let g := hex"deadbeef":u32 12 | let h := hex'deadbeef':u32 13 | datacopy(0, dataoffset('runtime'), datasize("runtime")) 14 | return(0, datasize("runtime")) 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /crates/fmt/testdata/YulStrings/single-quote.fmt.sol: -------------------------------------------------------------------------------- 1 | // config: quote_style = "single" 2 | contract Yul { 3 | function test() external { 4 | assembly { 5 | let a := 'abc' 6 | let b := 'abc' 7 | let c := 'abc':u32 8 | let d := 'abc':u32 9 | let e := hex'deadbeef' 10 | let f := hex'deadbeef' 11 | let g := hex'deadbeef':u32 12 | let h := hex'deadbeef':u32 13 | datacopy(0, dataoffset('runtime'), datasize('runtime')) 14 | return(0, datasize('runtime')) 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /crates/forge/assets/.gitignoreTemplate: -------------------------------------------------------------------------------- 1 | # Compiler files 2 | cache/ 3 | out/ 4 | 5 | # Ignores development broadcast logs 6 | !/broadcast 7 | /broadcast/*/31337/ 8 | /broadcast/**/dry-run/ 9 | 10 | # Docs 11 | docs/ 12 | 13 | # Dotenv file 14 | .env 15 | -------------------------------------------------------------------------------- /crates/forge/assets/CounterTemplate.s.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import {Script, console} from "forge-std/Script.sol"; 5 | import {Counter} from "../src/Counter.sol"; 6 | 7 | contract CounterScript is Script { 8 | Counter public counter; 9 | 10 | function setUp() public {} 11 | 12 | function run() public { 13 | vm.startBroadcast(); 14 | 15 | counter = new Counter(); 16 | 17 | vm.stopBroadcast(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /crates/forge/assets/CounterTemplate.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | contract Counter { 5 | uint256 public number; 6 | 7 | function setNumber(uint256 newNumber) public { 8 | number = newNumber; 9 | } 10 | 11 | function increment() public { 12 | number++; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /crates/forge/assets/CounterTemplate.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import {Test, console} from "forge-std/Test.sol"; 5 | import {Counter} from "../src/Counter.sol"; 6 | 7 | contract CounterTest is Test { 8 | Counter public counter; 9 | 10 | function setUp() public { 11 | counter = new Counter(); 12 | counter.setNumber(0); 13 | } 14 | 15 | function test_Increment() public { 16 | counter.increment(); 17 | assertEq(counter.number(), 1); 18 | } 19 | 20 | function testFuzz_SetNumber(uint256 x) public { 21 | counter.setNumber(x); 22 | assertEq(counter.number(), x); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /crates/forge/assets/generated/TestTemplate.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import {Test, console} from "forge-std/Test.sol"; 5 | import {{contract_name}} from "../src/{contract_name}.sol"; 6 | 7 | contract {contract_name}Test is Test { 8 | {contract_name} public {instance_name}; 9 | 10 | function setUp() public { 11 | {instance_name} = new {contract_name}(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /crates/forge/assets/workflowTemplate.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | workflow_dispatch: 7 | 8 | env: 9 | FOUNDRY_PROFILE: ci 10 | 11 | jobs: 12 | check: 13 | strategy: 14 | fail-fast: true 15 | 16 | name: Foundry project 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v4 20 | with: 21 | submodules: recursive 22 | 23 | - name: Install Foundry 24 | uses: foundry-rs/foundry-toolchain@v1 25 | with: 26 | version: nightly 27 | 28 | - name: Show Forge version 29 | run: | 30 | forge --version 31 | 32 | - name: Run Forge fmt 33 | run: | 34 | forge fmt --check 35 | id: fmt 36 | 37 | - name: Run Forge build 38 | run: | 39 | forge build --sizes 40 | id: build 41 | 42 | - name: Run Forge tests 43 | run: | 44 | forge test -vvv 45 | id: test 46 | -------------------------------------------------------------------------------- /crates/forge/benches/test.rs: -------------------------------------------------------------------------------- 1 | use criterion::{criterion_group, criterion_main, Criterion}; 2 | use foundry_test_utils::{util::setup_forge_remote, TestCommand, TestProject}; 3 | 4 | /// Returns a cloned and `forge built` `solmate` project 5 | fn built_solmate() -> (TestProject, TestCommand) { 6 | setup_forge_remote("transmissions11/solmate") 7 | } 8 | 9 | fn forge_test_benchmark(c: &mut Criterion) { 10 | let (prj, _) = built_solmate(); 11 | 12 | let mut group = c.benchmark_group("forge test"); 13 | group.sample_size(10); 14 | group.bench_function("solmate", |b| { 15 | let mut cmd = prj.forge_command(); 16 | cmd.arg("test"); 17 | b.iter(|| { 18 | cmd.print_output(); 19 | }); 20 | }); 21 | } 22 | 23 | criterion_group!(benches, forge_test_benchmark); 24 | criterion_main!(benches); 25 | -------------------------------------------------------------------------------- /crates/forge/bin/cmd/geiger/error.rs: -------------------------------------------------------------------------------- 1 | use forge_fmt::FormatterError; 2 | use foundry_common::errors::FsPathError; 3 | 4 | /// Possible errors when scanning a solidity file 5 | #[derive(Debug, thiserror::Error)] 6 | pub enum ScanFileError { 7 | #[error(transparent)] 8 | Io(#[from] FsPathError), 9 | #[error(transparent)] 10 | ParseSol(#[from] FormatterError), 11 | } 12 | -------------------------------------------------------------------------------- /crates/forge/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | vergen::EmitBuilder::builder().build_timestamp().git_sha(true).emit().unwrap(); 3 | } 4 | -------------------------------------------------------------------------------- /crates/forge/tests/cli/cache.rs: -------------------------------------------------------------------------------- 1 | //! Tests for various cache command. 2 | 3 | forgetest!(can_list_cache, |_prj, cmd| { 4 | cmd.args(["cache", "ls"]); 5 | cmd.assert_success(); 6 | }); 7 | 8 | forgetest!(can_list_cache_all, |_prj, cmd| { 9 | cmd.args(["cache", "ls", "all"]); 10 | cmd.assert_success(); 11 | }); 12 | 13 | forgetest!(can_list_specific_chain, |_prj, cmd| { 14 | cmd.args(["cache", "ls", "mainnet"]); 15 | cmd.assert_success(); 16 | }); 17 | 18 | forgetest_init!(can_test_no_cache, |prj, cmd| { 19 | prj.clear_cache(); 20 | 21 | cmd.args(["test", "--no-cache"]).assert_success(); 22 | assert!(!prj.cache().exists(), "cache file should not exist"); 23 | 24 | cmd.forge_fuse().arg("test").assert_success(); 25 | assert!(prj.cache().exists(), "cache file should exist"); 26 | }); 27 | -------------------------------------------------------------------------------- /crates/forge/tests/cli/constants.rs: -------------------------------------------------------------------------------- 1 | //! various constants 2 | 3 | pub const TEMPLATE_CONTRACT: &str = "Counter"; 4 | 5 | pub const TEMPLATE_TEST_CONTRACT: &str = "CounterTest"; 6 | 7 | pub const TEMPLATE_CONTRACT_ARTIFACT_BASE: &str = "Counter.sol/Counter"; 8 | 9 | pub const TEMPLATE_CONTRACT_ARTIFACT_JSON: &str = "Counter.sol/Counter.json"; 10 | 11 | pub const TEMPLATE_TEST_CONTRACT_ARTIFACT_JSON: &str = "Counter.t.sol/CounterTest.json"; 12 | -------------------------------------------------------------------------------- /crates/forge/tests/cli/doc.rs: -------------------------------------------------------------------------------- 1 | use foundry_test_utils::util::{setup_forge_remote, RemoteProject}; 2 | 3 | #[test] 4 | fn can_generate_solmate_docs() { 5 | let (prj, _) = 6 | setup_forge_remote(RemoteProject::new("transmissions11/solmate").set_build(false)); 7 | prj.forge_command().args(["doc", "--build"]).assert_success(); 8 | } 9 | -------------------------------------------------------------------------------- /crates/forge/tests/cli/main.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate foundry_test_utils; 3 | 4 | pub mod constants; 5 | pub mod utils; 6 | 7 | mod bind_json; 8 | mod build; 9 | mod cache; 10 | mod cmd; 11 | mod config; 12 | mod context; 13 | mod coverage; 14 | mod create; 15 | mod debug; 16 | mod doc; 17 | mod multi_script; 18 | mod script; 19 | mod soldeer; 20 | mod svm; 21 | mod test_cmd; 22 | mod verify; 23 | 24 | mod ext_integration; 25 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_build_path_with_one_file.stdout: -------------------------------------------------------------------------------- 1 | Compiling 1 files with 0.8.23 2 | Solc 0.8.23 finished in 33.25ms 3 | Compiler run successful! 4 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_build_path_with_three_files.stdout: -------------------------------------------------------------------------------- 1 | Compiling 3 files with 0.8.23 2 | Solc 0.8.23 finished in 33.25ms 3 | Compiler run successful! 4 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_build_path_with_two_files.stdout: -------------------------------------------------------------------------------- 1 | Compiling 2 files with 0.8.23 2 | Solc 0.8.23 finished in 33.25ms 3 | Compiler run successful! 4 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_build_skip_contracts.stdout: -------------------------------------------------------------------------------- 1 | Compiling 1 files with 0.8.23 2 | Solc 0.8.23 finished in 34.45ms 3 | Compiler run successful! 4 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_build_skip_glob.stdout: -------------------------------------------------------------------------------- 1 | Compiling 1 files with 0.8.23 2 | Solc 0.8.23 finished in 33.25ms 3 | Compiler run successful! 4 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_check_snapshot.stdout: -------------------------------------------------------------------------------- 1 | Compiling 2 files with 0.8.23 2 | Solc 0.8.23 finished in 424.55ms 3 | Compiler run successful! 4 | 5 | Ran 1 test for src/ATest.t.sol:ATest 6 | [PASS] testExample() (gas: 168) 7 | Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.42ms 8 | 9 | Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) 10 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_detect_dirty_git_status_on_init.stderr: -------------------------------------------------------------------------------- 1 | Error: 2 | The target directory is a part of or on its own an already initialized git repository, 3 | and it requires clean working and staging areas, including no untracked files. 4 | 5 | Check the current git repository's status with `git status`. 6 | Then, you can track files with `git add ...` and then commit them with `git commit`, 7 | ignore them in the `.gitignore` file, or run this command again with the `--no-commit` flag. 8 | 9 | If none of the previous steps worked, please open an issue at: 10 | https://github.com/foundry-rs/foundry/issues/new/choose 11 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_execute_script_and_skip_contracts.stdout: -------------------------------------------------------------------------------- 1 | Compiling 1 files with 0.8.23 2 | Solc 0.8.23 3 | Compiler run successful! 4 | Script ran successfully. 5 | Gas used: 22900 6 | 7 | == Return == 8 | result: uint256 255 9 | 1: uint8 3 10 | 11 | == Logs == 12 | script ran 13 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_execute_script_command.stdout: -------------------------------------------------------------------------------- 1 | Compiling 1 files with 0.8.23 2 | Solc 0.8.23 finished in 23.34ms 3 | Compiler run successful! 4 | Script ran successfully. 5 | Gas used: 22815 6 | 7 | == Logs == 8 | script ran 9 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_execute_script_command_fqn.stdout: -------------------------------------------------------------------------------- 1 | Compiling 1 files with 0.8.23 2 | Solc 0.8.23 finished in 23.70ms 3 | Compiler run successful! 4 | Script ran successfully. 5 | Gas used: 22815 6 | 7 | == Logs == 8 | script ran 9 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_execute_script_command_with_args.stdout: -------------------------------------------------------------------------------- 1 | Compiling 1 files with 0.8.23 2 | Solc 0.8.23 finished in 35.28ms 3 | Compiler run successful! 4 | Script ran successfully. 5 | Gas used: 25301 6 | 7 | == Logs == 8 | script ran 9 | 1 10 | 2 11 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_execute_script_command_with_returned.stdout: -------------------------------------------------------------------------------- 1 | Compiling 1 files with 0.8.23 2 | Solc 0.8.23 finished in 1.27s 3 | Compiler run successful! 4 | Script ran successfully. 5 | Gas used: 22900 6 | 7 | == Return == 8 | result: uint256 255 9 | 1: uint8 3 10 | 11 | == Logs == 12 | script ran 13 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_execute_script_command_with_sig.stdout: -------------------------------------------------------------------------------- 1 | Compiling 1 files with 0.8.23 2 | Solc 0.8.23 finished in 24.49ms 3 | Compiler run successful! 4 | Script ran successfully. 5 | Gas used: 22815 6 | 7 | == Logs == 8 | script ran 9 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_run_test_in_custom_test_folder.stdout: -------------------------------------------------------------------------------- 1 | Compiling 2 files with 0.8.23 2 | Solc 0.8.23 finished in 185.25ms 3 | Compiler run successful! 4 | 5 | Ran 1 test for src/nested/forge-tests/MyTest.t.sol:MyTest 6 | [PASS] testTrue() (gas: 168) 7 | Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.93ms 8 | 9 | Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) 10 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_set_yul_optimizer.stderr: -------------------------------------------------------------------------------- 1 | Error: 2 | Compiler run failed: 3 | Error (6553): The msize instruction cannot be used when the Yul optimizer is activated because it can change its semantics. Either disable the Yul optimizer or do not use the instruction. 4 | --> src/Foo.sol:6:8: 5 | | 6 | 6 | assembly { 7 | | ^ (Relevant source part starts here and spans across multiple lines). 8 | 9 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_test_repeatedly.stdout: -------------------------------------------------------------------------------- 1 | No files changed, compilation skipped 2 | 3 | Ran 2 tests for test/Counter.t.sol:CounterTest 4 | [PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 26521, ~: 28387) 5 | <<<<<<< HEAD 6 | [PASS] test_Increment() (gas: 28379) 7 | ======= 8 | [PASS] test_Increment() (gas: 31303) 9 | >>>>>>> upstream/master 10 | Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 9.42ms 11 | 12 | Ran 1 test suite: 2 tests passed, 0 failed, 0 skipped (2 total tests) 13 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/can_use_libs_in_multi_fork.stdout: -------------------------------------------------------------------------------- 1 | Compiling 2 files with 0.8.23 2 | Solc 0.8.23 finished in 1.95s 3 | Compiler run successful! 4 | 5 | Ran 1 test for test/Contract.t.sol:ContractTest 6 | [PASS] test() (gas: 70360) 7 | Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.21s 8 | 9 | Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) 10 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/compile_json.stdout: -------------------------------------------------------------------------------- 1 | { 2 | "contracts": {}, 3 | "errors": [ 4 | { 5 | "sourceLocation": { 6 | "file": "src/jsonError.sol", 7 | "start": 184, 8 | "end": 193 9 | }, 10 | "type": "DeclarationError", 11 | "component": "general", 12 | "severity": "error", 13 | "errorCode": "7576", 14 | "message": "Undeclared identifier. Did you mean \"newNumber\"?", 15 | "formattedMessage": "DeclarationError: Undeclared identifier. Did you mean \"newNumber\"?\n --> src/jsonError.sol:7:18:\n |\n7 | number = newnumber; // error here\n | ^^^^^^^^^\n\n" 16 | } 17 | ], 18 | "sources": {}, 19 | "build_infos": ["{...}"] 20 | } -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/include_custom_types_in_traces.stdout: -------------------------------------------------------------------------------- 1 | Compiling 1 files with 0.8.23 2 | Solc 0.8.23 finished in 798.51ms 3 | Compiler run successful! 4 | 5 | Ran 2 tests for test/Contract.t.sol:CustomTypesTest 6 | [FAIL. Reason: PoolNotInitialized()] testErr() (gas: 254) 7 | Traces: 8 | [254] CustomTypesTest::testErr() 9 | └─ ← [Revert] PoolNotInitialized() 10 | 11 | [PASS] testEvent() (gas: 1268) 12 | Traces: 13 | [1268] CustomTypesTest::testEvent() 14 | ├─ emit MyEvent(a: 100) 15 | └─ ← [Stop] 16 | 17 | Suite result: FAILED. 1 passed; 1 failed; 0 skipped; finished in 3.88ms 18 | 19 | Ran 1 test suite: 1 tests passed, 1 failed, 0 skipped (2 total tests) 20 | 21 | Failing tests: 22 | Encountered 1 failing test in test/Contract.t.sol:CustomTypesTest 23 | [FAIL. Reason: PoolNotInitialized()] testErr() (gas: 254) 24 | 25 | Encountered a total of 1 failing tests, 1 tests succeeded 26 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/replay_last_run_failures.stdout: -------------------------------------------------------------------------------- 1 | No files changed, compilation skipped 2 | 3 | Ran 2 tests for test/ReplayFailures.t.sol:ReplayFailuresTest 4 | [FAIL. Reason: revert: testB failed] testB() (gas: 303) 5 | [FAIL. Reason: revert: testD failed] testD() (gas: 314) 6 | Suite result: FAILED. 0 passed; 2 failed; 0 skipped; finished in 555.95µs (250.31µs CPU time) 7 | 8 | Ran 1 test suite in 3.24ms (555.95µs CPU time): 0 tests passed, 2 failed, 0 skipped (2 total tests) 9 | 10 | Failing tests: 11 | Encountered 2 failing tests in test/ReplayFailures.t.sol:ReplayFailuresTest 12 | [FAIL. Reason: revert: testB failed] testB() (gas: 303) 13 | [FAIL. Reason: revert: testD failed] testD() (gas: 314) 14 | 15 | Encountered a total of 2 failing tests, 0 tests succeeded 16 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/repro_6531.stdout: -------------------------------------------------------------------------------- 1 | Compiling 1 files with 0.8.23 2 | 3 | Compiler run successful! 4 | 5 | Ran 1 test for test/Contract.t.sol:USDTCallingTest 6 | [PASS] test() (gas: 9537) 7 | Traces: 8 | [9537] USDTCallingTest::test() 9 | ├─ [0] VM::createSelectFork("") 10 | │ └─ ← [Return] 0 11 | ├─ [3110] 0xdAC17F958D2ee523a2206206994597C13D831ec7::name() [staticcall] 12 | │ └─ ← [Return] "Tether USD" 13 | └─ ← [Stop] 14 | 15 | Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 3.43s 16 | 17 | Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) 18 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.1.stdout: -------------------------------------------------------------------------------- 1 | Compiling 2 files with 0.8.23 2 | Solc 0.8.23 finished in 185.25ms 3 | Compiler run successful! 4 | 5 | Ran 1 test for src/Contract.t.sol:ContractTest 6 | [PASS] testExample() (gas: 190) 7 | Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms 8 | 9 | Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) 10 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/runs_tests_exactly_once_with_changed_versions.2.stdout: -------------------------------------------------------------------------------- 1 | Compiling 2 files with 0.8.22 2 | Solc 0.8.22 finished in 185.25ms 3 | Compiler run successful! 4 | 5 | Ran 1 test for src/Contract.t.sol:ContractTest 6 | [PASS] testExample() (gas: 190) 7 | Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.89ms 8 | 9 | Ran 1 test suite: 1 tests passed, 0 failed, 0 skipped (1 total tests) 10 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/suggest_when_no_tests_match.stdout: -------------------------------------------------------------------------------- 1 | No tests match the provided pattern: 2 | match-test: `testA.*` 3 | no-match-test: `testB.*` 4 | match-contract: `TestC.*` 5 | no-match-contract: `TestD.*` 6 | match-path: `*TestE*` 7 | no-match-path: `*TestF*` 8 | 9 | Did you mean `test1`? 10 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/warn_no_tests.stdout: -------------------------------------------------------------------------------- 1 | No tests found in project! Forge looks for functions that starts with `test`. 2 | -------------------------------------------------------------------------------- /crates/forge/tests/fixtures/warn_no_tests_match.stdout: -------------------------------------------------------------------------------- 1 | No tests match the provided pattern: 2 | match-test: `testA.*` 3 | no-match-test: `testB.*` 4 | match-contract: `TestC.*` 5 | no-match-contract: `TestD.*` 6 | match-path: `*TestE*` 7 | no-match-path: `*TestF*` 8 | -------------------------------------------------------------------------------- /crates/forge/tests/it/main.rs: -------------------------------------------------------------------------------- 1 | pub mod config; 2 | pub mod test_helpers; 3 | 4 | mod cheats; 5 | mod core; 6 | mod fork; 7 | mod fs; 8 | mod fuzz; 9 | mod inline; 10 | mod invariant; 11 | mod repros; 12 | mod spec; 13 | mod vyper; 14 | -------------------------------------------------------------------------------- /crates/forge/tests/it/spec.rs: -------------------------------------------------------------------------------- 1 | //! Integration tests for EVM specifications. 2 | 3 | use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; 4 | use foundry_evm::revm::primitives::SpecId; 5 | use foundry_test_utils::Filter; 6 | 7 | #[tokio::test(flavor = "multi_thread")] 8 | async fn test_shanghai_compat() { 9 | let filter = Filter::new("", "ShanghaiCompat", ".*spec"); 10 | TestConfig::with_filter(TEST_DATA_DEFAULT.runner(), filter) 11 | .evm_spec(SpecId::SHANGHAI) 12 | .run() 13 | .await; 14 | } 15 | -------------------------------------------------------------------------------- /crates/forge/tests/it/vyper.rs: -------------------------------------------------------------------------------- 1 | //! Integration tests for EVM specifications. 2 | 3 | use crate::{config::*, test_helpers::TEST_DATA_DEFAULT}; 4 | use foundry_test_utils::Filter; 5 | 6 | #[tokio::test(flavor = "multi_thread")] 7 | async fn test_basic_vyper_test() { 8 | let filter = Filter::new("", "CounterTest", ".*vyper"); 9 | TestConfig::with_filter(TEST_DATA_DEFAULT.runner(), filter).run().await; 10 | } 11 | -------------------------------------------------------------------------------- /crates/forge/tests/rpc-cache-keyfile: -------------------------------------------------------------------------------- 1 | This file serves as the key for the github actions/cache 2 | 3 | Any change in this file will invalidate the cache in CI that stores RPC data. 4 | 5 | Last updated: 05-26-2022 -------------------------------------------------------------------------------- /crates/linking/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-linking" 3 | description = "Smart contract linking tools" 4 | 5 | version.workspace = true 6 | edition.workspace = true 7 | rust-version.workspace = true 8 | authors.workspace = true 9 | license.workspace = true 10 | homepage.workspace = true 11 | repository.workspace = true 12 | 13 | [lints] 14 | workspace = true 15 | 16 | [dependencies] 17 | foundry-compilers = { workspace = true, features = ["full"] } 18 | semver.workspace = true 19 | alloy-primitives = { workspace = true, features = ["rlp"] } 20 | thiserror.workspace = true 21 | -------------------------------------------------------------------------------- /crates/macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "foundry-macros" 3 | 4 | version.workspace = true 5 | edition.workspace = true 6 | rust-version.workspace = true 7 | authors.workspace = true 8 | license.workspace = true 9 | homepage.workspace = true 10 | repository.workspace = true 11 | 12 | [lints] 13 | workspace = true 14 | 15 | [lib] 16 | proc-macro = true 17 | # proc-macro tests aren't fully supported by cargo-nextest archives 18 | test = false 19 | doc = false 20 | 21 | [dependencies] 22 | proc-macro2 = "1.0" 23 | quote = "1.0" 24 | syn = "2.0" 25 | proc-macro-error = "1" 26 | -------------------------------------------------------------------------------- /crates/macros/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # foundry-macros 2 | //! 3 | //! Internal Foundry proc-macros. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | #[macro_use] 9 | extern crate proc_macro_error; 10 | 11 | use proc_macro::TokenStream; 12 | use proc_macro_error::proc_macro_error; 13 | use syn::{parse_macro_input, DeriveInput, Error}; 14 | 15 | mod cheatcodes; 16 | mod console_fmt; 17 | 18 | #[proc_macro_derive(ConsoleFmt)] 19 | pub fn console_fmt(input: TokenStream) -> TokenStream { 20 | let input = parse_macro_input!(input as DeriveInput); 21 | console_fmt::console_fmt(&input).into() 22 | } 23 | 24 | #[proc_macro_derive(Cheatcode, attributes(cheatcode))] 25 | #[proc_macro_error] 26 | pub fn cheatcode(input: TokenStream) -> TokenStream { 27 | let input = parse_macro_input!(input as DeriveInput); 28 | cheatcodes::derive_cheatcode(&input).unwrap_or_else(Error::into_compile_error).into() 29 | } 30 | -------------------------------------------------------------------------------- /crates/sol-macro-gen/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "forge-sol-macro-gen" 3 | description = "Contains types and methods for generating rust bindings using sol!" 4 | publish = false 5 | 6 | version.workspace = true 7 | edition.workspace = true 8 | rust-version.workspace = true 9 | authors.workspace = true 10 | license.workspace = true 11 | homepage.workspace = true 12 | repository.workspace = true 13 | 14 | [lints] 15 | workspace = true 16 | 17 | [dependencies] 18 | alloy-json-abi.workspace = true 19 | alloy-sol-macro-input.workspace = true 20 | alloy-sol-macro-expander = { workspace = true, features = ["json"] } 21 | foundry-common.workspace = true 22 | 23 | proc-macro2.workspace = true 24 | quote.workspace = true 25 | syn.workspace = true 26 | prettyplease.workspace = true 27 | 28 | serde_json.workspace = true 29 | eyre.workspace = true 30 | -------------------------------------------------------------------------------- /crates/sol-macro-gen/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! This crate constains the logic for Rust bindings generating from Solidity contracts 2 | 3 | pub mod sol_macro_gen; 4 | 5 | pub use sol_macro_gen::*; 6 | -------------------------------------------------------------------------------- /crates/test-utils/src/fd_lock.rs: -------------------------------------------------------------------------------- 1 | //! File locking utilities. 2 | 3 | use crate::util::pretty_err; 4 | use std::{ 5 | fs::{File, OpenOptions}, 6 | path::Path, 7 | }; 8 | 9 | pub use fd_lock::*; 10 | 11 | /// Creates a new lock file at the given path. 12 | pub fn new_lock(lock_path: impl AsRef) -> RwLock { 13 | fn new_lock(lock_path: &Path) -> RwLock { 14 | let lock_file = pretty_err( 15 | lock_path, 16 | OpenOptions::new().read(true).write(true).create(true).truncate(false).open(lock_path), 17 | ); 18 | RwLock::new(lock_file) 19 | } 20 | new_lock(lock_path.as_ref()) 21 | } 22 | -------------------------------------------------------------------------------- /crates/wallets/src/lib.rs: -------------------------------------------------------------------------------- 1 | //! # foundry-wallets 2 | //! 3 | //! Utilities for working with multiple signers. 4 | 5 | #![cfg_attr(not(test), warn(unused_crate_dependencies))] 6 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] 7 | 8 | #[macro_use] 9 | extern crate tracing; 10 | 11 | pub mod error; 12 | pub mod multi_wallet; 13 | pub mod raw_wallet; 14 | pub mod utils; 15 | pub mod wallet; 16 | pub mod wallet_signer; 17 | 18 | pub use multi_wallet::MultiWalletOpts; 19 | pub use raw_wallet::RawWalletOpts; 20 | pub use wallet::WalletOpts; 21 | pub use wallet_signer::{PendingSigner, WalletSigner}; 22 | -------------------------------------------------------------------------------- /docs/dev/architecture.md: -------------------------------------------------------------------------------- 1 | # Architecture 2 | 3 | This document describes the high-level architecture of Foundry. 4 | 5 | ### `evm/` 6 | 7 | Foundry's EVM tooling. This is built around [`revm`](https://github.com/bluealloy/revm) and has additional 8 | implementation of: 9 | - [cheatcodes](./cheatcodes.md) a set of solidity calls dedicated to testing which can manipulate the environment in which the execution is run 10 | 11 | ### `config/` 12 | 13 | Includes all of Foundry's settings and how to get them 14 | 15 | ### `cli/` 16 | 17 | The core `forge` and `cast` cli implementation. Includes all subcommands. 18 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | reorder_imports = true 2 | imports_granularity = "Crate" 3 | use_small_heuristics = "Max" 4 | comment_width = 100 5 | wrap_comments = true 6 | binop_separator = "Back" 7 | trailing_comma = "Vertical" 8 | trailing_semicolon = false 9 | use_field_init_shorthand = true 10 | format_code_in_doc_comments = true 11 | doc_comment_code_block_width = 100 12 | -------------------------------------------------------------------------------- /testdata/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiler files 2 | cache/ 3 | out/ 4 | .lock 5 | -------------------------------------------------------------------------------- /testdata/README.md: -------------------------------------------------------------------------------- 1 | ## Foundry Tests 2 | 3 | A test suite that tests different aspects of Foundry. 4 | 5 | ### Structure 6 | 7 | - [`core`](core): Tests for fundamental aspects of Foundry 8 | - [`logs`](logs): Tests for Foundry logging capabilities 9 | - [`cheats`](cheats): Tests for Foundry cheatcodes 10 | - [`fuzz`](fuzz): Tests for the Foundry fuzzer 11 | - [`trace`](trace): Tests for the Foundry tracer 12 | - [`fork`](fork): Tests for Foundry forking capabilities 13 | -------------------------------------------------------------------------------- /testdata/cancun/cheats/BlobBaseFee.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.25; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract BlobBaseFeeTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function test_blob_base_fee() public { 11 | vm.blobBaseFee(6969); 12 | assertEq(vm.getBlobBaseFee(), 6969); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/cancun/cheats/Blobhashes.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.25; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract BlobhashesTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testSetAndGetBlobhashes() public { 11 | bytes32[] memory blobhashes = new bytes32[](2); 12 | blobhashes[0] = bytes32(0x0000000000000000000000000000000000000000000000000000000000000001); 13 | blobhashes[1] = bytes32(0x0000000000000000000000000000000000000000000000000000000000000002); 14 | vm.blobhashes(blobhashes); 15 | 16 | bytes32[] memory gotBlobhashes = vm.getBlobhashes(); 17 | assertEq(gotBlobhashes[0], blobhashes[0]); 18 | assertEq(gotBlobhashes[1], blobhashes[1]); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/default/cheats/Addr.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract AddrTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testFailPrivKeyZero() public { 11 | vm.addr(0); 12 | } 13 | 14 | function testAddr() public { 15 | uint256 pk = 77814517325470205911140941194401928579557062014761831930645393041380819009408; 16 | address expected = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; 17 | 18 | assertEq(vm.addr(pk), expected, "expected address did not match"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/default/cheats/Assume.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract AssumeTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testAssume(uint8 x) public { 11 | vm.assume(x < 2 ** 7); 12 | assertTrue(x < 2 ** 7, "did not discard inputs"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/default/cheats/Bank.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract CoinbaseTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testCoinbase() public { 11 | vm.coinbase(0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8); 12 | assertEq(block.coinbase, 0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8, "coinbase failed"); 13 | } 14 | 15 | function testCoinbaseFuzzed(address who) public { 16 | vm.coinbase(who); 17 | assertEq(block.coinbase, who, "coinbase failed"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/cheats/Base64.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | import "../logs/console.sol"; 7 | 8 | contract Base64Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function test_toBase64() public { 12 | bytes memory input = hex"00112233445566778899aabbccddeeff"; 13 | string memory expected = "ABEiM0RVZneImaq7zN3u/w=="; 14 | string memory actual = vm.toBase64(input); 15 | assertEq(actual, expected); 16 | } 17 | 18 | function test_toBase64URL() public { 19 | bytes memory input = hex"00112233445566778899aabbccddeeff"; 20 | string memory expected = "ABEiM0RVZneImaq7zN3u_w=="; 21 | string memory actual = vm.toBase64URL(input); 22 | assertEq(actual, expected); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/default/cheats/ChainId.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract DealTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testChainId() public { 11 | uint256 newChainId = 99; 12 | vm.chainId(newChainId); 13 | assertEq(newChainId, block.chainid); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/default/cheats/Deal.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract DealTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testDeal(uint256 amount) public { 11 | address target = address(10); 12 | assertEq(target.balance, 0, "initial balance incorrect"); 13 | 14 | // Give half the amount 15 | vm.deal(target, amount / 2); 16 | assertEq(target.balance, amount / 2, "half balance is incorrect"); 17 | 18 | // Give the entire amount to check that deal is not additive 19 | vm.deal(target, amount); 20 | assertEq(target.balance, amount, "deal did not overwrite balance"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/cheats/Derive.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract DeriveTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testDerive() public { 11 | string memory mnemonic = "test test test test test test test test test test test junk"; 12 | 13 | uint256 privateKey = vm.deriveKey(mnemonic, 0); 14 | assertEq(privateKey, 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80); 15 | 16 | uint256 privateKeyDerivationPathChanged = vm.deriveKey(mnemonic, "m/44'/60'/0'/1/", 0); 17 | assertEq(privateKeyDerivationPathChanged, 0x6abb89895f93b02c1b9470db0fa675297f6cca832a5fc66d5dfd7661a42b37be); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/cheats/EnsNamehash.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract EnsNamehashTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testEnsNamehash() public { 11 | assertEq(vm.ensNamehash(""), 0x0000000000000000000000000000000000000000000000000000000000000000); 12 | assertEq(vm.ensNamehash("eth"), 0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae); 13 | assertEq(vm.ensNamehash("foo.eth"), 0xde9b09fd7c5f901e23a3f19fecc54828e9c848539801e86591bd9801b019f84f); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/default/cheats/Etch.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract EtchTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testEtch() public { 11 | address target = address(10); 12 | bytes memory code = hex"1010"; 13 | vm.etch(target, code); 14 | assertEq(string(code), string(target.code)); 15 | } 16 | 17 | function testEtchNotAvailableOnPrecompiles() public { 18 | address target = address(1); 19 | bytes memory code = hex"1010"; 20 | vm._expectCheatcodeRevert(bytes("cannot call `etch` on precompile 0x0000000000000000000000000000000000000001")); 21 | vm.etch(target, code); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/default/cheats/Fee.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract FeeTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testFee() public { 11 | vm.fee(10); 12 | assertEq(block.basefee, 10, "fee failed"); 13 | } 14 | 15 | function testFeeFuzzed(uint256 fee) public { 16 | vm.fee(fee); 17 | assertEq(block.basefee, fee, "fee failed"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/cheats/GetBlockTimestamp.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract GetBlockTimestampTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testGetTimestamp() public { 11 | uint256 timestamp = vm.getBlockTimestamp(); 12 | assertEq(timestamp, 1, "timestamp should be 1"); 13 | } 14 | 15 | function testGetTimestampWithWarp() public { 16 | assertEq(vm.getBlockTimestamp(), 1, "timestamp should be 1"); 17 | vm.warp(10); 18 | assertEq(vm.getBlockTimestamp(), 10, "warp failed"); 19 | } 20 | 21 | function testGetTimestampWithWarpFuzzed(uint128 jump) public { 22 | uint256 pre = vm.getBlockTimestamp(); 23 | vm.warp(pre + jump); 24 | assertEq(vm.getBlockTimestamp(), pre + jump, "warp failed"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testdata/default/cheats/GetLabel.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity >=0.8.0; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract GetLabelTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testGetLabel() public { 11 | // Label an address. 12 | vm.label(address(1), "Sir Address the 1st"); 13 | 14 | // Retrieve the label and check it. 15 | string memory label = vm.getLabel(address(1)); 16 | assertEq(label, "Sir Address the 1st"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/default/cheats/GetNonce.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract Foo {} 8 | 9 | contract GetNonceTest is DSTest { 10 | Vm constant vm = Vm(HEVM_ADDRESS); 11 | 12 | function testGetNonce() public { 13 | uint64 nonce1 = vm.getNonce(address(this)); 14 | new Foo(); 15 | new Foo(); 16 | uint64 nonce2 = vm.getNonce(address(this)); 17 | assertEq(nonce1 + 2, nonce2); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/cheats/Label.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract LabelTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testLabel() public { 11 | vm.label(address(1), "Sir Address the 1st"); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /testdata/default/cheats/Remember.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract RememberTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testRememberKey() public { 11 | string memory mnemonic = "test test test test test test test test test test test junk"; 12 | 13 | uint256 privateKey = vm.deriveKey(mnemonic, 0); 14 | assertEq(privateKey, 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80); 15 | 16 | address thisAddress = vm.rememberKey(privateKey); 17 | assertEq(thisAddress, 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/cheats/SetBlockhash.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract SetBlockhash is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testSetBlockhash() public { 11 | bytes32 blockHash = 0x1234567890123456789012345678901234567890123456789012345678901234; 12 | vm.setBlockhash(block.number - 1, blockHash); 13 | bytes32 expected = blockhash(block.number - 1); 14 | assertEq(blockHash, expected); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testdata/default/cheats/SetNonce.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract Foo { 8 | function f() external view returns (uint256) { 9 | return 1; 10 | } 11 | } 12 | 13 | contract SetNonceTest is DSTest { 14 | Vm constant vm = Vm(HEVM_ADDRESS); 15 | Foo public foo; 16 | 17 | function setUp() public { 18 | foo = new Foo(); 19 | } 20 | 21 | function testSetNonce() public { 22 | vm.setNonce(address(foo), 10); 23 | // makes sure working correctly after mutating nonce. 24 | foo.f(); 25 | assertEq(vm.getNonce(address(foo)), 10); 26 | foo.f(); 27 | } 28 | 29 | function testFailInvalidNonce() public { 30 | vm.setNonce(address(foo), 10); 31 | // set lower nonce should fail 32 | vm.setNonce(address(foo), 5); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /testdata/default/cheats/SetNonceUnsafe.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract Foo { 8 | function f() external view returns (uint256) { 9 | return 1; 10 | } 11 | } 12 | 13 | contract SetNonceTest is DSTest { 14 | Vm constant vm = Vm(HEVM_ADDRESS); 15 | Foo public foo; 16 | 17 | function setUp() public { 18 | foo = new Foo(); 19 | } 20 | 21 | function testSetNonceUnsafe() public { 22 | vm.setNonceUnsafe(address(foo), 10); 23 | // makes sure working correctly after mutating nonce. 24 | foo.f(); 25 | assertEq(vm.getNonce(address(foo)), 10); 26 | foo.f(); 27 | } 28 | 29 | function testDoesNotFailDecreasingNonce() public { 30 | vm.setNonce(address(foo), 10); 31 | vm.setNonceUnsafe(address(foo), 5); 32 | assertEq(vm.getNonce(address(foo)), 5); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /testdata/default/cheats/Sign.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract SignTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testSignDigest(uint248 pk, bytes32 digest) public { 11 | vm.assume(pk != 0); 12 | 13 | (uint8 v, bytes32 r, bytes32 s) = vm.sign(pk, digest); 14 | address expected = vm.addr(pk); 15 | address actual = ecrecover(digest, v, r, s); 16 | 17 | assertEq(actual, expected, "digest signer did not match"); 18 | } 19 | 20 | function testSignMessage(uint248 pk, bytes memory message) public { 21 | testSignDigest(pk, keccak256(message)); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/default/cheats/SignP256.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract SignTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testSignP256() public { 11 | bytes32 pk = hex"A8568B74282DCC66FF70F10B4CE5CC7B391282F5381BBB4F4D8DD96974B16E6B"; 12 | bytes32 digest = hex"54705ba3baafdbdfba8c5f9a70f7a89bee98d906b53e31074da7baecdc0da9ad"; 13 | 14 | (bytes32 r, bytes32 s) = vm.signP256(uint256(pk), digest); 15 | assertEq(r, hex"7C11C3641B19E7822DB644CBF76ED0420A013928C2FD3E36D8EF983B103BDFE1"); 16 | assertEq(s, hex"317D89879868D484810D4E508A96109F8C87617B7BE9337411348D7B786F945F"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/default/cheats/Skip.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract SkipTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testSkip() public { 11 | vm.skip(true); 12 | revert("Should not reach this revert"); 13 | } 14 | 15 | function testFailNotSkip() public { 16 | vm.skip(false); 17 | revert("This test should fail"); 18 | } 19 | 20 | function testFuzzSkip(uint256 x) public { 21 | vm.skip(true); 22 | revert("Should not reach revert"); 23 | } 24 | 25 | function testFailFuzzSkip(uint256 x) public { 26 | vm.skip(false); 27 | revert("This test should fail"); 28 | } 29 | 30 | function statefulFuzzSkip() public { 31 | vm.skip(true); 32 | require(true == false, "Test should not reach invariant"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /testdata/default/cheats/Travel.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ChainIdTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testChainId() public { 11 | vm.chainId(10); 12 | assertEq(block.chainid, 10, "chainId switch failed"); 13 | } 14 | 15 | function testChainIdFuzzed(uint64 chainId) public { 16 | vm.chainId(chainId); 17 | assertEq(block.chainid, chainId, "chainId switch failed"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/cheats/Warp.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract WarpTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testWarp() public { 11 | vm.warp(10); 12 | assertEq(block.timestamp, 10, "warp failed"); 13 | } 14 | 15 | function testWarpFuzzed(uint128 jump) public { 16 | uint256 pre = block.timestamp; 17 | vm.warp(block.timestamp + jump); 18 | assertEq(block.timestamp, pre + jump, "warp failed"); 19 | } 20 | 21 | function testWarp2() public { 22 | assertEq(block.timestamp, 1); 23 | vm.warp(100); 24 | assertEq(block.timestamp, 100); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testdata/default/cheats/getBlockNumber.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract GetBlockNumberTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testGetBlockNumber() public { 11 | uint256 height = vm.getBlockNumber(); 12 | assertEq(height, uint256(block.number), "height should be equal to block.number"); 13 | } 14 | 15 | function testGetBlockNumberWithRoll() public { 16 | vm.roll(10); 17 | assertEq(vm.getBlockNumber(), 10, "could not get correct block height after roll"); 18 | } 19 | 20 | function testGetBlockNumberWithRollFuzzed(uint128 jump) public { 21 | uint256 pre = vm.getBlockNumber(); 22 | vm.roll(pre + jump); 23 | assertEq(vm.getBlockNumber(), pre + jump, "could not get correct block height after roll"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testdata/default/core/Abstract.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | contract TestFixture { 5 | function something() public pure returns (string memory) { 6 | return "something"; 7 | } 8 | } 9 | 10 | abstract contract AbstractTestBase { 11 | TestFixture fixture; 12 | 13 | function testSomething() public { 14 | fixture.something(); 15 | } 16 | } 17 | 18 | contract AbstractTest is AbstractTestBase { 19 | function setUp() public { 20 | fixture = new TestFixture(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/core/BadSigAfterInvariant.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract BadSigAfterInvariant is DSTest { 7 | function afterinvariant() public {} 8 | 9 | function testShouldPassWithWarning() public { 10 | assert(true); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testdata/default/core/DSStyle.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract DSStyleTest is DSTest { 7 | function testFailingAssertions() public { 8 | emit log_string("assertionOne"); 9 | assertEq(uint256(1), uint256(2)); 10 | emit log_string("assertionTwo"); 11 | assertEq(uint256(3), uint256(4)); 12 | emit log_string("done"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/default/core/FailingSetup.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract FailingSetupTest is DSTest { 7 | event Test(uint256 n); 8 | 9 | function setUp() public { 10 | emit Test(42); 11 | require(false, "setup failed predictably"); 12 | } 13 | 14 | function testFailShouldBeMarkedAsFailedBecauseOfSetup() public { 15 | emit log("setup did not fail"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/default/core/FailingTestAfterFailedSetup.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract FailingTestAfterFailedSetupTest is DSTest { 7 | function setUp() public { 8 | assertTrue(false); 9 | } 10 | 11 | function testAssertSuccess() public { 12 | assertTrue(true); 13 | } 14 | 15 | function testAssertFailure() public { 16 | assertTrue(false); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/default/core/LegacyAssertions.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract NoAssertionsRevertTest is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testMultipleAssertFailures() public { 11 | vm.assertEq(uint256(1), uint256(2)); 12 | vm.assertLt(uint256(5), uint256(4)); 13 | } 14 | } 15 | 16 | contract LegacyAssertionsTest { 17 | bool public failed; 18 | 19 | function testFlagNotSetSuccess() public {} 20 | 21 | function testFlagSetFailure() public { 22 | failed = true; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/default/core/MultipleAfterInvariant.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract MultipleAfterInvariant is DSTest { 7 | function afterInvariant() public {} 8 | 9 | function afterinvariant() public {} 10 | 11 | function testFailShouldBeMarkedAsFailedBecauseOfAfterInvariant() public { 12 | assert(true); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/default/core/MultipleSetup.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract MultipleSetup is DSTest { 7 | function setUp() public {} 8 | 9 | function setup() public {} 10 | 11 | function testFailShouldBeMarkedAsFailedBecauseOfSetup() public { 12 | assert(true); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/default/core/PaymentFailure.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract Payable { 8 | function pay() public payable {} 9 | } 10 | 11 | contract PaymentFailureTest is DSTest { 12 | Vm constant vm = Vm(HEVM_ADDRESS); 13 | 14 | function testCantPay() public { 15 | Payable target = new Payable(); 16 | vm.prank(address(1)); 17 | target.pay{value: 1}(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/core/Reverting.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | contract RevertingTest { 5 | function testFailRevert() public pure { 6 | require(false, "should revert here"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /testdata/default/core/SetupConsistency.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract SetupConsistencyCheck is DSTest { 7 | uint256 two; 8 | uint256 four; 9 | uint256 result; 10 | 11 | function setUp() public { 12 | two = 2; 13 | four = 4; 14 | result = 0; 15 | } 16 | 17 | function testAdd() public { 18 | assertEq(result, 0); 19 | result = two + four; 20 | assertEq(result, 6); 21 | } 22 | 23 | function testMultiply() public { 24 | assertEq(result, 0); 25 | result = two * four; 26 | assertEq(result, 8); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testdata/default/fork/ForkSame_1.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ForkTest is DSTest { 8 | address constant WETH_TOKEN_ADDR = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | uint256 forkA; 11 | 12 | // this will create two _different_ forks during setup 13 | function setUp() public { 14 | forkA = vm.createFork("https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", 15_977_624); 15 | } 16 | 17 | function testDummy() public { 18 | uint256 balance = WETH_TOKEN_ADDR.balance; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/default/fork/ForkSame_2.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ForkTest is DSTest { 8 | address constant WETH_TOKEN_ADDR = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | uint256 forkA; 11 | 12 | // this will create two _different_ forks during setup 13 | function setUp() public { 14 | forkA = vm.createFork("https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", 15_977_624); 15 | } 16 | 17 | function testDummy() public { 18 | uint256 balance = WETH_TOKEN_ADDR.balance; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /testdata/default/fuzz/Fuzz.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | interface Vm { 7 | function toString(bytes32) external returns (string memory); 8 | } 9 | 10 | contract FuzzTest is DSTest { 11 | constructor() { 12 | emit log("constructor"); 13 | } 14 | 15 | function setUp() public { 16 | emit log("setUp"); 17 | } 18 | 19 | function testFailFuzz(uint8 x) public { 20 | emit log("testFailFuzz"); 21 | require(x > 128, "should revert"); 22 | } 23 | 24 | function testSuccessfulFuzz(uint128 a, uint128 b) public { 25 | emit log("testSuccessfulFuzz"); 26 | assertEq(uint256(a) + uint256(b), uint256(a) + uint256(b)); 27 | } 28 | 29 | function testToStringFuzz(bytes32 data) public { 30 | Vm vm = Vm(HEVM_ADDRESS); 31 | vm.toString(data); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /testdata/default/fuzz/FuzzFailurePersist.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | struct TestTuple { 8 | address user; 9 | uint256 amount; 10 | } 11 | 12 | contract FuzzFailurePersistTest is DSTest { 13 | Vm vm = Vm(HEVM_ADDRESS); 14 | 15 | function test_persist_fuzzed_failure( 16 | uint256 x, 17 | int256 y, 18 | address addr, 19 | bool cond, 20 | string calldata test, 21 | TestTuple calldata tuple, 22 | address[] calldata addresses 23 | ) public { 24 | // dummy assume to trigger runs 25 | vm.assume(x > 1 && x < 1111111111111111111111111111); 26 | vm.assume(y > 1 && y < 1111111111111111111111111111); 27 | require(false); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /testdata/default/fuzz/FuzzPositive.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract FuzzPositive is DSTest { 7 | function testSuccessChecker(uint256 val) public { 8 | assertTrue(true); 9 | } 10 | 11 | function testSuccessChecker2(int256 val) public { 12 | assert(val == val); 13 | } 14 | 15 | function testSuccessChecker3(uint32 val) public { 16 | assert(val + 0 == val); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/common/InvariantAssume.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.0; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract Handler is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function doSomething(uint256 param) public { 11 | vm.assume(param == 0); 12 | } 13 | } 14 | 15 | contract InvariantAssume is DSTest { 16 | Handler handler; 17 | 18 | function setUp() public { 19 | handler = new Handler(); 20 | } 21 | 22 | function invariant_dummy() public {} 23 | } 24 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/common/InvariantCustomError.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.0; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ContractWithCustomError { 8 | error InvariantCustomError(uint256, string); 9 | 10 | function revertWithInvariantCustomError() external { 11 | revert InvariantCustomError(111, "custom"); 12 | } 13 | } 14 | 15 | contract Handler is DSTest { 16 | ContractWithCustomError target; 17 | 18 | constructor() { 19 | target = new ContractWithCustomError(); 20 | } 21 | 22 | function revertTarget() external { 23 | target.revertWithInvariantCustomError(); 24 | } 25 | } 26 | 27 | contract InvariantCustomError is DSTest { 28 | Handler handler; 29 | 30 | function setUp() external { 31 | handler = new Handler(); 32 | } 33 | 34 | function invariant_decode_error() public {} 35 | } 36 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/common/InvariantExcludedSenders.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract InvariantSenders { 7 | function checkSender() external { 8 | require(msg.sender != 0x7109709ECfa91a80626fF3989D68f67F5b1DD12D, "sender cannot be cheatcode address"); 9 | require(msg.sender != 0x000000000000000000636F6e736F6c652e6c6f67, "sender cannot be console address"); 10 | require(msg.sender != 0x4e59b44847b379578588920cA78FbF26c0B4956C, "sender cannot be CREATE2 deployer"); 11 | } 12 | } 13 | 14 | contract InvariantExcludedSendersTest is DSTest { 15 | InvariantSenders target; 16 | 17 | function setUp() public { 18 | target = new InvariantSenders(); 19 | } 20 | 21 | function invariant_check_sender() public view {} 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/common/InvariantSequenceNoReverts.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract SequenceNoReverts { 7 | uint256 public count; 8 | 9 | function work(uint256 x) public { 10 | require(x % 2 != 0); 11 | count++; 12 | } 13 | } 14 | 15 | contract SequenceNoRevertsTest is DSTest { 16 | SequenceNoReverts target; 17 | 18 | function setUp() public { 19 | target = new SequenceNoReverts(); 20 | } 21 | 22 | function invariant_no_reverts() public view { 23 | require(target.count() < 10, "condition met"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/common/InvariantShrinkBigSequence.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ShrinkBigSequence { 8 | uint256 cond; 9 | 10 | function work(uint256 x) public { 11 | if (x % 2 != 0 && x < 9000) { 12 | cond++; 13 | } 14 | } 15 | 16 | function checkCond() public view { 17 | require(cond < 77, "condition met"); 18 | } 19 | } 20 | 21 | contract ShrinkBigSequenceTest is DSTest { 22 | ShrinkBigSequence target; 23 | 24 | function setUp() public { 25 | target = new ShrinkBigSequence(); 26 | } 27 | 28 | function invariant_shrink_big_sequence() public view { 29 | target.checkCond(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/common/InvariantShrinkFailOnRevert.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.13; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ShrinkFailOnRevert { 8 | uint256 cond; 9 | 10 | function work(uint256 x) public { 11 | if (x % 2 != 0 && x < 9000) { 12 | cond++; 13 | } 14 | require(cond < 10, "condition met"); 15 | } 16 | } 17 | 18 | contract ShrinkFailOnRevertTest is DSTest { 19 | ShrinkFailOnRevert target; 20 | 21 | function setUp() public { 22 | target = new ShrinkFailOnRevert(); 23 | } 24 | 25 | function invariant_shrink_fail_on_revert() public view {} 26 | } 27 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/target/ExcludeContracts.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract Hello { 7 | bool public world = true; 8 | 9 | function change() public { 10 | world = false; 11 | } 12 | } 13 | 14 | contract ExcludeContracts is DSTest { 15 | Hello hello; 16 | 17 | function setUp() public { 18 | hello = new Hello(); 19 | new Hello(); 20 | } 21 | 22 | function excludeContracts() public returns (address[] memory) { 23 | address[] memory addrs = new address[](1); 24 | addrs[0] = address(hello); 25 | return addrs; 26 | } 27 | 28 | function invariantTrueWorld() public { 29 | require(hello.world() == true, "false world"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/target/TargetContracts.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract Hello { 7 | bool public world = true; 8 | 9 | function change() public { 10 | world = false; 11 | } 12 | } 13 | 14 | contract TargetContracts is DSTest { 15 | Hello hello1; 16 | Hello hello2; 17 | 18 | function setUp() public { 19 | hello1 = new Hello(); 20 | hello2 = new Hello(); 21 | } 22 | 23 | function targetContracts() public returns (address[] memory) { 24 | address[] memory addrs = new address[](1); 25 | addrs[0] = address(hello1); 26 | return addrs; 27 | } 28 | 29 | function invariantTrueWorld() public { 30 | require(hello2.world() == true, "false world"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /testdata/default/fuzz/invariant/target/TargetSenders.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract Hello { 7 | bool public world = true; 8 | 9 | function change() public { 10 | require(msg.sender == address(0xdeadbeef)); 11 | world = false; 12 | } 13 | } 14 | 15 | contract TargetSenders is DSTest { 16 | Hello hello; 17 | 18 | function setUp() public { 19 | hello = new Hello(); 20 | } 21 | 22 | function targetSenders() public returns (address[] memory) { 23 | address[] memory addrs = new address[](1); 24 | addrs[0] = address(0xdeadbeef); 25 | return addrs; 26 | } 27 | 28 | function invariantTrueWorld() public { 29 | require(hello.world() == true, "false world"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /testdata/default/inline/FuzzInlineConf.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity >=0.8.0; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract FuzzInlineConf is DSTest { 7 | /** 8 | * forge-config: default.fuzz.runs = 1024 9 | * forge-config: default.fuzz.max-test-rejects = 500 10 | */ 11 | function testInlineConfFuzz(uint8 x) public { 12 | require(true, "this is not going to revert"); 13 | } 14 | } 15 | 16 | /// forge-config: default.fuzz.runs = 10 17 | contract FuzzInlineConf2 is DSTest { 18 | /// forge-config: default.fuzz.runs = 1 19 | function testInlineConfFuzz1(uint8 x) public { 20 | require(true, "this is not going to revert"); 21 | } 22 | 23 | function testInlineConfFuzz2(uint8 x) public { 24 | require(true, "this is not going to revert"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testdata/default/linking/cycle/Cycle.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | library Foo { 5 | function foo() external { 6 | Bar.bar(); 7 | } 8 | 9 | function flum() external {} 10 | } 11 | 12 | library Bar { 13 | function bar() external { 14 | Foo.flum(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testdata/default/linking/simple/Simple.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | // Linking scenario: contract with one library 7 | 8 | library Lib { 9 | function plus100(uint256 a) public pure returns (uint256) { 10 | return a + 100; 11 | } 12 | } 13 | 14 | contract LibraryConsumer { 15 | function consume(uint256 a) public pure returns (uint256) { 16 | return Lib.plus100(a); 17 | } 18 | } 19 | 20 | contract SimpleLibraryLinkingTest is DSTest { 21 | LibraryConsumer consumer; 22 | 23 | function setUp() public { 24 | consumer = new LibraryConsumer(); 25 | } 26 | 27 | function testCall() public { 28 | assertEq(consumer.consume(1), 101, "library call failed"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue2623.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/2623 8 | contract Issue2623Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testRollFork() public { 12 | uint256 fork = vm.createFork("rpcAlias", 10); 13 | vm.selectFork(fork); 14 | 15 | assertEq(block.number, 10); 16 | assertEq(block.timestamp, 1438270128); 17 | 18 | vm.rollFork(11); 19 | 20 | assertEq(block.number, 11); 21 | assertEq(block.timestamp, 1438270136); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue2629.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/2629 8 | contract Issue2629Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testSelectFork() public { 12 | address coinbase = 0x0193d941b50d91BE6567c7eE1C0Fe7AF498b4137; 13 | 14 | uint256 f1 = vm.createSelectFork("rpcAlias", 9); 15 | vm.selectFork(f1); 16 | 17 | assertEq(block.number, 9); 18 | assertEq(coinbase.balance, 11250000000000000000); 19 | 20 | uint256 f2 = vm.createFork("rpcAlias", 10); 21 | vm.selectFork(f2); 22 | 23 | assertEq(block.number, 10); 24 | assertEq(coinbase.balance, 16250000000000000000); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue2723.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/2723 8 | contract Issue2723Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testRollFork() public { 12 | address coinbase = 0x0193d941b50d91BE6567c7eE1C0Fe7AF498b4137; 13 | 14 | vm.createSelectFork("rpcAlias", 9); 15 | 16 | assertEq(block.number, 9); 17 | assertEq(coinbase.balance, 11250000000000000000); 18 | 19 | vm.rollFork(10); 20 | 21 | assertEq(block.number, 10); 22 | assertEq(coinbase.balance, 16250000000000000000); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue2851.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.1; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | contract Backdoor { 7 | uint256 public number = 1; 8 | 9 | function backdoor(uint256 newNumber) public payable { 10 | uint256 x = newNumber - 1; 11 | if (x == 6912213124124531) { 12 | number = 0; 13 | } 14 | } 15 | } 16 | 17 | // https://github.com/foundry-rs/foundry/issues/2851 18 | contract Issue2851Test is DSTest { 19 | Backdoor back; 20 | 21 | function setUp() public { 22 | back = new Backdoor(); 23 | } 24 | 25 | function invariantNotZero() public { 26 | assertEq(back.number(), 1); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue2898.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | import "../logs/console.sol"; 7 | 8 | // https://github.com/foundry-rs/foundry/issues/2898 9 | contract Issue2898Test is DSTest { 10 | address private constant BRIDGE = address(10); 11 | address private constant BENEFICIARY = address(11); 12 | Vm constant vm = Vm(HEVM_ADDRESS); 13 | 14 | function setUp() public { 15 | vm.deal(BRIDGE, 100); 16 | vm.deal(BENEFICIARY, 99); 17 | 18 | vm.setNonce(BRIDGE, 10); 19 | } 20 | 21 | function testDealBalance() public { 22 | assertEq(BRIDGE.balance, 100); 23 | assertEq(BENEFICIARY.balance, 99); 24 | } 25 | 26 | function testSetNonce() public { 27 | assertEq(vm.getNonce(BRIDGE), 10); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue2984.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/2984 8 | contract Issue2984Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | uint256 fork; 11 | uint256 snapshot; 12 | 13 | function setUp() public { 14 | fork = vm.createSelectFork("https://api.avax-test.network/ext/bc/C/rpc", 12880747); 15 | snapshot = vm.snapshot(); 16 | } 17 | 18 | function testForkRevertSnapshot() public { 19 | vm.revertTo(snapshot); 20 | } 21 | 22 | function testForkSelectSnapshot() public { 23 | uint256 fork2 = vm.createSelectFork("https://api.avax-test.network/ext/bc/C/rpc", 12880749); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3189.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3189 8 | contract MyContract { 9 | function foo(uint256 arg) public returns (uint256) { 10 | return arg + 2; 11 | } 12 | } 13 | 14 | contract MyContractUser is DSTest { 15 | MyContract immutable myContract; 16 | 17 | constructor() { 18 | myContract = new MyContract(); 19 | } 20 | 21 | function foo(uint256 arg) public returns (uint256 ret) { 22 | ret = myContract.foo(arg); 23 | assertEq(ret, arg + 1, "Invariant failed"); 24 | } 25 | } 26 | 27 | contract Issue3189Test is DSTest { 28 | function testFoo() public { 29 | MyContractUser user = new MyContractUser(); 30 | uint256 fooRet = user.foo(123); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3190.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | import "../logs/console.sol"; 7 | 8 | // https://github.com/foundry-rs/foundry/issues/3190 9 | contract Issue3190Test is DSTest { 10 | Vm constant vm = Vm(HEVM_ADDRESS); 11 | 12 | function setUp() public { 13 | vm.chainId(99); 14 | assertEq(99, block.chainid); 15 | } 16 | 17 | function testChainId() public { 18 | assertEq(99, block.chainid); 19 | vm.chainId(100); 20 | assertEq(100, block.chainid); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3192.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3192 8 | contract Issue3192Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | uint256 fork1; 11 | uint256 fork2; 12 | 13 | function setUp() public { 14 | fork1 = vm.createFork("rpcAlias", 7475589); 15 | fork2 = vm.createFork("rpcAlias", 12880747); 16 | vm.selectFork(fork1); 17 | } 18 | 19 | function testForkSwapSelect() public { 20 | assertEq(fork1, vm.activeFork()); 21 | vm.selectFork(fork2); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3347.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3347 8 | contract Issue3347Test is DSTest { 9 | event log2(uint256, uint256); 10 | 11 | function test() public { 12 | emit log2(1, 2); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3437.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity >=0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3437 8 | contract Issue3347Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function internalRevert() internal { 12 | revert(); 13 | } 14 | 15 | function testFailExample() public { 16 | vm.expectRevert(); 17 | internalRevert(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3596.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3596 8 | contract Issue3596Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testDealTransfer() public { 12 | address addr = vm.addr(1337); 13 | vm.startPrank(addr); 14 | vm.deal(addr, 20000001 ether); 15 | payable(address(this)).transfer(20000000 ether); 16 | 17 | Nested nested = new Nested(); 18 | nested.doStuff(); 19 | vm.stopPrank(); 20 | } 21 | } 22 | 23 | contract Nested { 24 | function doStuff() public { 25 | doRevert(); 26 | } 27 | 28 | function doRevert() public { 29 | revert("This fails"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3653.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3653 8 | contract Issue3653Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | uint256 fork; 11 | Token token; 12 | 13 | constructor() { 14 | fork = vm.createSelectFork("rpcAlias", 1000000); 15 | token = new Token(); 16 | vm.makePersistent(address(token)); 17 | } 18 | 19 | function testDummy() public { 20 | assertEq(block.number, 1000000); 21 | } 22 | } 23 | 24 | contract Token {} 25 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3661.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | // https://github.com/foundry-rs/foundry/issues/3661 7 | contract Issue3661Test is DSTest { 8 | address sender; 9 | 10 | function setUp() public { 11 | sender = msg.sender; 12 | } 13 | 14 | function testSameSender() public { 15 | assert(sender == msg.sender); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3674.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3674 8 | contract Issue3674Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testNonceCreateSelect() public { 12 | vm.createSelectFork("rpcAliasSepolia"); 13 | 14 | vm.createSelectFork("https://api.avax-test.network/ext/bc/C/rpc"); 15 | assert(vm.getNonce(msg.sender) > 0x17); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3723.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity >=0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3723 8 | contract Issue3723Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testFailExample() public { 12 | vm.expectRevert(); 13 | revert(); 14 | 15 | vm.expectRevert(); 16 | emit log_string("Do not revert"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3753.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/3753 8 | contract Issue3753Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function test_repro() public { 12 | bool res; 13 | assembly { 14 | res := staticcall(gas(), 4, 0, 0, 0, 0) 15 | } 16 | vm.expectRevert("require"); 17 | this.revert_require(); 18 | } 19 | 20 | function revert_require() public { 21 | revert("require"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue3792.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract Config { 8 | address public test = 0xcBa28b38103307Ec8dA98377ffF9816C164f9AFa; 9 | } 10 | 11 | contract TestSetup is Config, DSTest { 12 | Vm constant vm = Vm(HEVM_ADDRESS); 13 | 14 | // More context: the inheritance order causes the _failed flag 15 | // that is usually checked on snapshots to be shifted. 16 | // We now check for keccak256("failed") on the hevm address. 17 | // This test should succeed. 18 | function testSnapshotStorageShift() public { 19 | uint256 snapshotId = vm.snapshot(); 20 | 21 | vm.prank(test); 22 | 23 | vm.revertTo(snapshotId); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue4630.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/4630 8 | contract Issue4630Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testExistingValue() public { 12 | string memory path = "fixtures/Json/Issue4630.json"; 13 | string memory json = vm.readFile(path); 14 | uint256 val = vm.parseJsonUint(json, ".local.prop1"); 15 | assertEq(val, 10); 16 | } 17 | 18 | function testMissingValue() public { 19 | string memory path = "fixtures/Json/Issue4630.json"; 20 | string memory json = vm.readFile(path); 21 | vm._expectCheatcodeRevert(); 22 | vm.parseJsonUint(json, ".localempty.prop1"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue4640.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/4640 8 | contract Issue4640Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testArbitrumBlockNumber() public { 12 | // 13 | vm.createSelectFork("https://arb-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", 75219831); 14 | // L1 block number 15 | assertEq(block.number, 16939475); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue4832.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity >=0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/4832 8 | contract Issue4832Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testFailExample() public { 12 | assertEq(uint256(1), 2); 13 | 14 | vm.expectRevert(); 15 | revert(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue5808.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/5808 8 | contract Issue5808Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testReadInt() public { 12 | string memory str1 = '["ffffffff","00000010"]'; 13 | vm._expectCheatcodeRevert(); 14 | int256[] memory ints1 = vm.parseJsonIntArray(str1, ""); 15 | 16 | string memory str2 = '["0xffffffff","0x00000010"]'; 17 | int256[] memory ints2 = vm.parseJsonIntArray(str2, ""); 18 | assertEq(ints2[0], 0xffffffff); 19 | assertEq(ints2[1], 16); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue5929.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/5929 8 | contract Issue5929Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function test_transact_not_working() public { 12 | vm.createSelectFork("rpcAlias", 15625301); 13 | // https://etherscan.io/tx/0x96a129768ec66fd7d65114bf182f4e173bf0b73a44219adaf71f01381a3d0143 14 | vm.transact(hex"96a129768ec66fd7d65114bf182f4e173bf0b73a44219adaf71f01381a3d0143"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6070.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6070 8 | contract Issue6066Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testNonPrefixed() public { 12 | vm.setEnv("__FOUNDRY_ISSUE_6066", "abcd"); 13 | vm._expectCheatcodeRevert( 14 | "failed parsing $__FOUNDRY_ISSUE_6066 as type `uint256`: missing hex prefix (\"0x\") for hex string" 15 | ); 16 | uint256 x = vm.envUint("__FOUNDRY_ISSUE_6066"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6170.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract Emitter { 8 | event Values(uint256 indexed a, uint256 indexed b); 9 | 10 | function plsEmit(uint256 a, uint256 b) external { 11 | emit Values(a, b); 12 | } 13 | } 14 | 15 | // https://github.com/foundry-rs/foundry/issues/6170 16 | contract Issue6170Test is DSTest { 17 | Vm constant vm = Vm(HEVM_ADDRESS); 18 | 19 | event Values(uint256 indexed a, uint256 b); 20 | 21 | Emitter e = new Emitter(); 22 | 23 | function test() public { 24 | vm.expectEmit(true, true, false, true); 25 | emit Values(69, 420); 26 | e.plsEmit(69, 420); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6180.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6180 8 | contract Issue6180Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function test_timebug() external { 12 | uint256 start = block.timestamp; 13 | uint256 count = 4; 14 | uint256 duration = 15; 15 | for (uint256 i; i < count; i++) { 16 | vm.warp(block.timestamp + duration); 17 | } 18 | 19 | uint256 end = block.timestamp; 20 | assertEq(end, start + count * duration); 21 | assertEq(end - start, count * duration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6293.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: Unlicense 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6293 8 | contract Issue6293Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | constructor() { 12 | require(address(this).balance > 0); 13 | payable(address(1)).call{value: 1}(""); 14 | } 15 | 16 | function test() public { 17 | assertGt(address(this).balance, 0); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6501.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "../logs/console.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6501 8 | contract Issue6501Test is DSTest { 9 | function test_hhLogs() public { 10 | console.log("a"); 11 | console.log(uint256(1)); 12 | console.log("b", uint256(2)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6538.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6538 8 | contract Issue6538Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function test_transact() public { 12 | bytes32 lastHash = 0xdbdce1d5c14a6ca17f0e527ab762589d6a73f68697606ae0bb90df7ac9ec5087; 13 | vm.createSelectFork("rpcAlias", lastHash); 14 | bytes32 txhash = 0xadbe5cf9269a001d50990d0c29075b402bcc3a0b0f3258821881621b787b35c6; 15 | vm.transact(txhash); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6554.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6554 8 | contract Issue6554Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testPermissions() public { 12 | vm.writeFile("./out/default/Issue6554.t.sol/cachedFile.txt", "cached data"); 13 | string memory content = vm.readFile("./out/default/Issue6554.t.sol/cachedFile.txt"); 14 | assertEq(content, "cached data"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6616.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6616 8 | contract Issue6616Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testCreateForkRollLatestBlock() public { 12 | vm.createSelectFork("rpcAlias"); 13 | uint256 startBlock = block.number; 14 | // this will create new forks and exit once a new latest block is found 15 | for (uint256 i; i < 10; i++) { 16 | vm.sleep(5000); 17 | vm.createSelectFork("rpcAlias"); 18 | if (block.number > startBlock) break; 19 | } 20 | assertGt(block.number, startBlock); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6759.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/6759 8 | contract Issue6759Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | function testCreateMulti() public { 12 | uint256 fork1 = vm.createFork("rpcAlias", 10); 13 | uint256 fork2 = vm.createFork("rpcAlias", 10); 14 | uint256 fork3 = vm.createFork("rpcAlias", 10); 15 | assert(fork1 != fork2); 16 | assert(fork1 != fork3); 17 | assert(fork2 != fork3); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue6966.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | 6 | // https://github.com/foundry-rs/foundry/issues/6966 7 | // See also https://github.com/RustCrypto/elliptic-curves/issues/988#issuecomment-1817681013 8 | contract Issue6966Test is DSTest { 9 | function testEcrecover() public { 10 | bytes32 h = 0x0000000000000000000000000000000000000000000000000000000000000000; 11 | uint8 v = 27; 12 | bytes32 r = bytes32(0xf87fff3202dfeae34ce9cb8151ce2e176bee02a937baac6de85c4ea03d6a6618); 13 | bytes32 s = bytes32(0xedf9ab5c7d3ec1df1c2b48600ab0a35f586e069e9a69c6cdeebc99920128d1a5); 14 | assert(ecrecover(h, v, r, s) != address(0)); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue7481.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/7481 8 | // This test ensures that we don't panic 9 | contract Issue7481Test is DSTest { 10 | Vm constant vm = Vm(HEVM_ADDRESS); 11 | 12 | function testFailTransact() public { 13 | vm.createSelectFork("rpcAlias", 19514903); 14 | 15 | // Transfer some funds to sender of tx being transacted to ensure that it appears in journaled state 16 | payable(address(0x5C60cD7a3D50877Bfebd484750FBeb245D936dAD)).call{value: 1}(""); 17 | vm.transact(0xccfd66fc409a633a99b5b75b0e9a2040fcf562d03d9bee3fefc1a5c0eb49c999); 18 | 19 | // Revert the current call to ensure that revm can revert state journal 20 | revert("HERE"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /testdata/default/repros/Issue8277.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | // https://github.com/foundry-rs/foundry/issues/8277 8 | contract Issue8277Test is DSTest { 9 | Vm constant vm = Vm(HEVM_ADDRESS); 10 | 11 | struct MyJson { 12 | string s; 13 | } 14 | 15 | function test_hexprefixednonhexstring() public { 16 | { 17 | bytes memory b = vm.parseJson("{\"a\": \"0x834629f473876e5f0d3d9d269af3dabcb0d7d520-identifier-0\"}"); 18 | MyJson memory decoded = abi.decode(b, (MyJson)); 19 | assertEq(decoded.s, "0x834629f473876e5f0d3d9d269af3dabcb0d7d520-identifier-0"); 20 | } 21 | 22 | { 23 | bytes memory b = vm.parseJson("{\"b\": \"0xBTC\"}"); 24 | MyJson memory decoded = abi.decode(b, (MyJson)); 25 | assertEq(decoded.s, "0xBTC"); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /testdata/default/spec/ShanghaiCompat.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.20; 3 | 4 | import "ds-test/test.sol"; 5 | import "cheats/Vm.sol"; 6 | 7 | contract ShanghaiCompat is DSTest { 8 | Vm constant vm = Vm(HEVM_ADDRESS); 9 | 10 | function testPush0() public { 11 | address target = address(uint160(uint256(0xc4f3))); 12 | 13 | bytes memory bytecode = hex"365f5f37365ff3"; 14 | // 36 CALLDATASIZE 15 | // 5F PUSH0 16 | // 5F PUSH0 17 | // 37 CALLDATACOPY -> copies calldata at mem[0..calldatasize] 18 | 19 | // 36 CALLDATASIZE 20 | // 5F PUSH0 21 | // F3 RETURN -> returns mem[0..calldatasize] 22 | 23 | vm.etch(target, bytecode); 24 | 25 | (bool success, bytes memory result) = target.call(bytes("hello PUSH0")); 26 | assertTrue(success); 27 | assertEq(string(result), "hello PUSH0"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /testdata/default/vyper/Counter.vy: -------------------------------------------------------------------------------- 1 | from . import ICounter 2 | implements: ICounter 3 | 4 | number: public(uint256) 5 | 6 | @external 7 | def set_number(new_number: uint256): 8 | self.number = new_number 9 | 10 | @external 11 | def increment(): 12 | self.number += 1 13 | -------------------------------------------------------------------------------- /testdata/default/vyper/CounterTest.vy: -------------------------------------------------------------------------------- 1 | from . import ICounter 2 | 3 | interface Vm: 4 | def deployCode(artifact_name: String[1024], args: Bytes[1024] = b"") -> address: nonpayable 5 | 6 | vm: constant(Vm) = Vm(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D) 7 | counter: ICounter 8 | 9 | @external 10 | def setUp(): 11 | self.counter = ICounter(extcall vm.deployCode("vyper/Counter.vy")) 12 | 13 | @external 14 | def test_increment(): 15 | extcall self.counter.increment() 16 | assert staticcall self.counter.number() == 1 17 | -------------------------------------------------------------------------------- /testdata/default/vyper/ICounter.vyi: -------------------------------------------------------------------------------- 1 | @view 2 | @external 3 | def number() -> uint256: 4 | ... 5 | 6 | @external 7 | def set_number(new_number: uint256): 8 | ... 9 | 10 | @external 11 | def increment(): 12 | ... -------------------------------------------------------------------------------- /testdata/etherscan/0x044b75f554b886A065b9567891e45c79542d7357/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0x044b75f554b886a065b9567891e45c79542d7357","contractCreator":"0xf87bc5535602077d340806d71f805ea9907a843d","txHash":"0x9a89d2f5528bf07661e92f3f78a3311396f11f15da19e3ec4d880be1ad1a4bec"} -------------------------------------------------------------------------------- /testdata/etherscan/0x35Fb958109b70799a8f9Bc2a8b1Ee4cC62034193/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0x35fb958109b70799a8f9bc2a8b1ee4cc62034193","contractCreator":"0x3e32324277e96b69750bc6f7c4ba27e122413e07","txHash":"0x41e3517f8262b55e1eb1707ba0760b603a70e89ea4a86eff56072fcc80c3d0a1"} -------------------------------------------------------------------------------- /testdata/etherscan/0x3a23F943181408EAC424116Af7b7790c94Cb97a5/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0x3a23f943181408eac424116af7b7790c94cb97a5","contractCreator":"0xe8dd38e673a93ccfc2e3d7053efccb5c93f49365","txHash":"0x29328ac0edf7b080320bc8ed998fcd3e866f7eec3775b0d91a86f5d02ab83c28"} -------------------------------------------------------------------------------- /testdata/etherscan/0x71356E37e0368Bd10bFDbF41dC052fE5FA24cD05/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0x71356e37e0368bd10bfdbf41dc052fe5fa24cd05","contractCreator":"0xaa1d342354d755ec515f40e7d5e83cb4184bb9ee","txHash":"0x1c800c2c2d5230823602cae6896a8db1ab7d1341ca697c6c64d9f0edf11dabe2"} -------------------------------------------------------------------------------- /testdata/etherscan/0x8B3D32cf2bb4d0D16656f4c0b04Fa546274f1545/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0x8b3d32cf2bb4d0d16656f4c0b04fa546274f1545","contractCreator":"0x958892b4a0512b28aaac890fc938868bbd42f064","txHash":"0x79820495643caf5a1e7e96578361c9ddba0e0735cd684ada7450254f6fd58f51"} -------------------------------------------------------------------------------- /testdata/etherscan/0x9AB6b21cDF116f611110b048987E58894786C244/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0x9ab6b21cdf116f611110b048987e58894786c244","contractCreator":"0x603d50bad151da8becf405e51a8c4abc8ba1c95e","txHash":"0x72be611ae1ade09242d9fc9c950a73d076f6c23514564a7b9ac730400dbaf2c0"} -------------------------------------------------------------------------------- /testdata/etherscan/0x9d27527Ada2CF29fBDAB2973cfa243845a08Bd3F/creation_data.json: -------------------------------------------------------------------------------- 1 | { 2 | "contractAddress": "0x9d27527ada2cf29fbdab2973cfa243845a08bd3f", 3 | "contractCreator": "0x7773ae67403d2e30102a84c48cc939919c4c881c", 4 | "txHash": "0xc757719b7ae11ea651b1b23249978a3e8fca94d358610f5809a5dc19fbf850ce" 5 | } -------------------------------------------------------------------------------- /testdata/etherscan/0xDb53f47aC61FE54F456A4eb3E09832D08Dd7BEec/creation_data.json: -------------------------------------------------------------------------------- 1 | {"contractAddress":"0xdb53f47ac61fe54f456a4eb3e09832d08dd7beec","contractCreator":"0xc7f8d87734ab2cbf70030ac8aa82abfe3e8126cb","txHash":"0x196898c69f6b1944f1011120b15c0903329d46259c8cdc0fbcad71da1fe58245"} -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_chinese_simplified.txt: -------------------------------------------------------------------------------- 1 | 谐 谐 谐 谐 谐 谐 谐 谐 谐 谐 谐 宗 -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_chinese_traditional.txt: -------------------------------------------------------------------------------- 1 | 諧 諧 諧 諧 諧 諧 諧 諧 諧 諧 諧 宗 -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_czech.txt: -------------------------------------------------------------------------------- 1 | uzenina uzenina uzenina uzenina uzenina uzenina uzenina uzenina uzenina uzenina uzenina nevina -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_english.txt: -------------------------------------------------------------------------------- 1 | test test test test test test test test test test test junk -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_french.txt: -------------------------------------------------------------------------------- 1 | sonde sonde sonde sonde sonde sonde sonde sonde sonde sonde sonde hématome -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_italian.txt: -------------------------------------------------------------------------------- 1 | surgelato surgelato surgelato surgelato surgelato surgelato surgelato surgelato surgelato surgelato surgelato mansarda -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_japanese.txt: -------------------------------------------------------------------------------- 1 | ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ほんけ ぜんご -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_korean.txt: -------------------------------------------------------------------------------- 1 | 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 큰어머니 시스템 -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_portuguese.txt: -------------------------------------------------------------------------------- 1 | sobra sobra sobra sobra sobra sobra sobra sobra sobra sobra sobra guarani -------------------------------------------------------------------------------- /testdata/fixtures/Derive/mnemonic_spanish.txt: -------------------------------------------------------------------------------- 1 | tacto tacto tacto tacto tacto tacto tacto tacto tacto tacto tacto lacra -------------------------------------------------------------------------------- /testdata/fixtures/Dir/depth1: -------------------------------------------------------------------------------- 1 | Wow! 😀 -------------------------------------------------------------------------------- /testdata/fixtures/Dir/nested/depth2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flashbots/suavex-foundry/76966b85de7bc6413e2faefbcc5a171b2a606d58/testdata/fixtures/Dir/nested/depth2 -------------------------------------------------------------------------------- /testdata/fixtures/Dir/nested/nested2/depth3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flashbots/suavex-foundry/76966b85de7bc6413e2faefbcc5a171b2a606d58/testdata/fixtures/Dir/nested/nested2/depth3 -------------------------------------------------------------------------------- /testdata/fixtures/File/read.txt: -------------------------------------------------------------------------------- 1 | hello readable world 2 | this is the second line! -------------------------------------------------------------------------------- /testdata/fixtures/File/symlink: -------------------------------------------------------------------------------- 1 | read.txt -------------------------------------------------------------------------------- /testdata/fixtures/GetCode/HuffWorkingContract.json: -------------------------------------------------------------------------------- 1 | { 2 | "file": { 3 | "path": "src/WorkingContract.huff" 4 | }, 5 | "bytecode": "602d8060093d393df33d3560e01c63d1efd30d14610012573d3dfd5b6f656d6f2e6574682077757a206865726560801b3d523d6020f3", 6 | "runtime": "3d3560e01c63d1efd30d14610012573d3dfd5b6f656d6f2e6574682077757a206865726560801b3d523d6020f3", 7 | "abi": { 8 | "constructor": null, 9 | "functions": { 10 | "secret": { 11 | "name": "secret", 12 | "inputs": [], 13 | "outputs": [ 14 | { 15 | "name": "", 16 | "kind": { 17 | "Uint": 256 18 | }, 19 | "internal_type": null 20 | } 21 | ], 22 | "constant": false, 23 | "state_mutability": "View" 24 | } 25 | }, 26 | "events": {}, 27 | "errors": {}, 28 | "receive": false, 29 | "fallback": false 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /testdata/fixtures/GetCode/Override.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity ^0.8.13; 3 | 4 | contract Override { 5 | event Payload(address sender, address target, bytes data); 6 | 7 | function emitPayload(address target, bytes calldata message) external payable returns (uint256) { 8 | emit Payload(msg.sender, target, message); 9 | return 0; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /testdata/fixtures/GetCode/UnlinkedContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | library SmolLibrary { 5 | function add(uint256 a, uint256 b) public pure returns (uint256 c) { 6 | c = a + b; 7 | } 8 | } 9 | 10 | contract UnlinkedContract { 11 | function complicated(uint256 a, uint256 b, uint256 c) public pure returns (uint256 d) { 12 | d = SmolLibrary.add(SmolLibrary.add(a, b), c); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /testdata/fixtures/GetCode/WorkingContract.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT OR Apache-2.0 2 | pragma solidity 0.8.18; 3 | 4 | contract WorkingContract { 5 | uint256 public constant secret = 42; 6 | } 7 | -------------------------------------------------------------------------------- /testdata/fixtures/Json/Issue4402.json: -------------------------------------------------------------------------------- 1 | { 2 | "tokens": ["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"], 3 | "empty": [] 4 | } -------------------------------------------------------------------------------- /testdata/fixtures/Json/Issue4630.json: -------------------------------------------------------------------------------- 1 | { 2 | "local": { 3 | "prop1": 10 4 | }, 5 | "localempty": { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /testdata/fixtures/Json/test_allocs.json: -------------------------------------------------------------------------------- 1 | { 2 | "0x0000000000000000000000000000000000000420": { 3 | "balance": "0xabcd", 4 | "code": "0x604260005260206000F3", 5 | "storage": { 6 | "0x1000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000000000000000000000000000000000000000beef" 7 | } 8 | }, 9 | "0x0000000000000000000000000000000000000421": { 10 | "balance": "0x0", 11 | "storage": { 12 | "0x1000000000000000000000000000000000000000000000000000000000000000": "0x000000000000000000000000000000000000000000000000000000000000beef" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/fixtures/Json/whole_json.json: -------------------------------------------------------------------------------- 1 | { 2 | "str": "hai", 3 | "uintArray": [42, 43], 4 | "strArray": ["hai", "there"] 5 | } 6 | -------------------------------------------------------------------------------- /testdata/fixtures/Json/write_complex_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 123, 3 | "b": "test", 4 | "c": { 5 | "a": 123, 6 | "b": "test" 7 | } 8 | } -------------------------------------------------------------------------------- /testdata/fixtures/Json/write_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 123, 3 | "b": "0x000000000000000000000000000000000000bEEF" 4 | } -------------------------------------------------------------------------------- /testdata/fixtures/Rpc/README.md: -------------------------------------------------------------------------------- 1 | # Fixture Generation Instructions 2 | 3 | ### `eth_getLogs.json` 4 | 5 | To generate this fixture, send a POST request to a Eth Mainnet (chainId = 1) RPC 6 | 7 | ``` 8 | { 9 | "jsonrpc": "2.0", 10 | "method": "eth_getLogs", 11 | "id": "1", 12 | "params": [ 13 | { 14 | "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", 15 | "fromBlock": "0x10CEB1B", 16 | "toBlock": "0x10CEB1B", 17 | "topics": [ 18 | "0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65" 19 | ] 20 | } 21 | ] 22 | } 23 | ``` 24 | 25 | Then you must change the `address` key to `emitter` because in Solidity, a struct's name cannot be `address` as that is a keyword. 26 | -------------------------------------------------------------------------------- /testdata/fixtures/Rpc/balance_params.json: -------------------------------------------------------------------------------- 1 | ["0x8D97689C9818892B700e27F316cc3E41e17fBeb9", "0x117BC09"] -------------------------------------------------------------------------------- /testdata/fixtures/SolidityGeneration/GeneratedNamedInterface.sol: -------------------------------------------------------------------------------- 1 | interface test { 2 | event Bar(address indexed x); 3 | event Foo(address x); 4 | 5 | function guess(uint8 n, address x) external payable; 6 | function isComplete() external view returns (bool example, string memory); 7 | } 8 | -------------------------------------------------------------------------------- /testdata/fixtures/SolidityGeneration/GeneratedUnnamedInterface.sol: -------------------------------------------------------------------------------- 1 | interface Interface { 2 | event Bar(address indexed x); 3 | event Foo(address x); 4 | 5 | function guess(uint8 n, address x) external payable; 6 | function isComplete() external view returns (bool example, string memory); 7 | } 8 | -------------------------------------------------------------------------------- /testdata/fixtures/Toml/Issue4402.toml: -------------------------------------------------------------------------------- 1 | tokens = ["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"] 2 | empty = [] 3 | -------------------------------------------------------------------------------- /testdata/fixtures/Toml/whole_toml.toml: -------------------------------------------------------------------------------- 1 | str = "hai" 2 | uintArray = [42, 43] 3 | strArray = ["hai", "there"] 4 | -------------------------------------------------------------------------------- /testdata/fixtures/Toml/write_complex_test.toml: -------------------------------------------------------------------------------- 1 | a = 123 2 | b = "test" 3 | 4 | [c] 5 | a = 123 6 | b = "test" 7 | -------------------------------------------------------------------------------- /testdata/fixtures/Toml/write_test.toml: -------------------------------------------------------------------------------- 1 | a = 123 2 | b = "0x000000000000000000000000000000000000bEEF" 3 | -------------------------------------------------------------------------------- /testdata/fixtures/broadcast.sensitive.log.json: -------------------------------------------------------------------------------- 1 | { 2 | "transactions": [ 3 | { 4 | "rpc": "http://127.0.0.1:57544" 5 | }, 6 | { 7 | "rpc": "http://127.0.0.1:57544" 8 | }, 9 | { 10 | "rpc": "http://127.0.0.1:57544" 11 | }, 12 | { 13 | "rpc": "http://127.0.0.1:57544" 14 | }, 15 | { 16 | "rpc": "http://127.0.0.1:57544" 17 | }, 18 | { 19 | "rpc": "http://127.0.0.1:57544" 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /testdata/forge-std-rev: -------------------------------------------------------------------------------- 1 | 07263d193d621c4b2b0ce8b4d54af58f6957d97d -------------------------------------------------------------------------------- /testdata/multi-version/Counter.sol: -------------------------------------------------------------------------------- 1 | contract Counter { 2 | uint256 public number; 3 | 4 | function setNumber(uint256 newNumber) public { 5 | number = newNumber; 6 | } 7 | 8 | function increment() public { 9 | number++; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /testdata/multi-version/Importer.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.17; 2 | 3 | import "./Counter.sol"; 4 | 5 | // Please do not remove or change version pragma for this file. 6 | // If you need to ensure that some of the files are compiled with 7 | // solc 0.8.17, you should add imports of them to this file. 8 | --------------------------------------------------------------------------------