diff --git a/Week16/my-create-web3-dapp/contract/.editorconfig b/Week16/my-create-web3-dapp/contract/.editorconfig deleted file mode 100644 index 746ae312..00000000 --- a/Week16/my-create-web3-dapp/contract/.editorconfig +++ /dev/null @@ -1,19 +0,0 @@ -# EditorConfig http://EditorConfig.org - -# top-most EditorConfig file -root = true - -# All files -[*] -charset = utf-8 -end_of_line = lf -indent_size = 2 -indent_style = space -insert_final_newline = true -trim_trailing_whitespace = true - -[*.sol] -indent_size = 4 - -[*.tree] -indent_size = 1 diff --git a/Week16/my-create-web3-dapp/contract/.env.example b/Week16/my-create-web3-dapp/contract/.env.example deleted file mode 100644 index 5d822020..00000000 --- a/Week16/my-create-web3-dapp/contract/.env.example +++ /dev/null @@ -1,10 +0,0 @@ -API_KEY_ALCHEMY="YOUR_API_KEY_ALCHEMY" -API_KEY_ARBISCAN="YOUR_API_KEY_ARBISCAN" -API_KEY_BSCSCAN="YOUR_API_KEY_BSCSCAN" -API_KEY_ETHERSCAN="YOUR_API_KEY_ETHERSCAN" -API_KEY_GNOSISSCAN="YOUR_API_KEY_GNOSISSCAN" -API_KEY_INFURA="YOUR_API_KEY_INFURA" -API_KEY_OPTIMISTIC_ETHERSCAN="YOUR_API_KEY_OPTIMISTIC_ETHERSCAN" -API_KEY_POLYGONSCAN="YOUR_API_KEY_POLYGONSCAN" -API_KEY_SNOWTRACE="YOUR_API_KEY_SNOWTRACE" -MNEMONIC="YOUR_MNEMONIC" diff --git a/Week16/my-create-web3-dapp/contract/.gitattributes b/Week16/my-create-web3-dapp/contract/.gitattributes deleted file mode 100644 index d5e5d277..00000000 --- a/Week16/my-create-web3-dapp/contract/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -lib/** linguist-vendored diff --git a/Week16/my-create-web3-dapp/contract/.github/FUNDING.yml b/Week16/my-create-web3-dapp/contract/.github/FUNDING.yml deleted file mode 100644 index b9a2f48e..00000000 --- a/Week16/my-create-web3-dapp/contract/.github/FUNDING.yml +++ /dev/null @@ -1,2 +0,0 @@ -custom: "https://gitcoin.co/grants/1657/PaulRBerg-open-source-engineering" -github: "PaulRBerg" diff --git a/Week16/my-create-web3-dapp/contract/.github/scripts/rename.sh b/Week16/my-create-web3-dapp/contract/.github/scripts/rename.sh deleted file mode 100644 index 62e37dda..00000000 --- a/Week16/my-create-web3-dapp/contract/.github/scripts/rename.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -# https://gist.github.com/vncsna/64825d5609c146e80de8b1fd623011ca -set -euo pipefail - -# Define the input vars -GITHUB_REPOSITORY=${1?Error: Please pass username/repo, e.g. prb/foundry-template} -GITHUB_REPOSITORY_OWNER=${2?Error: Please pass username, e.g. prb} -GITHUB_REPOSITORY_DESCRIPTION=${3:-""} # If null then replace with empty string - -echo "GITHUB_REPOSITORY: $GITHUB_REPOSITORY" -echo "GITHUB_REPOSITORY_OWNER: $GITHUB_REPOSITORY_OWNER" -echo "GITHUB_REPOSITORY_DESCRIPTION: $GITHUB_REPOSITORY_DESCRIPTION" - -# jq is like sed for JSON data -JQ_OUTPUT=`jq \ - --arg NAME "@$GITHUB_REPOSITORY" \ - --arg AUTHOR_NAME "$GITHUB_REPOSITORY_OWNER" \ - --arg URL "https://github.com/$GITHUB_REPOSITORY_OWNER" \ - --arg DESCRIPTION "$GITHUB_REPOSITORY_DESCRIPTION" \ - '.name = $NAME | .description = $DESCRIPTION | .author |= ( .name = $AUTHOR_NAME | .url = $URL )' \ - package.json -` - -# Overwrite package.json -echo "$JQ_OUTPUT" > package.json - -# Make sed command compatible in both Mac and Linux environments -# Reference: https://stackoverflow.com/a/38595160/8696958 -sedi () { - sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i "" "$@" -} - -# Rename instances of "PaulRBerg/foundry-template" to the new repo name in README.md for badges only -sedi "/gitpod/ s|PaulRBerg/foundry-template|"${GITHUB_REPOSITORY}"|;" "README.md" -sedi "/gitpod-badge/ s|PaulRBerg/foundry-template|"${GITHUB_REPOSITORY}"|;" "README.md" -sedi "/gha/ s|PaulRBerg/foundry-template|"${GITHUB_REPOSITORY}"|;" "README.md" -sedi "/gha-badge/ s|PaulRBerg/foundry-template|"${GITHUB_REPOSITORY}"|;" "README.md" diff --git a/Week16/my-create-web3-dapp/contract/.github/workflows/ci.yml b/Week16/my-create-web3-dapp/contract/.github/workflows/ci.yml deleted file mode 100644 index 68e303c5..00000000 --- a/Week16/my-create-web3-dapp/contract/.github/workflows/ci.yml +++ /dev/null @@ -1,97 +0,0 @@ -name: "CI" - -env: - API_KEY_ALCHEMY: ${{ secrets.API_KEY_ALCHEMY }} - API_KEY_ETHERSCAN: ${{ secrets.API_KEY_ETHERSCAN }} - API_KEY_INFURA: ${{ secrets.API_KEY_INFURA }} - FOUNDRY_PROFILE: "ci" - MNEMONIC: ${{ secrets.MNEMONIC }} - -on: - workflow_dispatch: - pull_request: - push: - branches: - - "main" - -jobs: - lint: - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v3" - with: - submodules: "recursive" - - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" - - - name: "Install Pnpm" - uses: "pnpm/action-setup@v2" - with: - version: "8" - - - name: "Install Node.js" - uses: "actions/setup-node@v3" - with: - cache: "pnpm" - node-version: "lts/*" - - - name: "Install the Node.js dependencies" - run: "pnpm install" - - - name: "Lint the contracts" - run: "pnpm lint" - - - name: "Add lint summary" - run: | - echo "## Lint result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - - build: - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v3" - with: - submodules: "recursive" - - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" - - - name: "Build the contracts and print their size" - run: "forge build --sizes" - - - name: "Add build summary" - run: | - echo "## Build result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - - test: - needs: ["lint", "build"] - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v3" - with: - submodules: "recursive" - - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" - - - name: "Show the Foundry config" - run: "forge config" - - - name: "Generate a fuzz seed that changes weekly to avoid burning through RPC allowance" - run: > - echo "FOUNDRY_FUZZ_SEED=$( - echo $(($EPOCHSECONDS - $EPOCHSECONDS % 604800)) - )" >> $GITHUB_ENV - - - name: "Run the tests" - run: "forge test" - - - name: "Add test summary" - run: | - echo "## Tests result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY diff --git a/Week16/my-create-web3-dapp/contract/.github/workflows/create.yml b/Week16/my-create-web3-dapp/contract/.github/workflows/create.yml deleted file mode 100644 index 6cb22c3e..00000000 --- a/Week16/my-create-web3-dapp/contract/.github/workflows/create.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: "Create" - -# The workflow will run only when the "Use this template" button is used -on: - create: - -jobs: - create: - # We only run this action when the repository isn't the template repository. References: - # - https://docs.github.com/en/actions/learn-github-actions/contexts - # - https://docs.github.com/en/actions/learn-github-actions/expressions - if: ${{ !github.event.repository.is_template }} - permissions: "write-all" - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v3" - - - name: "Update package.json" - env: - GITHUB_REPOSITORY_DESCRIPTION: ${{ github.event.repository.description }} - run: - ./.github/scripts/rename.sh "$GITHUB_REPOSITORY" "$GITHUB_REPOSITORY_OWNER" "$GITHUB_REPOSITORY_DESCRIPTION" - - - name: "Add rename summary" - run: | - echo "## Commit result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - - - name: "Remove files not needed in the user's copy of the template" - run: | - rm -f "./.github/FUNDING.yml" - rm -f "./.github/scripts/rename.sh" - rm -f "./.github/workflows/create.yml" - - - name: "Add remove summary" - run: | - echo "## Remove result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - - - name: "Update commit" - uses: "stefanzweifel/git-auto-commit-action@v4" - with: - commit_message: "feat: initial commit" - commit_options: "--amend" - push_options: "--force" - skip_fetch: true - - - name: "Add commit summary" - run: | - echo "## Commit result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY diff --git a/Week16/my-create-web3-dapp/contract/.gitignore b/Week16/my-create-web3-dapp/contract/.gitignore deleted file mode 100644 index 27c05e87..00000000 --- a/Week16/my-create-web3-dapp/contract/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -# directories -cache -node_modules -out - -# files -*.env -*.log -.DS_Store -.pnp.* -lcov.info -yarn.lock - -# broadcasts -!broadcast -broadcast/* -broadcast/*/31337/ diff --git a/Week16/my-create-web3-dapp/contract/.gitmodules b/Week16/my-create-web3-dapp/contract/.gitmodules deleted file mode 100644 index 3b3d8c3d..00000000 --- a/Week16/my-create-web3-dapp/contract/.gitmodules +++ /dev/null @@ -1,8 +0,0 @@ -[submodule "lib/forge-std"] - branch = "v1" - path = "lib/forge-std" - url = "https://github.com/foundry-rs/forge-std" -[submodule "lib/prb-test"] - branch = "v0" - path = "lib/prb-test" - url = "https://github.com/PaulRBerg/prb-test" diff --git a/Week16/my-create-web3-dapp/contract/.prettierignore b/Week16/my-create-web3-dapp/contract/.prettierignore deleted file mode 100644 index 92003846..00000000 --- a/Week16/my-create-web3-dapp/contract/.prettierignore +++ /dev/null @@ -1,16 +0,0 @@ -# directories -broadcast -cache -lib -node_modules -out - -# files -*.env -*.log -.DS_Store -.pnp.* -lcov.info -package-lock.json -pnpm-lock.yaml -yarn.lock diff --git a/Week16/my-create-web3-dapp/contract/.prettierrc.yml b/Week16/my-create-web3-dapp/contract/.prettierrc.yml deleted file mode 100644 index a1ecdbb9..00000000 --- a/Week16/my-create-web3-dapp/contract/.prettierrc.yml +++ /dev/null @@ -1,7 +0,0 @@ -bracketSpacing: true -printWidth: 120 -proseWrap: "always" -singleQuote: false -tabWidth: 2 -trailingComma: "all" -useTabs: false diff --git a/Week16/my-create-web3-dapp/contract/.solhint.json b/Week16/my-create-web3-dapp/contract/.solhint.json deleted file mode 100644 index ac7469ed..00000000 --- a/Week16/my-create-web3-dapp/contract/.solhint.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "solhint:recommended", - "rules": { - "code-complexity": ["error", 8], - "compiler-version": ["error", ">=0.8.19"], - "func-name-mixedcase": "off", - "func-visibility": ["error", { "ignoreConstructors": true }], - "max-line-length": ["error", 120], - "named-parameters-mapping": "warn", - "no-console": "off", - "not-rely-on-time": "off" - } -} diff --git a/Week16/my-create-web3-dapp/contract/.vscode/settings.json b/Week16/my-create-web3-dapp/contract/.vscode/settings.json deleted file mode 100644 index c6fd597e..00000000 --- a/Week16/my-create-web3-dapp/contract/.vscode/settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "[solidity]": { - "editor.defaultFormatter": "NomicFoundation.hardhat-solidity" - }, - "[toml]": { - "editor.defaultFormatter": "tamasfe.even-better-toml" - }, - "npm.exclude": "**/lib/**", - "solidity.formatter": "forge" -} diff --git a/Week16/my-create-web3-dapp/contract/LICENSE.md b/Week16/my-create-web3-dapp/contract/LICENSE.md deleted file mode 100644 index 88a2b87b..00000000 --- a/Week16/my-create-web3-dapp/contract/LICENSE.md +++ /dev/null @@ -1,16 +0,0 @@ -MIT License - -Copyright (c) 2023 Paul Razvan Berg - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit -persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Week16/my-create-web3-dapp/contract/README.md b/Week16/my-create-web3-dapp/contract/README.md deleted file mode 100644 index 9c5505dc..00000000 --- a/Week16/my-create-web3-dapp/contract/README.md +++ /dev/null @@ -1,187 +0,0 @@ -# Foundry Template [![Open in Gitpod][gitpod-badge]][gitpod] [![Github Actions][gha-badge]][gha] [![Foundry][foundry-badge]][foundry] [![License: MIT][license-badge]][license] - -[gitpod]: https://gitpod.io/#https://github.com/PaulRBerg/foundry-template -[gitpod-badge]: https://img.shields.io/badge/Gitpod-Open%20in%20Gitpod-FFB45B?logo=gitpod -[gha]: https://github.com/PaulRBerg/foundry-template/actions -[gha-badge]: https://github.com/PaulRBerg/foundry-template/actions/workflows/ci.yml/badge.svg -[foundry]: https://getfoundry.sh/ -[foundry-badge]: https://img.shields.io/badge/Built%20with-Foundry-FFDB1C.svg -[license]: https://opensource.org/licenses/MIT -[license-badge]: https://img.shields.io/badge/License-MIT-blue.svg - -A Foundry-based template for developing Solidity smart contracts, with sensible defaults. - -## What's Inside - -- [Forge](https://github.com/foundry-rs/foundry/blob/master/forge): compile, test, fuzz, format, and deploy smart - contracts -- [PRBTest](https://github.com/PaulRBerg/prb-test): modern collection of testing assertions and logging utilities -- [Forge Std](https://github.com/foundry-rs/forge-std): collection of helpful contracts and cheatcodes for testing -- [Solhint](https://github.com/protofire/solhint): linter for Solidity code -- [Prettier Plugin Solidity](https://github.com/prettier-solidity/prettier-plugin-solidity): code formatter for - non-Solidity files - -## Getting Started - -Click the [`Use this template`](https://github.com/PaulRBerg/foundry-template/generate) button at the top of the page to -create a new repository with this repo as the initial state. - -Or, if you prefer to install the template manually: - -```sh -forge init my-project --template https://github.com/PaulRBerg/foundry-template -cd my-project -pnpm install # install Solhint, Prettier, and other Node.js deps -``` - -If this is your first time with Foundry, check out the -[installation](https://github.com/foundry-rs/foundry#installation) instructions. - -## Features - -This template builds upon the frameworks and libraries mentioned above, so for details about their specific features, -please consult their respective documentation. - -For example, if you're interested in exploring Foundry in more detail, you should look at the -[Foundry Book](https://book.getfoundry.sh/). In particular, you may be interested in reading the -[Writing Tests](https://book.getfoundry.sh/forge/writing-tests.html) tutorial. - -### Sensible Defaults - -This template comes with a set of sensible default configurations for you to use. These defaults can be found in the -following files: - -```text -├── .editorconfig -├── .gitignore -├── .prettierignore -├── .prettierrc.yml -├── .solhint.json -├── foundry.toml -└── remappings.txt -``` - -### VSCode Integration - -This template is IDE agnostic, but for the best user experience, you may want to use it in VSCode alongside Nomic -Foundation's [Solidity extension](https://marketplace.visualstudio.com/items?itemName=NomicFoundation.hardhat-solidity). - -For guidance on how to integrate a Foundry project in VSCode, please refer to this -[guide](https://book.getfoundry.sh/config/vscode). - -### GitHub Actions - -This template comes with GitHub Actions pre-configured. Your contracts will be linted and tested on every push and pull -request made to the `main` branch. - -You can edit the CI script in [.github/workflows/ci.yml](./.github/workflows/ci.yml). - -## Writing Tests - -To write a new test contract, you start by importing [PRBTest](https://github.com/PaulRBerg/prb-test) and inherit from -it in your test contract. PRBTest comes with a pre-instantiated [cheatcodes](https://book.getfoundry.sh/cheatcodes/) -environment accessible via the `vm` property. If you would like to view the logs in the terminal output you can add the -`-vvv` flag and use [console.log](https://book.getfoundry.sh/faq?highlight=console.log#how-do-i-use-consolelog). - -This template comes with an example test contract [Foo.t.sol](./test/Foo.t.sol) - -## Usage - -This is a list of the most frequently needed commands. - -### Build - -Build the contracts: - -```sh -$ forge build -``` - -### Clean - -Delete the build artifacts and cache directories: - -```sh -$ forge clean -``` - -### Compile - -Compile the contracts: - -```sh -$ forge build -``` - -### Coverage - -Get a test coverage report: - -```sh -$ forge coverage -``` - -### Deploy - -Deploy to Anvil: - -```sh -$ forge script script/Deploy.s.sol --broadcast --fork-url http://localhost:8545 -``` - -For this script to work, you need to have a `MNEMONIC` environment variable set to a valid -[BIP39 mnemonic](https://iancoleman.io/bip39/). - -For instructions on how to deploy to a testnet or mainnet, check out the -[Solidity Scripting](https://book.getfoundry.sh/tutorials/solidity-scripting.html) tutorial. - -### Format - -Format the contracts: - -```sh -$ forge fmt -``` - -### Gas Usage - -Get a gas report: - -```sh -$ forge test --gas-report -``` - -### Lint - -Lint the contracts: - -```sh -$ pnpm lint -``` - -### Test - -Run the tests: - -```sh -$ forge test -``` - -## Notes - -1. Foundry uses [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) to manage dependencies. For - detailed instructions on working with dependencies, please refer to the - [guide](https://book.getfoundry.sh/projects/dependencies.html) in the book -2. You don't have to create a `.env` file, but filling in the environment variables may be useful when debugging and - testing against a fork. - -## Related Efforts - -- [abigger87/femplate](https://github.com/abigger87/femplate) -- [cleanunicorn/ethereum-smartcontract-template](https://github.com/cleanunicorn/ethereum-smartcontract-template) -- [foundry-rs/forge-template](https://github.com/foundry-rs/forge-template) -- [FrankieIsLost/forge-template](https://github.com/FrankieIsLost/forge-template) - -## License - -This project is licensed under MIT. diff --git a/Week16/my-create-web3-dapp/contract/foundry.toml b/Week16/my-create-web3-dapp/contract/foundry.toml index bdee49aa..4ff40c48 100644 --- a/Week16/my-create-web3-dapp/contract/foundry.toml +++ b/Week16/my-create-web3-dapp/contract/foundry.toml @@ -1,54 +1,6 @@ -# Full reference https://github.com/foundry-rs/foundry/tree/master/config - [profile.default] - auto_detect_solc = false - block_timestamp = 1_680_220_800 # March 31, 2023 at 00:00 GMT - bytecode_hash = "none" - cbor_metadata = false - fuzz = { runs = 1_000 } - gas_reports = ["*"] - libs = ["lib"] - optimizer = true - optimizer_runs = 10_000 - out = "out" - script = "script" - solc = "0.8.19" - src = "src" - test = "test" - -[profile.ci] - fuzz = { runs = 10_000 } - verbosity = 4 - -[etherscan] - arbitrum_one = { key = "${API_KEY_ARBISCAN}" } - avalanche = { key = "${API_KEY_SNOWTRACE}" } - bnb_smart_chain = { key = "${API_KEY_BSCSCAN}" } - gnosis_chain = { key = "${API_KEY_GNOSISSCAN}" } - goerli = { key = "${API_KEY_ETHERSCAN}" } - mainnet = { key = "${API_KEY_ETHERSCAN}" } - optimism = { key = "${API_KEY_OPTIMISTIC_ETHERSCAN}" } - polygon = { key = "${API_KEY_POLYGONSCAN}" } - sepolia = { key = "${API_KEY_ETHERSCAN}" } - -[fmt] - bracket_spacing = true - int_types = "long" - line_length = 120 - multiline_func_header = "all" - number_underscore = "thousands" - quote_style = "double" - tab_width = 4 - wrap_comments = true +src = "src" +out = "out" +libs = ["lib"] -[rpc_endpoints] - arbitrum_one = "https://arbitrum-mainnet.infura.io/v3/${API_KEY_INFURA}" - avalanche = "https://avalanche-mainnet.infura.io/v3/${API_KEY_INFURA}" - bnb_smart_chain = "https://bsc-dataseed.binance.org" - gnosis_chain = "https://rpc.gnosischain.com" - goerli = "https://goerli.infura.io/v3/${API_KEY_INFURA}" - localhost = "http://localhost:8545" - mainnet = "https://eth-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}" - optimism = "https://optimism-mainnet.infura.io/v3/${API_KEY_INFURA}" - polygon = "https://polygon-mainnet.infura.io/v3/${API_KEY_INFURA}" - sepolia = "https://sepolia.infura.io/v3/${API_KEY_INFURA}" +# See more config options https://github.com/foundry-rs/foundry/tree/master/config \ No newline at end of file diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/.editorconfig b/Week16/my-create-web3-dapp/contract/lib/prb-test/.editorconfig deleted file mode 100644 index 96786282..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/.editorconfig +++ /dev/null @@ -1,19 +0,0 @@ -# EditorConfig http://EditorConfig.org - -# top-most EditorConfig file -root = true - -# All files -[*] -charset = utf-8 -end_of_line = lf -indent_size = 2 -indent_style = space -insert_final_newline = true -trim_trailing_whitespace = true - -[*.{sol}] -indent_size = 4 - -[*.tree] -indent_size = 1 diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/.gitattributes b/Week16/my-create-web3-dapp/contract/lib/prb-test/.gitattributes deleted file mode 100644 index d5e5d277..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -lib/** linguist-vendored diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/.github/workflows/ci.yml b/Week16/my-create-web3-dapp/contract/lib/prb-test/.github/workflows/ci.yml deleted file mode 100644 index 3254b696..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/.github/workflows/ci.yml +++ /dev/null @@ -1,107 +0,0 @@ -name: "CI" - -env: - FOUNDRY_PROFILE: "ci" - -on: - workflow_dispatch: - pull_request: - push: - branches: - - "main" - -jobs: - lint: - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v3" - - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" - - - name: "Install Pnpm" - uses: "pnpm/action-setup@v2" - with: - version: "8" - - - name: "Install Node.js" - uses: "actions/setup-node@v3" - with: - cache: "pnpm" - node-version: "lts/*" - - - name: "Install the Node.js dependencies" - run: "pnpm install" - - - name: "Lint the contracts" - run: "pnpm lint" - - - name: "Add lint summary" - run: | - echo "## Lint result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - - build: - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v3" - with: - submodules: "recursive" - - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" - - - name: "Build the contracts and print their size" - run: "forge build --sizes" - - - name: "Add build summary" - run: | - echo "## Build result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - - test: - needs: ["lint", "build"] - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v3" - with: - submodules: "recursive" - - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" - - - name: "Run the tests" - run: "forge test" - - - name: "Add test summary" - run: | - echo "## Tests result" >> $GITHUB_STEP_SUMMARY - echo "✅ Passed" >> $GITHUB_STEP_SUMMARY - - coverage: - needs: ["lint", "build"] - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v3" - with: - submodules: "recursive" - - - name: "Install Foundry" - uses: "foundry-rs/foundry-toolchain@v1" - - - name: "Generate the coverage report" - run: "forge coverage --report lcov" - - - name: "Upload coverage report to Codecov" - uses: "codecov/codecov-action@v3" - with: - files: "./lcov.info" - - - name: "Add coverage summary" - run: | - echo "## Coverage result" >> $GITHUB_STEP_SUMMARY - echo "✅ Uploaded to Codecov" >> $GITHUB_STEP_SUMMARY diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/.github/workflows/release.yml b/Week16/my-create-web3-dapp/contract/lib/prb-test/.github/workflows/release.yml deleted file mode 100644 index 710c08b5..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/.github/workflows/release.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: "Release" - -on: - push: - tags: - - "v[0-9]+.[0-9]+.[0-9]+" - -jobs: - release: - runs-on: "ubuntu-latest" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v3" - - - name: "Release" - uses: "docker://antonyurchenko/git-release:v5" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/.github/workflows/sync.yml b/Week16/my-create-web3-dapp/contract/lib/prb-test/.github/workflows/sync.yml deleted file mode 100644 index e9d77f64..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/.github/workflows/sync.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: "Sync Release Branch" - -on: - release: - types: - - "created" - -jobs: - sync-release-branch: - runs-on: "ubuntu-latest" - if: "startsWith(github.event.release.tag_name, 'v0')" - steps: - - name: "Check out the repo" - uses: "actions/checkout@v3" - with: - fetch-depth: 0 - ref: "v0" - - - name: "Configure Git" - run: | - git config user.name github-actions[bot] - git config user.email 41898282+github-actions[bot]@users.noreply.github.com - - - name: "Sync Release Branch" - run: | - git fetch --tags - git checkout v0 - git reset --hard ${GITHUB_REF} - git push --force diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/.gitignore b/Week16/my-create-web3-dapp/contract/lib/prb-test/.gitignore deleted file mode 100644 index 78878923..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -# directories -cache -node_modules -out - -# files -*.env -*.log -.DS_Store -.pnp.* -lcov.info -yarn.lock diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/.prettierignore b/Week16/my-create-web3-dapp/contract/lib/prb-test/.prettierignore deleted file mode 100644 index 92003846..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/.prettierignore +++ /dev/null @@ -1,16 +0,0 @@ -# directories -broadcast -cache -lib -node_modules -out - -# files -*.env -*.log -.DS_Store -.pnp.* -lcov.info -package-lock.json -pnpm-lock.yaml -yarn.lock diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/.prettierrc.yml b/Week16/my-create-web3-dapp/contract/lib/prb-test/.prettierrc.yml deleted file mode 100644 index a1ecdbb9..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/.prettierrc.yml +++ /dev/null @@ -1,7 +0,0 @@ -bracketSpacing: true -printWidth: 120 -proseWrap: "always" -singleQuote: false -tabWidth: 2 -trailingComma: "all" -useTabs: false diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/.solhint.json b/Week16/my-create-web3-dapp/contract/lib/prb-test/.solhint.json deleted file mode 100644 index 35272de4..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/.solhint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "solhint:recommended", - "rules": { - "avoid-low-level-calls": "off", - "code-complexity": ["error", 8], - "compiler-version": ["error", ">=0.8.0"], - "contract-name-camelcase": "off", - "const-name-snakecase": "off", - "constructor-syntax": "error", - "func-name-mixedcase": "off", - "func-visibility": ["error", { "ignoreConstructors": true }], - "max-line-length": ["error", 120], - "named-parameters-mapping": "warn", - "no-console": "off", - "no-global-import": "off" - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/.vscode/settings.json b/Week16/my-create-web3-dapp/contract/lib/prb-test/.vscode/settings.json deleted file mode 100644 index c6fd597e..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/.vscode/settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "[solidity]": { - "editor.defaultFormatter": "NomicFoundation.hardhat-solidity" - }, - "[toml]": { - "editor.defaultFormatter": "tamasfe.even-better-toml" - }, - "npm.exclude": "**/lib/**", - "solidity.formatter": "forge" -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/CHANGELOG.md b/Week16/my-create-web3-dapp/contract/lib/prb-test/CHANGELOG.md deleted file mode 100644 index be323f3c..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/CHANGELOG.md +++ /dev/null @@ -1,183 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Common Changelog](https://common-changelog.org/). - -[0.5.7]: https://github.com/PaulRBerg/prb-math/compare/v0.5.6...v0.5.7 -[0.5.6]: https://github.com/PaulRBerg/prb-math/compare/v0.5.5...v0.5.6 -[0.5.5]: https://github.com/PaulRBerg/prb-math/compare/v0.5.4...v0.5.5 -[0.5.4]: https://github.com/PaulRBerg/prb-math/compare/v0.5.3...v0.5.4 -[0.5.3]: https://github.com/PaulRBerg/prb-math/compare/v0.5.2...v0.5.3 -[0.5.2]: https://github.com/PaulRBerg/prb-math/compare/v0.5.1...v0.5.2 -[0.5.1]: https://github.com/PaulRBerg/prb-math/compare/v0.5.0...v0.5.1 -[0.5.0]: https://github.com/PaulRBerg/prb-math/compare/v0.4.0...v0.5.0 -[0.4.0]: https://github.com/PaulRBerg/prb-math/compare/v0.3.1...v0.4.0 -[0.3.1]: https://github.com/PaulRBerg/prb-math/compare/v0.3.0...v0.3.1 -[0.3.0]: https://github.com/PaulRBerg/prb-math/compare/v0.2.1...v0.3.0 -[0.2.1]: https://github.com/PaulRBerg/prb-math/compare/v0.2.0...v0.2.1 -[0.2.0]: https://github.com/PaulRBerg/prb-math/compare/v0.1.3...v0.2.0 -[0.1.3]: https://github.com/PaulRBerg/prb-math/compare/v0.1.2...v0.1.3 -[0.1.2]: https://github.com/PaulRBerg/prb-math/compare/v0.1.1...v0.1.2 -[0.1.1]: https://github.com/PaulRBerg/prb-math/compare/v0.1.0...v0.1.1 -[0.1.0]: https://github.com/PaulRBerg/prb-test/releases/tag/v0.1.0 - -## [0.5.7] - 2023-05-05 - -### Added - -- Add breakpoint cheatcodes ([#27](https://github.com/PaulRBerg/prb-test/pull/27)) (@PaulRBerg) -- Add and sync filesystem cheatcodes ([#28](https://github.com/PaulRBerg/prb-test/pull/28)) (@PaulRBerg) - -## [0.5.6] - 2023-04-29 - -### Added - -- Add new `expectCall` overloads ([#26](https://github.com/PaulRBerg/prb-test/pull/26)) (@andreivladbrg) - -## [0.5.5] - 2023-04-18 - -### Added - -- Add gas metering cheatcodes (@PaulRBerg) - -## [0.5.4] - 2023-04-11 - -### Changed - -- Update Node.js dependencies (@PaulRBerg) - -### Added - -- Sync `Vm` with forge-std (@PaulRBerg) - -## [0.5.3] - 2023-03-18 - -### Added - -- Add `MIN_INT256` constant (@PaulRBerg) -- Name `emitter` argument in `expectEmit` variant (@PaulRBerg) - -### Fixed - -- Fix typos in NatSpec comments (@PaulRBerg) - -## [0.5.2] - 2023-03-17 - -### Added - -- Add ASCII art (@PaulRBerg) - -## [0.5.1] - 2023-03-10 - -### Added - -- Add simple `expectEmit` variants ([#22](https://github.com/PaulRBerg/prb-test/pull/22)) (@PaulRBerg) - -## [0.5.0] - 2023-03-01 - -### Changed - -- Format contracts with `forge fmt` (@PaulRBerg) -- Improve documentation (@PaulRBerg) -- Name the global import of `Helpers.sol` (@PaulRBerg) -- Rename "Expected/Actual" to "Left/Right" in assertion logs (@PaulRBerg) - -### Added - -- Add new `expectCall` variants (@PaulRBerg) - -## [0.4.0] - 2023-02-14 - -### Changed - -- Improve documentation (@PaulRBerg) -- Name return argument in `addr` cheatcode (@PaulRBerg) -- Upgrade Node.js dependencies (@PaulRBerg) - -### Added - -- Add named alternatives to `contains` and `eq` (@PaulRBerg) -- Add `parseJson` cheatcodes with type coercion (@PaulRBerg) -- Sync `Vm` with forge-std (@PaulRBerg) - -## [0.3.1] - 2022-12-12 - -### Changed - -- Improve argument names in `Vm` (@PaulRBerg) - -## [0.3.0] - 2022-12-06 - -### Added - -- Add `envOr` cheatcodes (@PaulRBerg) -- Add `fsMetadata` cheatcode (@PaulRBerg) - -### Fixed - -- Make `accesses` non-view (@PaulRBerg) -- Make `getRecordedLogs` non-view (@PaulRBerg) - -## [0.2.1] - 2022-12-04 - -### Changed - -- Fix Prettier formatting issues (@PaulRBerg) - -## [0.2.0] - 2022-12-04 - -### Changed - -- Improve wording in CHANGELOG (@PaulRBerg) -- Name arguments in `Vm` interface functions (@PaulRBerg) -- Sync `Vm` with forge-std (@PaulRBerg) -- Set cheatcode mutability/ visibility (@PaulRBerg) -- Split `Vm` in `Vm` and `VmSafe` interfaces (@PaulRBerg) - -### Added - -- Add `allowCheatcodes` cheatcode (@PaulRBerg) -- Add `broadcast` and `startBroadcast` private key overloads (@PaulRBerg) -- Add `deriveKey` and `rememberKey` cheatcodes (@PaulRBerg) -- Add `difficulty` cheatcode (@PaulRBerg) -- Add fork-related cheatcodes (@PaulRBerg) -- Add `getDeployedCode` (@PaulRBerg) -- Add parsing cheatcodes (@PaulRBerg) -- Add `parseJson` helper functions in `Vm` (@PaulRBerg) -- Add `projectRoot` cheatcode (@PaulRBerg) -- Add `transact` cheatcode (@PaulRBerg) -- Add emitter in `Log` struct (@PaulRBerg) - -## [0.1.3] - 2022-10-29 - -### Changed - -- Fix typos in README (@jordaniza, @PaulRBerg) -- Improve usage guides in README (@PaulRBerg) -- Make `IS_TEST` virtual (@PaulRBerg) -- Remove superfluous `bytes20` cast (@PaulRBerg) -- Update fuzzing configuration in `foundry.toml` (@PaulRBerg) - -### Added - -- Add more information in README (@PaulRBerg) - -## [0.1.2] - 2022-07-17 - -### Fixed - -- Switch to global import to fix the overload type checker bug in Solidity v0.8.12 - ([#5](https://github.com/PaulRBerg/prb-test/issues/5)) (@jordaniza, @PaulRBerg) - -## [0.1.1] - 2022-07-15 - -### Fixed - -- Add `pinst` as Node.js dev dependency to disable the `postinstall` life cycle script in production (@PaulRBerg) - -## [0.1.0] - 2022-07-15 - -### Added - -- First release (@PaulRBerg) diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/LICENSE.md b/Week16/my-create-web3-dapp/contract/lib/prb-test/LICENSE.md deleted file mode 100644 index 054bdbe3..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/LICENSE.md +++ /dev/null @@ -1,16 +0,0 @@ -MIT License - -Copyright (c) 2022 Paul Razvan Berg - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit -persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/README.md b/Week16/my-create-web3-dapp/contract/lib/prb-test/README.md deleted file mode 100644 index a4e56619..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/README.md +++ /dev/null @@ -1,234 +0,0 @@ -# PRBTest [![Github Actions][gha-badge]][gha] [![Coverage][codecov-badge]][codecov] [![Foundry][foundry-badge]][foundry] [![License: MIT][license-badge]][license] - -[gha]: https://github.com/PaulRBerg/prb-test/actions -[gha-badge]: https://github.com/PaulRBerg/prb-test/actions/workflows/ci.yml/badge.svg -[codecov]: https://codecov.io/gh/PaulRBerg/prb-test -[codecov-badge]: https://codecov.io/gh/PaulRBerg/prb-test/branch/main/graph/badge.svg?token=T46OSU33QB -[foundry]: https://getfoundry.sh/ -[foundry-badge]: https://img.shields.io/badge/Built%20with-Foundry-FFDB1C.svg -[license]: https://opensource.org/licenses/MIT -[license-badge]: https://img.shields.io/badge/License-MIT-blue.svg - -PRBTest is a modern collection of testing assertions and logging utilities for Solidity, and is meant to be a drop-in -replacement for DSTest. - -- Feature-packed: assertions for equalities, inequalities, approximate equalities, numerical comparisons, and more -- Type-rich: every assertion has overloads for `address`, `bytes`, `bytes32`, `int256`, `string` and `uint256` -- Versioned releases so that you don't accidentally pull the latest version and break your test suites -- Meant to be used with Foundry, but can also be used with Hardhat -- Complementary to Forge Std -- Designed for Solidity >=0.8.0 -- Thoroughly tested - -## Install - -### Foundry - -First, run the install step: - -```sh -forge install --no-commit PaulRBerg/prb-test@v0 -``` - -Your `.gitmodules` file should now contain the following entry: - -```toml -[submodule "lib/prb-test"] - branch = "v0" - path = "lib/prb-test" - url = "https://github.com/PaulRBerg/prb-test" -``` - -Finally, add this to your `remappings.txt` file: - -```text -@prb/test/=lib/prb-test/src/ -``` - -### Node.js - -```sh -pnpm add @prb/test -# or -npm install @prb/test -``` - -### Template - -If you're starting a project from scratch, the easiest way to install PRBTest is to use my [Foundry -template][my-foundry-template], since it comes pre-configured with PRBTest. - -## Usage - -Once installed, all you need to do is import `PRBTest` and inherit from it in your test contract. `PRBTest` comes with a -pre-instantiated [cheatcodes](https://book.getfoundry.sh/cheatcodes/) environment accessible via the `vm` property. It -also has support for logs. - -```solidity -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.0; - -import { PRBTest } from "@prb/test/PRBTest.sol"; - -contract MyTest is PRBTest { - function testExample() external { - vm.warp(block.timestamp + 100); - emit Log("Hello World"); - assertTrue(true); - } -} -``` - -### Assertions - -All assertions have overloads with an additional `err` argument, so that you can pass custom error messages. - -| Name | Argument Types | -| ---------------- | ---------------------------------------------------------------------------------------- | -| `assertTrue` | `bool` | -| `assertFalse` | `bool` | -| `assertEq` | `address`, `bytes`, `bytes32`, `int256`, `string`, `uint256` and their array equivalents | -| `assertNotEq` | `address`, `bytes`, `bytes32`, `int256`, `string`, `uint256` and their array equivalents | -| `assertAlmostEq` | `int256` and `uint256` | -| `assertGt` | `int256` and `uint256` | -| `assertGte` | `int256` and `uint256` | -| `assertLt` | `int256` and `uint256` | -| `assertLte` | `int256` and `uint256` | -| `assertContains` | `address[]`, `bytes32[]`, `int256[]`, `string[]`, and `uint256[]` | - -### Forge Std - -PRBTest can be used alongside all testing utilities from [forge-std][forge-std], except for their [Test][forge-std-test] -contract. - -Here's an example for how to use PRBTest with `StdCheats` and `stdError`: - -```solidity -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.0; - -import { PRBTest } from "@prb/test/PRBTest.sol"; -import { StdCheats } from "forge-std/StdCheats.sol"; -import { stdError } from "forge-std/Test.sol"; - -contract MyTest is PRBTest, StdCheats { - function testArithmeticOverflow() external { - uint256 a = type(uint256).max; - uint256 b = 1; - vm.expectRevert(stdError.arithmeticError); - a + b; - } -} -``` - -## Why Choose PRBTest Over DSTest? - -[DSTest][ds-test] is great. I have used it for a while, and I like it a lot. But, with time, I slowly came to realize -that there's a lot of room for improvement. - -### 1. Missing Features and Tests - -DSTest is incomplete. Some commonly needed assertions, like equality assertions for arrays, `assertEq(bool,bool)` and -`assertNotEq`, are missing from DSTest. PRBTest fills these gaps, and then some. - -Also, the DSTest testing assertions are not themselves tested. Whereas the PRBTest testing assertions are tested, and in -fact they are quite thoroughly tested. All other things being equal, this should give you more confidence that your -tests do what you intend them to do. - -### 2. No Release Versioning - -DSTest doesn't version its releases, which makes it difficult to future-proof consumer repos. It's quite easy to -accidentally update your git submodules and thus break your test suites. For -[some users](https://github.com/dapphub/ds-test/issues/32), this is a real pain. - -PRBTest is versioned via tags and branches and all changes are tracked in a [CHANGELOG](./CHANGELOG.md) file. I maintain -redundant branches for each release because git submodules -[don't support tags](https://stackoverflow.com/q/1777854/3873510). - -I will strive to follow the [semver](https://semver.org/) versioning scheme, though I won't do this before the v1.0 -release, and it might not always be feasible. - -### 3. Path Dependence - -As one of the maintainers of DSTest said [here](https://github.com/dapphub/ds-test/pull/21#issuecomment-903668033), -updating DSTest is painful to orchestrate. The reasons for this are twofold: - -1. Every DappTools project uses it as a git submodule. -2. DSTest releases have not been versioned. - -So any significant change in DSTest might wreak havoc downstream. - -This issue has led to a "balkanization" of DSTest forks and extensions. See, for instance, Solmate's -[DSTestPlus][ds-test-plus] and Forge Std's [Test][forge-std-test]. Also see the discussions in this -[PR](https://github.com/foundry-rs/forge-std/pull/38), in which the PR author ended up making the PR against `forge-std` -rather than `ds-test` because he feared that his PR won't be merged. - -### 4. Lack of Backward Compatibility with Node.js - -It is my firm conviction that Foundry is the future of Ethereum smart contract development. Solidity code is best tested -in Solidity itself. - -But, due to various historical reasons, the Ethereum ecosystem has for a long time relied upon JavaScript for testing -smart contracts. Refactoring a code base from Hardhat or Truffle to Foundry takes time, and it may not always be -possible to do it in one fell swoop. Thus, to ensure backward compatibility, PRBTest is available as a Node.js package -in the npm package registry. - -For more details about this, see this discussion [here](https://github.com/dapphub/ds-test/issues/35). - -## Contributing - -Feel free to dive in! [Open](https://github.com/paulrberb/prb-test/issues/new) an issue, -[start](https://github.com/paulrberb/prb-test/discussions/new) a discussion or submit a PR. - -### Pre Requisites - -You will need the following software on your machine: - -- [Git](https://git-scm.com/downloads) -- [Foundry](https://github.com/foundry-rs/foundry) -- [Node.Js](https://nodejs.org/en/download/) -- [Pnpm](https://pnpm.io) - -In addition, familiarity with [Solidity](https://soliditylang.org/) is requisite. - -### Set Up - -Clone this repository including submodules: - -```sh -$ git clone --recurse-submodules -j8 git@github.com:PaulRBerg/prb-test.git -``` - -Then, inside the project's directory, run this to install the Node.js dependencies: - -```sh -$ pnpm install -``` - -Now you can start making changes. - -### Syntax Highlighting - -You will need the following VSCode extensions: - -- [hardhat-solidity](https://marketplace.visualstudio.com/items?itemName=NomicFoundation.hardhat-solidity) - -## Acknowledgements - -These contracts were inspired by or directly modified from the following sources: - -- [dapphub/ds-test](https://github.com/dapphub/ds-test/) -- [foundry-rs/forge-std](https://github.com/foundry-rs/forge-std/) - -## License - -This project is licensed under MIT. - - - -[ds-test]: https://github.com/dapphub/ds-test -[ds-test-plus]: - https://github.com/Rari-Capital/solmate/blob/03e425421b24c4f75e4a3209b019b367847b7708/src/test/utils/DSTestPlus.sol -[forge-std]: https://github.com/foundry-rs/forge-std -[forge-std-test]: https://github.com/foundry-rs/forge-std/blob/c19dfd2f2a88a461216b0dd1f4961e1a85dcad46/src/Test.sol -[my-foundry-template]: https://github.com/paulrberg/foundry-template diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/foundry.toml b/Week16/my-create-web3-dapp/contract/lib/prb-test/foundry.toml deleted file mode 100644 index 5e342079..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/foundry.toml +++ /dev/null @@ -1,33 +0,0 @@ -# Full reference https://github.com/foundry-rs/foundry/tree/master/config - -[profile.default] - auto_detect_solc = false - libs = ["lib"] - gas_reports = ["*"] - optimizer = false - out = "out" - solc = "0.8.19" - src = "src" - test = "test" - verbosity = 2 - -[profile.default.fuzz] - max_test_rejects = 100_000 # Number of times `vm.assume` can fail - runs = 100 - -[profile.lite.fuzz] - runs = 50 - -[profile.ci] - fuzz = { runs = 1_000 } - verbosity = 4 - -[fmt] - bracket_spacing = true - int_types = "long" - line_length = 120 - multiline_func_header = "all" - number_underscore = "thousands" - quote_style = "double" - tab_width = 4 - wrap_comments = true diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/package.json b/Week16/my-create-web3-dapp/contract/lib/prb-test/package.json deleted file mode 100644 index 68cb6bec..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "@prb/test", - "description": "Modern collection of testing assertions and logging utilities for Solidity", - "version": "0.5.7", - "author": { - "name": "Paul Razvan Berg", - "url": "https://github.com/PaulRBerg" - }, - "bugs": { - "url": "https://github.com/PaulRBerg/prb-test/issues" - }, - "devDependencies": { - "prettier": "^2.8.7", - "solhint": "^3.4.1" - }, - "files": [ - "/src", - "CHANGELOG.md" - ], - "homepage": "https://github.com/PaulRBerg/prb-test#readme", - "keywords": [ - "assertions", - "blockchain", - "ethereum", - "foundry", - "smart-contracts", - "solidity", - "testing" - ], - "license": "MIT", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/PaulRBerg/prb-test" - }, - "scripts": { - "clean": "rm -rf cache out", - "lint": "pnpm lint:sol && pnpm prettier:check", - "lint:sol": "forge fmt --check && pnpm solhint \"{script,src,test}/**/*.sol\"", - "prettier:check": "prettier --check \"**/*.{json,md,yml}\"", - "prettier:write": "prettier --write \"**/*.{json,md,yml}\"" - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/pnpm-lock.yaml b/Week16/my-create-web3-dapp/contract/lib/prb-test/pnpm-lock.yaml deleted file mode 100644 index b9415a7b..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/pnpm-lock.yaml +++ /dev/null @@ -1,437 +0,0 @@ -lockfileVersion: '6.0' - -devDependencies: - prettier: - specifier: ^2.8.7 - version: 2.8.7 - solhint: - specifier: ^3.4.1 - version: 3.4.1 - -packages: - - /@babel/code-frame@7.18.6: - resolution: {integrity: sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/highlight': 7.18.6 - dev: true - - /@babel/helper-validator-identifier@7.19.1: - resolution: {integrity: sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==} - engines: {node: '>=6.9.0'} - dev: true - - /@babel/highlight@7.18.6: - resolution: {integrity: sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/helper-validator-identifier': 7.19.1 - chalk: 2.4.2 - js-tokens: 4.0.0 - dev: true - - /@solidity-parser/parser@0.16.0: - resolution: {integrity: sha512-ESipEcHyRHg4Np4SqBCfcXwyxxna1DgFVz69bgpLV8vzl/NP1DtcKsJ4dJZXWQhY/Z4J2LeKBiOkOVZn9ct33Q==} - dependencies: - antlr4ts: 0.5.0-alpha.4 - dev: true - - /ajv@6.12.6: - resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} - dependencies: - fast-deep-equal: 3.1.3 - fast-json-stable-stringify: 2.1.0 - json-schema-traverse: 0.4.1 - uri-js: 4.4.1 - dev: true - - /ajv@8.12.0: - resolution: {integrity: sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==} - dependencies: - fast-deep-equal: 3.1.3 - json-schema-traverse: 1.0.0 - require-from-string: 2.0.2 - uri-js: 4.4.1 - dev: true - - /ansi-regex@5.0.1: - resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} - engines: {node: '>=8'} - dev: true - - /ansi-styles@3.2.1: - resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} - engines: {node: '>=4'} - dependencies: - color-convert: 1.9.3 - dev: true - - /ansi-styles@4.3.0: - resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} - engines: {node: '>=8'} - dependencies: - color-convert: 2.0.1 - dev: true - - /antlr4@4.12.0: - resolution: {integrity: sha512-23iB5IzXJZRZeK9TigzUyrNc9pSmNqAerJRBcNq1ETrmttMWRgaYZzC561IgEO3ygKsDJTYDTozABXa4b/fTQQ==} - engines: {node: '>=16'} - dev: true - - /antlr4ts@0.5.0-alpha.4: - resolution: {integrity: sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ==} - dev: true - - /argparse@2.0.1: - resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} - dev: true - - /ast-parents@0.0.1: - resolution: {integrity: sha512-XHusKxKz3zoYk1ic8Un640joHbFMhbqneyoZfoKnEGtf2ey9Uh/IdpcQplODdO/kENaMIWsD0nJm4+wX3UNLHA==} - dev: true - - /astral-regex@2.0.0: - resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} - engines: {node: '>=8'} - dev: true - - /balanced-match@1.0.2: - resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - dev: true - - /brace-expansion@2.0.1: - resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} - dependencies: - balanced-match: 1.0.2 - dev: true - - /callsites@3.1.0: - resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} - engines: {node: '>=6'} - dev: true - - /chalk@2.4.2: - resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} - engines: {node: '>=4'} - dependencies: - ansi-styles: 3.2.1 - escape-string-regexp: 1.0.5 - supports-color: 5.5.0 - dev: true - - /chalk@4.1.2: - resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} - engines: {node: '>=10'} - dependencies: - ansi-styles: 4.3.0 - supports-color: 7.2.0 - dev: true - - /color-convert@1.9.3: - resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} - dependencies: - color-name: 1.1.3 - dev: true - - /color-convert@2.0.1: - resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} - engines: {node: '>=7.0.0'} - dependencies: - color-name: 1.1.4 - dev: true - - /color-name@1.1.3: - resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} - dev: true - - /color-name@1.1.4: - resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - dev: true - - /commander@10.0.0: - resolution: {integrity: sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA==} - engines: {node: '>=14'} - dev: true - - /cosmiconfig@8.1.2: - resolution: {integrity: sha512-rmpUFKMZiawLfug8sP4NbpBSOpWftZB6UACOLEiNbnRAYM1TzgQuTWlMYFRuPgmoTCkcOxSMwQJQpJmiXv/eHw==} - engines: {node: '>=14'} - dependencies: - import-fresh: 3.3.0 - js-yaml: 4.1.0 - parse-json: 5.2.0 - path-type: 4.0.0 - dev: true - - /emoji-regex@8.0.0: - resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - dev: true - - /error-ex@1.3.2: - resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} - dependencies: - is-arrayish: 0.2.1 - dev: true - - /escape-string-regexp@1.0.5: - resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} - engines: {node: '>=0.8.0'} - dev: true - - /fast-deep-equal@3.1.3: - resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} - dev: true - - /fast-diff@1.2.0: - resolution: {integrity: sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==} - dev: true - - /fast-json-stable-stringify@2.1.0: - resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} - dev: true - - /fs.realpath@1.0.0: - resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} - dev: true - - /glob@8.1.0: - resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} - engines: {node: '>=12'} - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 5.1.6 - once: 1.4.0 - dev: true - - /has-flag@3.0.0: - resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} - engines: {node: '>=4'} - dev: true - - /has-flag@4.0.0: - resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} - engines: {node: '>=8'} - dev: true - - /ignore@5.2.4: - resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} - engines: {node: '>= 4'} - dev: true - - /import-fresh@3.3.0: - resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} - engines: {node: '>=6'} - dependencies: - parent-module: 1.0.1 - resolve-from: 4.0.0 - dev: true - - /inflight@1.0.6: - resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} - dependencies: - once: 1.4.0 - wrappy: 1.0.2 - dev: true - - /inherits@2.0.4: - resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} - dev: true - - /is-arrayish@0.2.1: - resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} - dev: true - - /is-fullwidth-code-point@3.0.0: - resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} - engines: {node: '>=8'} - dev: true - - /js-tokens@4.0.0: - resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - dev: true - - /js-yaml@4.1.0: - resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} - dependencies: - argparse: 2.0.1 - dev: true - - /json-parse-even-better-errors@2.3.1: - resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} - dev: true - - /json-schema-traverse@0.4.1: - resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} - dev: true - - /json-schema-traverse@1.0.0: - resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==} - dev: true - - /lines-and-columns@1.2.4: - resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - dev: true - - /lodash.truncate@4.4.2: - resolution: {integrity: sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==} - dev: true - - /lodash@4.17.21: - resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} - dev: true - - /minimatch@5.1.6: - resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} - engines: {node: '>=10'} - dependencies: - brace-expansion: 2.0.1 - dev: true - - /once@1.4.0: - resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} - dependencies: - wrappy: 1.0.2 - dev: true - - /parent-module@1.0.1: - resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} - engines: {node: '>=6'} - dependencies: - callsites: 3.1.0 - dev: true - - /parse-json@5.2.0: - resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} - engines: {node: '>=8'} - dependencies: - '@babel/code-frame': 7.18.6 - error-ex: 1.3.2 - json-parse-even-better-errors: 2.3.1 - lines-and-columns: 1.2.4 - dev: true - - /path-type@4.0.0: - resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} - engines: {node: '>=8'} - dev: true - - /pluralize@8.0.0: - resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} - engines: {node: '>=4'} - dev: true - - /prettier@2.8.7: - resolution: {integrity: sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==} - engines: {node: '>=10.13.0'} - hasBin: true - dev: true - - /punycode@2.3.0: - resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==} - engines: {node: '>=6'} - dev: true - - /require-from-string@2.0.2: - resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} - engines: {node: '>=0.10.0'} - dev: true - - /resolve-from@4.0.0: - resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} - engines: {node: '>=4'} - dev: true - - /semver@6.3.0: - resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==} - dev: true - - /slice-ansi@4.0.0: - resolution: {integrity: sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==} - engines: {node: '>=10'} - dependencies: - ansi-styles: 4.3.0 - astral-regex: 2.0.0 - is-fullwidth-code-point: 3.0.0 - dev: true - - /solhint@3.4.1: - resolution: {integrity: sha512-pzZn2RlZhws1XwvLPVSsxfHrwsteFf5eySOhpAytzXwKQYbTCJV6z8EevYDiSVKMpWrvbKpEtJ055CuEmzp4Xg==} - dependencies: - '@solidity-parser/parser': 0.16.0 - ajv: 6.12.6 - antlr4: 4.12.0 - ast-parents: 0.0.1 - chalk: 4.1.2 - commander: 10.0.0 - cosmiconfig: 8.1.2 - fast-diff: 1.2.0 - glob: 8.1.0 - ignore: 5.2.4 - js-yaml: 4.1.0 - lodash: 4.17.21 - pluralize: 8.0.0 - semver: 6.3.0 - strip-ansi: 6.0.1 - table: 6.8.1 - text-table: 0.2.0 - optionalDependencies: - prettier: 2.8.7 - dev: true - - /string-width@4.2.3: - resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} - engines: {node: '>=8'} - dependencies: - emoji-regex: 8.0.0 - is-fullwidth-code-point: 3.0.0 - strip-ansi: 6.0.1 - dev: true - - /strip-ansi@6.0.1: - resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} - engines: {node: '>=8'} - dependencies: - ansi-regex: 5.0.1 - dev: true - - /supports-color@5.5.0: - resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} - engines: {node: '>=4'} - dependencies: - has-flag: 3.0.0 - dev: true - - /supports-color@7.2.0: - resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} - engines: {node: '>=8'} - dependencies: - has-flag: 4.0.0 - dev: true - - /table@6.8.1: - resolution: {integrity: sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA==} - engines: {node: '>=10.0.0'} - dependencies: - ajv: 8.12.0 - lodash.truncate: 4.4.2 - slice-ansi: 4.0.0 - string-width: 4.2.3 - strip-ansi: 6.0.1 - dev: true - - /text-table@0.2.0: - resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} - dev: true - - /uri-js@4.4.1: - resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} - dependencies: - punycode: 2.3.0 - dev: true - - /wrappy@1.0.2: - resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} - dev: true diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/src/Helpers.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/src/Helpers.sol deleted file mode 100644 index 70a61aef..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/src/Helpers.sol +++ /dev/null @@ -1,241 +0,0 @@ -// solhint-disable func-visibility -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0 <0.9.0; - -/// @dev Calculates the absolute value of `a`. -function abs(int256 a) pure returns (uint256 result) { - // The unary operator "-" cannot be applied to "type(int256).min". - if (a == type(int256).min) { - return uint256(type(int256).min); - } - - unchecked { - result = uint256(a > 0 ? a : -a); - } -} - -/// @dev Checks if the `a` address array contains the `b` address. -function contains(address[] memory a, address b) pure returns (bool result) { - address item; - uint256 length = a.length; - - for (uint256 i = 0; i < length;) { - item = a[i]; - if (item == b) { - return true; - } - unchecked { - i += 1; - } - } - - result = false; -} - -/// @dev Checks if the `a` address array contains the `b` address. -function containsAddress(address[] memory a, address b) pure returns (bool result) { - result = contains(a, b); -} - -/// @dev Checks if the `a` bytes32 array contains the `b` bytes32. -function contains(bytes32[] memory a, bytes32 b) pure returns (bool result) { - bytes32 item; - uint256 length = a.length; - - for (uint256 i = 0; i < length;) { - item = a[i]; - if (item == b) { - return true; - } - unchecked { - i += 1; - } - } - - result = false; -} - -/// @dev Checks if the `a` bytes32 array contains the `b` bytes32. -function containsBytes32(bytes32[] memory a, bytes32 b) pure returns (bool result) { - result = contains(a, b); -} - -/// @dev Checks if the `a` string array contains the `b` string. -function contains(string[] memory a, string memory b) pure returns (bool result) { - bytes32 bHash = keccak256(abi.encode(b)); - string memory item; - uint256 length = a.length; - - for (uint256 i = 0; i < length;) { - item = a[i]; - if (keccak256(abi.encode(item)) == bHash) { - return true; - } - unchecked { - i += 1; - } - } - - result = false; -} - -/// @dev Checks if the `a` string array contains the `b` string. -function containsString(string[] memory a, string memory b) pure returns (bool result) { - result = contains(a, b); -} - -/// @dev Checks if the `a` int256 array contains the `b` int256. -function contains(int256[] memory a, int256 b) pure returns (bool result) { - int256 item; - uint256 length = a.length; - - for (uint256 i = 0; i < length;) { - item = a[i]; - if (item == b) { - return true; - } - unchecked { - i += 1; - } - } - - return false; -} - -/// @dev Checks if the `a` int256 array contains the `b` int256. -function containsInt256(int256[] memory a, int256 b) pure returns (bool result) { - result = contains(a, b); -} - -/// @dev Checks if the `a` uint256 array contains the `b` uint256. -function contains(uint256[] memory a, uint256 b) pure returns (bool result) { - uint256 item; - uint256 length = a.length; - - for (uint256 i = 0; i < length;) { - item = a[i]; - if (item == b) { - return true; - } - unchecked { - i += 1; - } - } - - result = false; -} - -/// @dev Checks if the `a` uint256 array contains the `b` uint256. -function containsUint256(uint256[] memory a, uint256 b) pure returns (bool result) { - result = contains(a, b); -} - -/// @dev Calculates the absolute delta between `a` and `b`. -function delta(int256 a, int256 b) pure returns (uint256 result) { - // If XOR of a and b is greater than -1, a and b have the same sign. This works due to two's complement. - // See https://twitter.com/PaulRBerg/status/1546957951579062272. - if ((a ^ b) > -1) { - result = delta(abs(a), abs(b)); - } else { - unchecked { - result = abs(a) + abs(b); - } - } -} - -/// @dev Calculates the absolute delta between `a` and `b`. -function delta(uint256 a, uint256 b) pure returns (uint256 result) { - unchecked { - result = a > b ? a - b : b - a; - } -} - -/// @dev Checks if the `a` address array equals the `b` address array. -function eq(address[] memory a, address[] memory b) pure returns (bool result) { - result = keccak256(abi.encode(a)) == keccak256(abi.encode(b)); -} - -/// @dev Checks if the `a` address array equals the `b` address array. -function eqAddressArr(address[] memory a, address[] memory b) pure returns (bool result) { - result = eq(a, b); -} - -/// @dev Checks if the `a` bool array equals the `b` bool array. -function eq(bool[] memory a, bool[] memory b) pure returns (bool result) { - result = keccak256(abi.encode(a)) == keccak256(abi.encode(b)); -} - -/// @dev Checks if the `a` bool array equals the `b` bool array. -function eqBoolArr(bool[] memory a, bool[] memory b) pure returns (bool result) { - result = eq(a, b); -} - -/// @dev Checks if the `a` bytes equals the `b` bytes. -function eq(bytes memory a, bytes memory b) pure returns (bool result) { - result = keccak256(a) == keccak256(b); -} - -/// @dev Checks if the `a` bytes equals the `b` bytes. -function eqBytes(bytes memory a, bytes memory b) pure returns (bool result) { - result = eq(a, b); -} - -/// @dev Checks if the `a` bytes32 equals the `b` bytes32. -function eq(bytes32 a, bytes32 b) pure returns (bool result) { - result = keccak256(abi.encode(a)) == keccak256(abi.encode(b)); -} - -/// @dev Checks if the `a` bytes32 equals the `b` bytes32. -function eqBytes32(bytes32 a, bytes32 b) pure returns (bool result) { - result = eq(a, b); -} - -/// @dev Checks if the `a` bytes32 array equals the `b` bytes32 array. -function eq(bytes32[] memory a, bytes32[] memory b) pure returns (bool result) { - result = keccak256(abi.encode(a)) == keccak256(abi.encode(b)); -} - -/// @dev Checks if the `a` bytes32 array equals the `b` bytes32 array. -function eqBytes32Arr(bytes32[] memory a, bytes32[] memory b) pure returns (bool result) { - result = eq(a, b); -} - -/// @dev Checks if the `a` string equals the `b` string. -function eq(string memory a, string memory b) pure returns (bool result) { - result = keccak256(abi.encode(a)) == keccak256(abi.encode(b)); -} - -/// @dev Checks if the `a` string equals the `b` string. -function eqString(string memory a, string memory b) pure returns (bool result) { - result = eq(a, b); -} - -/// @dev Checks if the `a` string array equals the `b` string array. -function eq(string[] memory a, string[] memory b) pure returns (bool result) { - result = keccak256(abi.encode(a)) == keccak256(abi.encode(b)); -} - -/// @dev Checks if the `a` string array equals the `b` string array. -function eqStringArr(string[] memory a, string[] memory b) pure returns (bool result) { - result = eq(a, b); -} - -/// @dev Checks if the `a` int256 array equals the `b` int256 array. -function eq(int256[] memory a, int256[] memory b) pure returns (bool result) { - result = keccak256(abi.encode(a)) == keccak256(abi.encode(b)); -} - -/// @dev Checks if the `a` int256 array equals the `b` int256 array. -function eqInt256Arr(int256[] memory a, int256[] memory b) pure returns (bool result) { - result = eq(a, b); -} - -/// @dev Checks if the `a` uint256 array equals the `b` uint256 array. -function eq(uint256[] memory a, uint256[] memory b) pure returns (bool result) { - result = keccak256(abi.encode(a)) == keccak256(abi.encode(b)); -} - -/// @dev Checks if the `a` uint256 array equals the `b` uint256 array. -function eqUint256Arr(uint256[] memory a, uint256[] memory b) pure returns (bool result) { - result = eq(a, b); -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/src/PRBTest.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/src/PRBTest.sol deleted file mode 100644 index 0b13a65a..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/src/PRBTest.sol +++ /dev/null @@ -1,968 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0 <0.9.0; - -import "./Helpers.sol" as Helpers; -import { Vm } from "./Vm.sol"; - -/* - -██████╗ ██████╗ ██████╗ ████████╗███████╗███████╗████████╗ -██╔══██╗██╔══██╗██╔══██╗╚══██╔══╝██╔════╝██╔════╝╚══██╔══╝ -██████╔╝██████╔╝██████╔╝ ██║ █████╗ ███████╗ ██║ -██╔═══╝ ██╔══██╗██╔══██╗ ██║ ██╔══╝ ╚════██║ ██║ -██║ ██║ ██║██████╔╝ ██║ ███████╗███████║ ██║ -╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚══════╝╚══════╝ ╚═╝ - -*/ - -/// @notice Modern collection of testing assertions and logging utilities. -/// @author Paul Razvan Berg -/// @dev Inspired by DSTest. -contract PRBTest { - /*////////////////////////////////////////////////////////////////////////// - EVENTS - //////////////////////////////////////////////////////////////////////////*/ - event Log(string err); - event LogAddress(address value); - event LogArray(address[] value); - event LogArray(bool[] value); - event LogArray(bytes32[] value); - event LogArray(int256[] value); - event LogArray(string[] value); - event LogArray(uint256[] value); - event LogBytes(bytes value); - event LogBytes32(bytes32 value); - event LogString(string value); - event LogInt256(int256 value); - event LogUint256(uint256 value); - event LogNamedAddress(string key, address value); - event LogNamedArray(string key, address[] value); - event LogNamedArray(string key, bool[] value); - event LogNamedArray(string key, bytes32[] value); - event LogNamedArray(string key, int256[] value); - event LogNamedArray(string key, string[] value); - event LogNamedArray(string key, uint256[] value); - event LogNamedBytes(string key, bytes value); - event LogNamedBytes32(string key, bytes32 value); - event LogNamedInt256(string key, int256 value); - event LogNamedString(string key, string value); - event LogNamedUint256(string key, uint256 value); - - /*////////////////////////////////////////////////////////////////////////// - CONSTANTS - //////////////////////////////////////////////////////////////////////////*/ - - /// @dev A flag to indicate that this is a test contract. - function IS_TEST() external pure virtual returns (bool) { - return true; - } - - /// @dev The maximum value available in the int256 type. - int256 internal constant MAX_INT256 = type(int256).max; - - /// @dev The maximum value available in the uint256 type. - uint256 internal constant MAX_UINT256 = type(uint256).max; - - /// @dev The minimum value available in the int256 type. - int256 internal constant MIN_INT256 = type(int256).min; - - /*////////////////////////////////////////////////////////////////////////// - CHEATCODES - //////////////////////////////////////////////////////////////////////////*/ - - /// @dev The address of the HEVM contract. - address internal constant HEVM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code")))); - - /// @dev An instance of the HEVM. - Vm internal constant vm = Vm(HEVM_ADDRESS); - - /*////////////////////////////////////////////////////////////////////////// - FAILURE SYSTEM - //////////////////////////////////////////////////////////////////////////*/ - - /// @dev This instance's failure flag. - bool private _failed; - - /// @dev Checks whether any test has failed so far. In addition to the local failure flag, we look for the global - /// flag in the HEVM contract at storage slot "failed", because it is possible to run assertions between different - /// instances of PRBTest. - /// See https://github.com/dapphub/dapptools/issues/768. - function failed() public returns (bool) { - if (_failed) { - return true; - } - - // If there is HEVM context, load the global variable "failed". - if (HEVM_ADDRESS.code.length > 0) { - (, bytes memory returndata) = HEVM_ADDRESS.call( - abi.encodePacked( - bytes4(keccak256("load(address,bytes32)")), abi.encode(HEVM_ADDRESS, bytes32("failed")) - ) - ); - bool globalFailed = abi.decode(returndata, (bool)); - return globalFailed; - } else { - return false; - } - } - - /// @dev Fails the test by setting the private variable `_failed` to `true` and storing "0x01" at the "failed" - /// storage slot on the HEVM contract. Doing this instead of reverting makes it possible to test multiple - /// assertions in one test function while also preserving emitted events. - function fail() internal { - // If there is no HEVM context, stop here. - if (HEVM_ADDRESS.code.length == 0) { - return; - } - - // Store "0x01" at the "failed" storage slot on the HEVM contract. - (bool status,) = HEVM_ADDRESS.call( - abi.encodePacked( - bytes4(keccak256("store(address,bytes32,bytes32)")), - abi.encode(HEVM_ADDRESS, bytes32("failed"), bytes32(uint256(0x01))) - ) - ); - - // Dummy statement to silence the compiler warning. - status; - - // Set this instance's failed flag to `true`. - _failed = true; - } - - /// @dev Logs the error message `err` and fails the test. - function fail(string memory err) internal { - emit LogNamedString("Error", err); - fail(); - } - - /*////////////////////////////////////////////////////////////////////////// - BOOLEAN ASSERTIONS - //////////////////////////////////////////////////////////////////////////*/ - - /// @dev Tests that `condition` evaluates to `true`. If it does not, the test fails. - function assertTrue(bool condition) internal virtual { - if (!condition) { - emit Log("Error: Assertion Failed"); - fail(); - } - } - - /// @dev Tests that `condition` evaluates to `true`. If it does not, the test fails with the error message `err`. - function assertTrue(bool condition, string memory err) internal virtual { - if (!condition) { - emit LogNamedString("Error", err); - fail(); - } - } - - /// @dev Tests that `condition` evaluates to `false`. If it does not, the test fails. - function assertFalse(bool condition) internal virtual { - assertTrue(!condition); - } - - /// @dev Tests that `condition` evaluates to `false`. If it does not, the test fails with the error message `err`. - function assertFalse(bool condition, string memory err) internal virtual { - assertTrue(!condition, err); - } - - /*////////////////////////////////////////////////////////////////////////// - EQUALITY ASSERTIONS - //////////////////////////////////////////////////////////////////////////*/ - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails. - function assertEq(address a, address b) internal virtual { - if (a != b) { - emit Log("Error: a == b not satisfied [address]"); - emit LogNamedAddress(" Left", a); - emit LogNamedAddress(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - function assertEq(address a, address b, string memory err) internal virtual { - if (a != b) { - emit LogNamedString("Error", err); - assertEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(address[] memory a, address[] memory b) internal virtual { - if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) { - emit Log("Error: a == b not satisfied [address[]]"); - emit LogNamedArray(" Left", a); - emit LogNamedArray(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(address[] memory a, address[] memory b, string memory err) internal virtual { - if (keccak256(abi.encode(a)) != keccak256(abi.encode(b))) { - emit LogNamedString("Error", err); - assertEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails. - function assertEq(bool a, bool b) internal virtual { - if (a != b) { - emit Log("Error: a == b not satisfied [bool]"); - emit LogNamedString(" Left", a ? "true" : "false"); - emit LogNamedString(" Right", b ? "true" : "false"); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - function assertEq(bool a, bool b, string memory err) internal virtual { - if (a != b) { - emit LogNamedString("Error", err); - assertEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(bool[] memory a, bool[] memory b) internal virtual { - if (!Helpers.eq(a, b)) { - emit Log("Error: a == b not satisfied [bool[]]"); - emit LogNamedArray(" Left", a); - emit LogNamedArray(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(bool[] memory a, bool[] memory b, string memory err) internal virtual { - if (!Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(bytes memory a, bytes memory b) internal virtual { - if (!Helpers.eq(a, b)) { - emit Log("Error: a == b not satisfied [bytes]"); - emit LogNamedBytes(" Left", a); - emit LogNamedBytes(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(bytes memory a, bytes memory b, string memory err) internal virtual { - if (!Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails. - function assertEq(bytes32 a, bytes32 b) internal virtual { - if (a != b) { - emit Log("Error: a == b not satisfied [bytes32]"); - emit LogNamedBytes32(" Left", a); - emit LogNamedBytes32(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - function assertEq(bytes32 a, bytes32 b, string memory err) internal virtual { - if (a != b) { - emit LogNamedString("Error", err); - assertEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(bytes32[] memory a, bytes32[] memory b) internal virtual { - if (!Helpers.eq(a, b)) { - emit Log("Error: a == b not satisfied [bytes32[]]"); - emit LogNamedArray(" Left", a); - emit LogNamedArray(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(bytes32[] memory a, bytes32[] memory b, string memory err) internal virtual { - if (!Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are equal. - function assertEq(int256 a, int256 b) internal virtual { - if (a != b) { - emit Log("Error: a == b not satisfied [int256]"); - emit LogNamedInt256(" Left", a); - emit LogNamedInt256(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - function assertEq(int256 a, int256 b, string memory err) internal virtual { - if (a != b) { - emit LogNamedString("Error", err); - assertEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(int256[] memory a, int256[] memory b) internal virtual { - if (!Helpers.eq(a, b)) { - emit Log("Error: a == b not satisfied [int256[]]"); - emit LogNamedArray(" Left", a); - emit LogNamedArray(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(int256[] memory a, int256[] memory b, string memory err) internal virtual { - if (!Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails. - /// Works by comparing the `keccak256` hashes of the strings, which is faster than iterating over the elements. - function assertEq(string memory a, string memory b) internal virtual { - if (!Helpers.eq(a, b)) { - emit Log("Error: a == b not satisfied [string]"); - emit LogNamedString(" Left", a); - emit LogNamedString(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the strings, which is faster than iterating over the elements. - function assertEq(string memory a, string memory b, string memory err) internal virtual { - if (!Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(string[] memory a, string[] memory b) internal virtual { - if (!Helpers.eq(a, b)) { - emit Log("Error: a == b not satisfied [string[]]"); - emit LogNamedArray(" Left", a); - emit LogNamedArray(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(string[] memory a, string[] memory b, string memory err) internal virtual { - if (!Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails. - function assertEq(uint256 a, uint256 b) internal virtual { - if (a != b) { - emit Log("Error: a == b not satisfied [uint256]"); - emit LogNamedUint256(" Left", a); - emit LogNamedUint256(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - function assertEq(uint256 a, uint256 b, string memory err) internal virtual { - if (a != b) { - emit LogNamedString("Error", err); - assertEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(uint256[] memory a, uint256[] memory b) internal virtual { - if (!Helpers.eq(a, b)) { - emit Log("Error: a == b not satisfied [uint256[]]"); - emit LogNamedArray(" Left", a); - emit LogNamedArray(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertEq(uint256[] memory a, uint256[] memory b, string memory err) internal virtual { - if (!Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertEq(a, b); - } - } - - /*////////////////////////////////////////////////////////////////////////// - INEQUALITY ASSERTIONS - //////////////////////////////////////////////////////////////////////////*/ - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails. - function assertNotEq(address a, address b) internal virtual { - if (a == b) { - emit Log("Error: a != b not satisfied [address]"); - emit LogNamedAddress(" Left", a); - emit LogNamedAddress(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails with the error message `err`. - function assertNotEq(address a, address b, string memory err) internal virtual { - if (a == b) { - emit LogNamedString("Error", err); - assertNotEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(address[] memory a, address[] memory b) internal virtual { - if (Helpers.eq(a, b)) { - emit Log("Error: a != b not satisfied [address[]]"); - emit LogNamedArray(" Left", a); - emit LogNamedArray(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(address[] memory a, address[] memory b, string memory err) internal virtual { - if (Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertNotEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails. - function assertNotEq(bool a, bool b) internal virtual { - if (a == b) { - emit Log("Error: a != b not satisfied [bool]"); - emit LogNamedString(" Left", a ? "true" : "false"); - emit LogNamedString(" Right", b ? "true" : "false"); - fail(); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails with the error message `err`. - function assertNotEq(bool a, bool b, string memory err) internal virtual { - if (a == b) { - emit LogNamedString("Error", err); - assertNotEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(bool[] memory a, bool[] memory b) internal virtual { - if (Helpers.eq(a, b)) { - emit Log("Error: a != b not satisfied [bool[]]"); - emit LogNamedArray(" Left", a); - emit LogNamedArray(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(bool[] memory a, bool[] memory b, string memory err) internal virtual { - if (Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertNotEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(bytes memory a, bytes memory b) internal virtual { - if (Helpers.eq(a, b)) { - emit Log("Error: a != b not satisfied [bytes]"); - emit LogNamedBytes(" Left", a); - emit LogNamedBytes(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are equal. If they are not, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(bytes memory a, bytes memory b, string memory err) internal virtual { - if (Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertNotEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails. - function assertNotEq(bytes32 a, bytes32 b) internal virtual { - if (Helpers.eq(a, b)) { - emit Log("Error: a != b not satisfied [bytes32]"); - emit LogNamedBytes32(" Left", a); - emit LogNamedBytes32(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails with the error message `err`. - function assertNotEq(bytes32 a, bytes32 b, string memory err) internal virtual { - if (Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertNotEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(bytes32[] memory a, bytes32[] memory b) internal virtual { - if (Helpers.eq(a, b)) { - emit Log("Error: a != b not satisfied [bytes32[]]"); - emit LogNamedArray(" Left", a); - emit LogNamedArray(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(bytes32[] memory a, bytes32[] memory b, string memory err) internal virtual { - if (Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertNotEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails. - function assertNotEq(int256 a, int256 b) internal virtual { - if (a == b) { - emit Log("Error: a != b not satisfied [int256]"); - emit LogNamedInt256(" Left", a); - emit LogNamedInt256(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails with the error message `err`. - function assertNotEq(int256 a, int256 b, string memory err) internal virtual { - if (a == b) { - emit LogNamedString("Error", err); - assertNotEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(int256[] memory a, int256[] memory b) internal virtual { - if (Helpers.eq(a, b)) { - emit Log("Error: a != b not satisfied [int256[]]"); - emit LogNamedArray(" Left", a); - emit LogNamedArray(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(int256[] memory a, int256[] memory b, string memory err) internal virtual { - if (Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertNotEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails. - /// Works by comparing the `keccak256` hashes of the strings, which is faster than iterating over the elements. - function assertNotEq(string memory a, string memory b) internal virtual { - if (Helpers.eq(a, b)) { - emit Log("Error: a != b not satisfied [string]"); - emit LogNamedString(" Left", a); - emit LogNamedString(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the strings, which is faster than iterating over the elements. - function assertNotEq(string memory a, string memory b, string memory err) internal virtual { - if (Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertNotEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(string[] memory a, string[] memory b) internal virtual { - if (Helpers.eq(a, b)) { - emit Log("Error: a != b not satisfied [string[]]"); - emit LogNamedArray(" Left", a); - emit LogNamedArray(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(string[] memory a, string[] memory b, string memory err) internal virtual { - if (Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertNotEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails. - function assertNotEq(uint256 a, uint256 b) internal virtual { - if (a == b) { - emit Log("Error: a != b not satisfied [uint256]"); - emit LogNamedUint256(" Left", a); - emit LogNamedUint256(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails with the error message `err`. - function assertNotEq(uint256 a, uint256 b, string memory err) internal virtual { - if (a == b) { - emit LogNamedString("Error", err); - assertNotEq(a, b); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(uint256[] memory a, uint256[] memory b) internal virtual { - if (Helpers.eq(a, b)) { - emit Log("Error: a != b not satisfied [uint256[]]"); - emit LogNamedArray(" Left", a); - emit LogNamedArray(" Right", b); - fail(); - } - } - - /// @dev Tests that `a` and `b` are not equal. If they are, the test fails with the error message `err`. - /// Works by comparing the `keccak256` hashes of the arrays, which is faster than iterating over the elements. - function assertNotEq(uint256[] memory a, uint256[] memory b, string memory err) internal virtual { - if (Helpers.eq(a, b)) { - emit LogNamedString("Error", err); - assertNotEq(a, b); - } - } - - /*////////////////////////////////////////////////////////////////////////// - APPROXIMATE ASSERTIONS - //////////////////////////////////////////////////////////////////////////*/ - - /// @dev Tests that the absolute difference between `a and `b` is less than or equal to `maxDelta`. - /// If it is not, the test fails. - function assertAlmostEq(int256 a, int256 b, uint256 maxDelta) internal virtual { - uint256 actualDelta = Helpers.delta(a, b); - if (actualDelta > maxDelta) { - emit Log("Error: a ~= b not satisfied [int256]"); - emit LogNamedInt256(" Expected", b); - emit LogNamedInt256(" Right", a); - emit LogNamedUint256(" Max Delta", maxDelta); - emit LogNamedUint256(" Actual Delta", actualDelta); - fail(); - } - } - - /// @dev Tests that the absolute difference between `a and `b` is less than or equal to `maxDelta`. - /// If it is not, the test fails with the error message `err`. - function assertAlmostEq(int256 a, int256 b, uint256 maxDelta, string memory err) internal virtual { - if (Helpers.delta(a, b) > maxDelta) { - emit LogNamedString("Error", err); - assertAlmostEq(a, b, maxDelta); - } - } - - /// @dev Tests that the absolute difference between `a and `b` is less than or equal to `maxDelta`. - /// If it is not, the test fails. - function assertAlmostEq(uint256 a, uint256 b, uint256 maxDelta) internal virtual { - uint256 actualDelta = Helpers.delta(a, b); - if (actualDelta > maxDelta) { - emit Log("Error: a ~= b not satisfied [uint256]"); - emit LogNamedUint256(" Expected", b); - emit LogNamedUint256(" Right", a); - emit LogNamedUint256(" Max Delta", maxDelta); - emit LogNamedUint256(" Actual Delta", actualDelta); - fail(); - } - } - - /// @dev Tests that the absolute difference between `a and `b` is less than or equal to `maxDelta`. - /// If it is not, the test fails with the error message `err`. - function assertAlmostEq(uint256 a, uint256 b, uint256 maxDelta, string memory err) internal virtual { - if (Helpers.delta(a, b) > maxDelta) { - emit LogNamedString("Error", err); - assertAlmostEq(a, b, maxDelta); - } - } - - /*////////////////////////////////////////////////////////////////////////// - NUMERICAL COMPARISON ASSERTIONS - //////////////////////////////////////////////////////////////////////////*/ - - /// @dev Tests that `a` is greater than `b`. If it is not, the test fails. - function assertGt(int256 a, int256 b) internal virtual { - if (a <= b) { - emit Log("Error: a > b not satisfied [int256]"); - emit LogNamedInt256(" Value a", a); - emit LogNamedInt256(" Value b", b); - fail(); - } - } - - /// @dev Tests that `a` is greater than `b`. If it is not, the test fails with the error message `err`. - function assertGt(int256 a, int256 b, string memory err) internal virtual { - if (a <= b) { - emit LogNamedString("Error", err); - assertGt(a, b); - } - } - - /// @dev Tests that `a` is greater than `b`. If it is not, the test fails. - function assertGt(uint256 a, uint256 b) internal virtual { - if (a <= b) { - emit Log("Error: a > b not satisfied [uint256]"); - emit LogNamedUint256(" Value a", a); - emit LogNamedUint256(" Value b", b); - fail(); - } - } - - /// @dev Tests that `a` is greater than `b`. If it is not, the test fails with the error message `err`. - function assertGt(uint256 a, uint256 b, string memory err) internal virtual { - if (a <= b) { - emit LogNamedString("Error", err); - assertGt(a, b); - } - } - - /// @dev Tests that `a` is greater than or equal to `b`. If it is not, the test fails. - function assertGte(int256 a, int256 b) internal virtual { - if (a < b) { - emit Log("Error: a >= b not satisfied [int256]"); - emit LogNamedInt256(" Value a", a); - emit LogNamedInt256(" Value b", b); - fail(); - } - } - - /// @dev Tests that `a` is greater than or equal to `b`. If it is not, the test fails with the error message `err`. - function assertGte(int256 a, int256 b, string memory err) internal virtual { - if (a < b) { - emit LogNamedString("Error", err); - assertGte(a, b); - } - } - - /// @dev Tests that `a` is greater than or equal to `b`. If it is not, the test fails. - function assertGte(uint256 a, uint256 b) internal virtual { - if (a < b) { - emit Log("Error: a >= b not satisfied [uint256]"); - emit LogNamedUint256(" Value a", a); - emit LogNamedUint256(" Value b", b); - fail(); - } - } - - /// @dev Tests that `a` is greater than or equal to `b`. If it is not, the test fails with the error message `err`. - function assertGte(uint256 a, uint256 b, string memory err) internal virtual { - if (a < b) { - emit LogNamedString("Error", err); - assertGte(a, b); - } - } - - /// @dev Tests that `a` is lower than `b`. If it is not, the test fails. - function assertLt(int256 a, int256 b) internal virtual { - if (a >= b) { - emit Log("Error: a < b not satisfied [int256]"); - emit LogNamedInt256(" Value a", a); - emit LogNamedInt256(" Value b", b); - fail(); - } - } - - /// @dev Tests that `a` is lower than `b`. If it is not, the test fails with the error message `err`. - function assertLt(int256 a, int256 b, string memory err) internal virtual { - if (a >= b) { - emit LogNamedString("Error", err); - assertLt(a, b); - } - } - - /// @dev Tests that `a` is lower than `b`. If it is not, the test fails. - function assertLt(uint256 a, uint256 b) internal virtual { - if (a >= b) { - emit Log("Error: a < b not satisfied [uint256]"); - emit LogNamedUint256(" Value a", a); - emit LogNamedUint256(" Value b", b); - fail(); - } - } - - /// @dev Tests that `a` is lower than `b`. If it is not, the test fails with the error message `err`. - function assertLt(uint256 a, uint256 b, string memory err) internal virtual { - if (a >= b) { - emit LogNamedString("Error", err); - assertLt(a, b); - } - } - - /// @dev Tests that `a` is lower than or equal to `b`. If it is not, the test fails. - function assertLte(int256 a, int256 b) internal virtual { - if (a > b) { - emit Log("Error: a <= b not satisfied [int256]"); - emit LogNamedInt256(" Value a", a); - emit LogNamedInt256(" Value b", b); - fail(); - } - } - - /// @dev Tests that `a` is lower than or equal to `b`. If it is not, the test fails with the error message `err`. - function assertLte(int256 a, int256 b, string memory err) internal virtual { - if (a > b) { - emit LogNamedString("Error", err); - assertLte(a, b); - } - } - - /// @dev Tests that `a` is lower than or equal to `b`. If it is not, the test fails. - function assertLte(uint256 a, uint256 b) internal virtual { - if (a > b) { - emit Log("Error: a <= b not satisfied [uint256]"); - emit LogNamedUint256(" Value a", a); - emit LogNamedUint256(" Value b", b); - fail(); - } - } - - /// @dev Tests that `a` is lower than or equal to `b`. If it is not, the test fails with the error message `err`. - function assertLte(uint256 a, uint256 b, string memory err) internal virtual { - if (a > b) { - emit LogNamedString("Error", err); - assertLte(a, b); - } - } - - /*////////////////////////////////////////////////////////////////////////// - CONTAINMENT ASSERTIONS - //////////////////////////////////////////////////////////////////////////*/ - - /// @dev Tests that `a` contains `b`. If it does not, the test fails. - function assertContains(address[] memory a, address b) internal virtual { - if (!Helpers.contains(a, b)) { - emit Log("Error: a does not contain b [address[]]"); - emit LogNamedArray(" Array a", a); - emit LogNamedAddress(" Item b", b); - fail(); - } - } - - /// @dev Tests that `a` contains `b`. If it does not, the test fails with the error message `err`. - function assertContains(address[] memory a, address b, string memory err) internal virtual { - if (!Helpers.contains(a, b)) { - emit LogNamedString("Error", err); - assertContains(a, b); - } - } - - /// @dev Tests that `a` contains `b`. If it does not, the test fails. - function assertContains(bytes32[] memory a, bytes32 b) internal virtual { - if (!Helpers.contains(a, b)) { - emit Log("Error: a does not contain b [bytes32[]]"); - emit LogNamedArray(" Array a", a); - emit LogNamedBytes32(" Item b", b); - fail(); - } - } - - /// @dev Tests that `a` contains `b`. If it does not, the test fails with the error message `err`. - function assertContains(bytes32[] memory a, bytes32 b, string memory err) internal virtual { - if (!Helpers.contains(a, b)) { - emit LogNamedString("Error", err); - assertContains(a, b); - } - } - - /// @dev Tests that `a` contains `b`. If it does not, the test fails. - function assertContains(int256[] memory a, int256 b) internal virtual { - if (!Helpers.contains(a, b)) { - emit Log("Error: a does not contain b [int256[]]"); - emit LogNamedArray(" Array a", a); - emit LogNamedInt256(" Item b", b); - fail(); - } - } - - /// @dev Tests that `a` contains `b`. If it does not, the test fails with the error message `err`. - function assertContains(int256[] memory a, int256 b, string memory err) internal virtual { - if (!Helpers.contains(a, b)) { - emit LogNamedString("Error", err); - assertContains(a, b); - } - } - - /// @dev Tests that `a` contains `b`. If it does not, the test fails. - function assertContains(string[] memory a, string memory b) internal virtual { - if (!Helpers.contains(a, b)) { - emit Log("Error: a does not contain b [string[]]"); - emit LogNamedArray(" Array a", a); - emit LogNamedString(" Item b", b); - fail(); - } - } - - /// @dev Tests that `a` contains `b`. If it does not, the test fails with the error message `err`. - function assertContains(string[] memory a, string memory b, string memory err) internal virtual { - if (!Helpers.contains(a, b)) { - emit LogNamedString("Error", err); - assertContains(a, b); - } - } - - /// @dev Tests that `a` contains `b`. If it does not, the test fails. - function assertContains(uint256[] memory a, uint256 b) internal virtual { - if (!Helpers.contains(a, b)) { - emit Log("Error: a does not contain b [uint256[]]"); - emit LogNamedArray(" Array a", a); - emit LogNamedUint256(" Item b", b); - fail(); - } - } - - /// @dev Tests that `a` contains `b`. If it does not, the test fails with the error message `err`. - function assertContains(uint256[] memory a, uint256 b, string memory err) internal virtual { - if (!Helpers.contains(a, b)) { - emit LogNamedString("Error", err); - assertContains(a, b); - } - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/src/Vm.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/src/Vm.sol deleted file mode 100644 index 7f0b2cde..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/src/Vm.sol +++ /dev/null @@ -1,743 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0 <0.9.0; - -/// Cheatcodes are marked as view/pure/none using the following rules: -/// -/// 1. A call's observable behavior includes its return value, logs, reverts and state writes, -/// 2. If it can influence a later call's observable behavior, it's neither view nor pure (it is modifying some -/// state be it the EVM, interpreter, filesystem, etc), -/// 3. Otherwise, if it can be influenced by an earlier call, or if reading some state, it's view, -/// 4. Otherwise, it's pure. - -/// @notice An EVM interpreter written with testing and debugging in mind. This is usually either HEVM or REVM. -/// @dev This interface can be safely used in scripts running on a live network, so for example you don't accidentally -/// change the block timestamp and use a fake timestamp as a value somewhere. -interface VmSafe { - struct DirEntry { - string errorMessage; - string path; - uint64 depth; - bool isDir; - bool isSymlink; - } - - struct FsMetadata { - bool isDir; - bool isSymlink; - uint256 length; - bool readOnly; - uint256 modified; - uint256 accessed; - uint256 created; - } - - struct Log { - bytes32[] topics; - bytes data; - address emitter; - } - - struct Rpc { - string key; - string url; - } - - /// @dev Gets all accessed reads and write slot from a recording session, for a given address. - function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots); - - /// @dev Gets the address for a given private key. - function addr(uint256 privateKey) external pure returns (address keyAddr); - - /// @dev If the condition is false, discard this run's fuzz inputs and generate new ones. - function assume(bool condition) external pure; - - /// @dev Writes a breakpoint to jump to in the debugger. - function breakpoint(string calldata char) external; - - /// @dev Writes a conditional breakpoint to jump to in the debugger. - function breakpoint(string calldata char, bool value) external; - - /// @dev Using the address that calls the test contract, has the next call (at this call depth only) create a - /// transaction that can later be signed and sent onchain. - function broadcast() external; - - /// @dev Has the next call (at this call depth only) create a transaction with the address provided as - /// the sender that can later be signed and sent onchain. - function broadcast(address signer) external; - - /// @dev Has the next call (at this call depth only) create a transaction with the private key provided as - /// the sender that can later be signed and sent onchain - function broadcast(uint256 privateKey) external; - - /// @dev Closes file for reading, resetting the offset and allowing to read it from beginning with readLine. - function closeFile(string calldata path) external; - - /// @dev Creates a new, empty directory at the provided path, which is relative ot the project root. - /// This cheatcode will revert in the following situations, but is not limited to just these cases: - /// - User lacks permissions to modify `path`. - /// - A parent of the given path doesn't exist and `recursive` is false. - /// - `path` already exists and `recursive` is false. - function createDir(string calldata path, bool recursive) external; - - /// @dev Derive a private key from a provided mnenomic string (or mnenomic file path) at the derivation - /// path m/44'/60'/0'/0/{index} - function deriveKey(string calldata mnemonic, uint32 index) external pure returns (uint256 privateKey); - - /// @dev Derive a private key from a provided mnenomic string (or mnenomic file path) at {derivationPath}{index} - function deriveKey( - string calldata mnemonic, - string calldata derivationPath, - uint32 index - ) - external - pure - returns (uint256 privateKey); - - /// @dev Reads environment variables - function envAddress(string calldata name) external view returns (address value); - - function envBool(string calldata name) external view returns (bool value); - - function envBytes(string calldata name) external view returns (bytes memory value); - - function envBytes32(string calldata name) external view returns (bytes32 value); - - function envInt(string calldata name) external view returns (int256 value); - - function envString(string calldata name) external view returns (string memory value); - - function envUint(string calldata name) external view returns (uint256 value); - - /// @dev Reads environment variables as arrays. - function envAddress(string calldata name, string calldata delim) external view returns (address[] memory values); - - function envBool(string calldata name, string calldata delim) external view returns (bool[] memory values); - - function envBytes(string calldata name, string calldata delim) external view returns (bytes[] memory values); - - function envBytes32(string calldata name, string calldata delim) external view returns (bytes32[] memory values); - - function envInt(string calldata name, string calldata delim) external view returns (int256[] memory values); - - function envString(string calldata name, string calldata delim) external view returns (string[] memory values); - - function envUint(string calldata name, string calldata delim) external view returns (uint256[] memory values); - - /// @dev Reads environment variables with a default value. - function envOr(string calldata name, bool defaultValue) external returns (bool value); - - function envOr(string calldata name, uint256 defaultValue) external returns (uint256 value); - - function envOr(string calldata name, int256 defaultValue) external returns (int256 value); - - function envOr(string calldata name, address defaultValue) external returns (address value); - - function envOr(string calldata name, bytes32 defaultValue) external returns (bytes32 value); - - function envOr(string calldata name, string calldata defaultValue) external returns (string memory value); - - function envOr(string calldata name, bytes calldata defaultValue) external returns (bytes memory value); - - /// @dev Reads environment variables as arrays with default value. - function envOr( - string calldata name, - string calldata, - bool[] calldata defaultValue - ) - external - returns (bool[] memory value); - - function envOr( - string calldata name, - string calldata, - uint256[] calldata defaultValue - ) - external - returns (uint256[] memory value); - - function envOr( - string calldata name, - string calldata, - int256[] calldata defaultValue - ) - external - returns (int256[] memory value); - - function envOr( - string calldata name, - string calldata, - address[] calldata defaultValue - ) - external - returns (address[] memory value); - - function envOr( - string calldata name, - string calldata, - bytes32[] calldata defaultValue - ) - external - returns (bytes32[] memory value); - - function envOr( - string calldata name, - string calldata, - string[] calldata defaultValue - ) - external - returns (string[] memory value); - - function envOr( - string calldata name, - string calldata, - bytes[] calldata defaultValue - ) - external - returns (bytes[] memory value); - - /// @dev Performs a foreign function call via the terminal. - function ffi(string[] calldata commandInput) external returns (bytes memory result); - - /// @dev Given a path, query the file system to get information about a file, directory, etc. - function fsMetadata(string calldata fileOrDir) external returns (FsMetadata memory metadata); - - /// @dev Gets the code from an artifact file. Takes in the relative path to the json file. - function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode); - - /// @dev Gets the _deployed_ bytecode from an artifact file. Takes in the relative path to the json file. - function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode); - - /// @dev Gets the nonce of an account. - function getNonce(address account) external view returns (uint64 nonce); - - /// @dev Gets all the recorded logs. - function getRecordedLogs() external returns (Log[] memory logs); - - /// @dev Labels an address in call traces. - function label(address account, string calldata newLabel) external; - - /// @dev Loads a storage slot from an address. - function load(address target, bytes32 slot) external view returns (bytes32 data); - - /// @dev Convert values from a string - function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue); - - function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue); - - function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue); - - function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue); - - function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue); - - /// In case the returned value is a JSON object, it's encoded as a ABI-encoded tuple. As JSON objects - /// don't have the notion of ordered, but tuples do, they JSON object is encoded with it's fields ordered in - /// ALPHABETICAL order. That means that in order to successfully decode the tuple, we need to define a tuple that - /// encodes the fields in the same order, which is alphabetical. In the case of Solidity structs, they are encoded - /// as tuples, with the attributes in the order in which they are defined. - /// For example: json = { 'a': 1, 'b': 0xa4tb......3xs} - /// a: uint256 - /// b: address - /// To decode that json, we need to define a struct or a tuple as follows: - /// struct json = { uint256 a; address b; } - /// If we defined a json struct with the opposite order, meaning placing the address b first, it would try to - /// decode the tuple in that order, and thus fail. - /// ---- - /// Given a string of JSON, return it as ABI-encoded - function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData); - - function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData); - - /// The following parseJson cheatcodes will do type coercion, for the type that they indicate. - /// For example, parseJsonUint will coerce all values to a uint256. That includes stringified numbers "12" - /// and hex numbers "0xEF". - /// Type coercion works ONLY for discrete values or arrays. That means that the key must return a value or array, - /// not a JSON object. - function parseJsonAddress(string calldata, string calldata) external returns (address); - - function parseJsonAddressArray(string calldata, string calldata) external returns (address[] memory); - - function parseJsonBytes(string calldata, string calldata) external returns (bytes memory); - - function parseJsonBytesArray(string calldata, string calldata) external returns (bytes[] memory); - - function parseJsonBytes32(string calldata, string calldata) external returns (bytes32); - - function parseJsonBytes32Array(string calldata, string calldata) external returns (bytes32[] memory); - - function parseJsonInt(string calldata, string calldata) external returns (int256); - - function parseJsonIntArray(string calldata, string calldata) external returns (int256[] memory); - - function parseJsonBool(string calldata, string calldata) external returns (bool); - - function parseJsonBoolArray(string calldata, string calldata) external returns (bool[] memory); - - function parseJsonString(string calldata, string calldata) external returns (string memory); - - function parseJsonStringArray(string calldata, string calldata) external returns (string[] memory); - - function parseJsonUint(string calldata, string calldata) external returns (uint256); - - function parseJsonUintArray(string calldata, string calldata) external returns (uint256[] memory); - - function parseUint(string calldata value) external pure returns (uint256 parsedValue); - - /// @dev Pauses gas metering (i.e. gas usage is not counted). No-op if already paused. - function pauseGasMetering() external; - - /// @dev Get the path of the current project root - function projectRoot() external view returns (string memory path); - - /// @dev Removes a directory at the provided path, which is relative to the project root. - /// This cheatcode will revert in the following situations, but is not limited to just these cases: - /// - `path` doesn't exist. - /// - `path` isn't a directory. - /// - User lacks permissions to modify `path`. - /// - The directory is not empty and `recursive` is false. - function removeDir(string calldata path, bool recursive) external; - - /// @dev Reads the directory at the given path recursively, up to `max_depth`. - /// `max_depth` defaults to 1, meaning only the direct children of the given directory will be returned. - /// Follows symbolic links if `follow_links` is true. - function readDir(string calldata path) external view returns (DirEntry[] memory entries); - function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries); - function readDir( - string calldata path, - uint64 maxDepth, - bool followLinks - ) - external - view - returns (DirEntry[] memory entries); - - /// @dev Reads the entire content of file to string. `path` is relative to the project root. - function readFile(string calldata path) external view returns (string memory data); - - /// @dev Reads the entire content of file as binary. `path` is relative to the project root. - function readFileBinary(string calldata path) external view returns (bytes memory data); - - /// @dev Reads a symbolic link, returning the path that the link points to. - /// This cheatcode will revert in the following situations, but is not limited to just these cases: - /// - `path` is not a symbolic link. - /// - `path` does not exist. - function readLink(string calldata linkPath) external view returns (string memory targetPath); - - /// @dev Records all storage reads and writes. - function record() external; - - /// @dev Record all the transaction logs. - function recordLogs() external; - - /// @dev Adds a private key to the local Forge wallet and returns the address. - function rememberKey(uint256 privateKey) external returns (address keyAddr); - - /// @dev Resumes gas metering (i.e. gas usage is counted again). No-op if already on. - function resumeGasMetering() external; - - //// @dev Returns the RPC url for the given alias. - function rpcUrl(string calldata rpcAlias) external view returns (string memory json); - - //// @dev Returns all rpc urls and their aliases `[alias, url][]`. - function rpcUrls() external view returns (string[2][] memory urls); - - /// @dev Returns all rpc urls and their aliases as structs. - function rpcUrlStructs() external view returns (Rpc[] memory urls); - - /// @dev Serializes a key and value to a JSON object stored in-memory that can be later written to a file. - /// It returns the stringified version of the specific JSON file up to that moment. - function serializeBool( - string calldata objectKey, - string calldata valueKey, - bool value - ) - external - returns (string memory json); - - function serializeUint( - string calldata objectKey, - string calldata valueKey, - uint256 value - ) - external - returns (string memory json); - - function serializeInt( - string calldata objectKey, - string calldata valueKey, - int256 value - ) - external - returns (string memory json); - - function serializeAddress( - string calldata objectKey, - string calldata valueKey, - address value - ) - external - returns (string memory json); - - function serializeBytes32( - string calldata objectKey, - string calldata valueKey, - bytes32 value - ) - external - returns (string memory json); - - function serializeString( - string calldata objectKey, - string calldata valueKey, - string calldata value - ) - external - returns (string memory json); - - function serializeBytes( - string calldata objectKey, - string calldata valueKey, - bytes calldata value - ) - external - returns (string memory json); - - function serializeBool( - string calldata objectKey, - string calldata valueKey, - bool[] calldata values - ) - external - returns (string memory json); - - function serializeUint( - string calldata objectKey, - string calldata valueKey, - uint256[] calldata values - ) - external - returns (string memory json); - - function serializeInt( - string calldata objectKey, - string calldata valueKey, - int256[] calldata values - ) - external - returns (string memory json); - - function serializeAddress( - string calldata objectKey, - string calldata valueKey, - address[] calldata values - ) - external - returns (string memory json); - - function serializeBytes32( - string calldata objectKey, - string calldata valueKey, - bytes32[] calldata values - ) - external - returns (string memory json); - - function serializeString( - string calldata objectKey, - string calldata valueKey, - string[] calldata values - ) - external - returns (string memory json); - - function serializeBytes( - string calldata objectKey, - string calldata valueKey, - bytes[] calldata values - ) - external - returns (string memory json); - - /// @dev Sets environment variables. - function setEnv(string calldata name, string calldata value) external; - - /// @dev Signs data. - function sign(uint256 privateKey, bytes32 digest) external pure returns (uint8 v, bytes32 r, bytes32 s); - - /// @dev Using the address that calls the test contract, has all subsequent calls (at this call depth only) - /// create transactions that can later be signed and sent onchain. - function startBroadcast() external; - - /// @dev Has all subsequent calls (at this call depth only) create transactions that can later be signed and - /// sent onchain. - function startBroadcast(address broadcaster) external; - - /// @dev Has all subsequent calls (at this call depth only) create transactions with the private key provided that - /// can later be signed and sent onchain - function startBroadcast(uint256 privateKey) external; - - /// @dev Stops collecting onchain transactions. - function stopBroadcast() external; - - /// Convert values to a string. - function toString(address value) external pure returns (string memory stringifiedValue); - - function toString(bool value) external pure returns (string memory stringifiedValue); - - function toString(bytes calldata value) external pure returns (string memory stringifiedValue); - - function toString(bytes32 value) external pure returns (string memory stringifiedValue); - - function toString(int256 value) external pure returns (string memory stringifiedValue); - - function toString(uint256 value) external pure returns (string memory stringifiedValue); - - /// @dev Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does. - /// `path` is relative to the project root - function writeFile(string calldata path, string calldata data) external; - - /// @dev Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if - /// it does. `path` is relative to the project root. - function writeFileBinary(string calldata path, bytes calldata data) external; - - /// @dev Writes line to file, creating a file if it does not exist. `path` is relative to the project root. - function writeLine(string calldata path, string calldata data) external; - - /// @dev Write a serialized JSON object to a file. If the file exists, it will be overwritten. - function writeJson(string calldata json, string calldata path) external; - - /// @dev Write a serialized JSON object to an **existing** JSON file, replacing a value with key = - /// This is useful to replace a specific value of a JSON file, without having to parse the entire thing - function writeJson(string calldata json, string calldata path, string calldata valueKey) external; -} - -/// @notice An EVM interpreter written with testing and debugging in mind. This is usually either HEVM or REVM. -/// @dev This interface contains cheatcodes that are potentially unsafe on a live network. -interface Vm is VmSafe { - //// @dev Returns the identifier of the currently active fork. Reverts if no fork is currently active. - function activeFork() external returns (uint256 forkId); - - /// @dev In forking mode, explicitly grant the given address cheatcode access - function allowCheatcodes(address account) external; - - /// @dev Sets block.chainid. - function chainId(uint256 newChainId) external; - - /// @dev Clears all mocked calls. - function clearMockedCalls() external; - - /// @dev Sets block.coinbase - function coinbase(address newCoinbase) external; - - /// @dev Creates a new fork with the given endpoint and block number and returns the identifier of the fork. - function createFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256); - - /// @dev Creates a new fork with the given endpoint and the _latest_ block and returns the identifier of the fork. - function createFork(string calldata urlOrAlias) external returns (uint256); - - /// @dev Creates _and_ also selects a new fork with the given endpoint and the latest block and returns the - /// identifier of the fork. - function createSelectFork(string calldata urlOrAlias) external returns (uint256); - - /// @dev Creates _and_ also selects a new fork with the given endpoint and block number and returns the identifier - /// of the fork. - function createSelectFork(string calldata urlOrAlias, uint256 blockNumber) external returns (uint256); - - /// @dev Creates _and_ also selects new fork with the given endpoint and at the block the given transaction was - /// mined in, replays all transaction mined in the block before the transaction, returns the identifier of the fork - function createSelectFork(string calldata urlOrAlias, bytes32 txHash) external returns (uint256 forkId); - - /// @dev Sets an account's balance. - function deal(address account, uint256 newBalance) external; - - /// @dev Sets block.difficulty - function difficulty(uint256 newDifficulty) external; - - /// @dev Sets an address' code. - function etch(address target, bytes calldata newRuntimeBytecode) external; - - /// @dev Expects a call to an address with the specified calldata. - /// Calldata can be either a strict or a partial match. - function expectCall(address callee, bytes calldata data) external; - - /// @dev Expects given number of calls to an address with the specified calldata. - function expectCall(address callee, bytes calldata data, uint64 count) external; - - /// @dev Expects a call to an address with the specified msg.value and calldata. - function expectCall(address callee, uint256 msgValue, bytes calldata data) external; - - /// @dev Expects given number of calls to an address with the specified msg.value and calldata - function expectCall(address callee, uint256 msgValue, bytes calldata data, uint64 count) external; - - /// @dev Expects a call to an address with the specified msg.value, gas, and calldata. - function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data) external; - - /// @dev Expects given number of calls to an address with the specified msg.value, gas, and calldata. - function expectCall(address callee, uint256 msgValue, uint64 gas, bytes calldata data, uint64 count) external; - - /// @dev Expects a call to an address with the specified msg.value and calldata, and a *minimum* amount of gas. - function expectCallMinGas(address callee, uint256 msgValue, uint64 minGas, bytes calldata data) external; - - /// @dev Expect given number of calls to an address with the specified msg.value and calldata, and a *minimum* - /// amount of gas. - function expectCallMinGas( - address callee, - uint256 msgValue, - uint64 minGas, - bytes calldata data, - uint64 count - ) - external; - - /// @dev Prepare an expected log with all four checks enabled. - /// Call this function, then emit an event, then call a function. Internally after the call, we check if - /// logs were emitted in the expected order with the expected topics and data. - /// Second form also checks supplied address against emitting contract. - function expectEmit() external; - function expectEmit(address emitter) external; - - /// @dev Prepare an expected log. - /// Call this function, then emit an event, then call a function. Internally after the call, we check if - /// logs were emitted in the expected order with the expected topics and data (as specified by the booleans). - /// Second form also checks supplied address against emitting contract. - function expectEmit(bool checkTopic1, bool checkTopic2, bool checkTopic3, bool checkData) external; - function expectEmit( - bool checkTopic1, - bool checkTopic2, - bool checkTopic3, - bool checkData, - address emitter - ) - external; - - /// @dev Expects an error on next call. - function expectRevert(bytes calldata revertData) external; - - function expectRevert(bytes4 revertData) external; - - function expectRevert() external; - - /// @dev Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the current subcontext. If any other - /// memory is written to, the test will fail. Can be called multiple times to add more ranges to the set. - function expectSafeMemory(uint64 min, uint64 max) external; - /// @dev Only allows memory writes to offsets [0x00, 0x60) ∪ [min, max) in the next created subcontext. - /// If any other memory is written to, the test will fail. Can be called multiple times to add more ranges - /// to the set. - function expectSafeMemoryCall(uint64 min, uint64 max) external; - - /// @dev Sets block.basefee. - function fee(uint256 newBasefee) external; - - /// @dev Returns true if the account is marked as persistent. - function isPersistent(address account) external view returns (bool persistent); - - /// @dev Marks that the account(s) should use persistent storage across fork swaps in a multifork setup. - // Meaning, changes made to the state of this account will be kept when switching forks - function makePersistent(address account) external; - - function makePersistent(address account0, address account1) external; - - function makePersistent(address account0, address account1, address account2) external; - - function makePersistent(address[] calldata accounts) external; - - /// @dev Mocks a call to an address, returning specified data. - /// Calldata can either be strict or a partial match, e.g. if you only pass a Solidity selector to the expected - /// calldata, then the entire Solidity function will be mocked. - function mockCall(address callee, bytes calldata data, bytes calldata returnData) external; - - /// @dev Mocks a call to an address with a specific msg.value, returning specified data. - /// Calldata match takes precedence over msg.value in case of ambiguity. - function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external; - - /// @dev Reverts a call to an address with specified revert data. - function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external; - - /// @dev Reverts a call to an address with a specific msg.value, with specified revert data. - function mockCallRevert( - address callee, - uint256 msgValue, - bytes calldata data, - bytes calldata revertData - ) - external; - - /// @dev Sets the *next* call's msg.sender to be the input address. - function prank(address msgSender) external; - - /// @dev Sets the *next* call's msg.sender to be the input address, and the tx.origin to be the second input. - function prank(address msgSender, address txOrigin) external; - - /// @dev Removes a file from the filesystem. - /// This cheatcode will revert in the following situations, but is not limited to just these cases: - /// - `path` points to a directory. - /// - The file doesn't exist. - /// - The user lacks permissions to remove the file. - /// `path` is relative to the project root. - function removeFile(string calldata path) external; - - /// @dev Revert the state of the evm to a previous snapshot. - /// Takes the snapshot id to revert to. - /// This deletes the snapshot and all snapshots taken after the given snapshot id. - function revertTo(uint256 snapshotId) external returns (bool result); - - /// @dev Revokes persistent status from the address, previously added via `makePersistent` - function revokePersistent(address account) external; - - function revokePersistent(address[] calldata accounts) external; - - /// @dev Sets block.height. - function roll(uint256 newHeight) external; - - /// @dev Updates the currently active fork to given block number. This is similar to `roll` but for the - /// currently active fork. - function rollFork(uint256 forkId) external; - - /// @dev Updates the given fork to given block number. - function rollFork(uint256 forkId, uint256 blockNumber) external; - - /// @dev Updates the currently active fork to given transaction - /// this will `rollFork` with the number of the block the transaction was mined in and replays all transaction - /// mined before it in the block - function rollFork(bytes32 txHash) external; - - /// @dev Updates the given fork to block number of the given transaction and replays all transaction mined before - /// it in the block - function rollFork(uint256 forkId, bytes32 txHash) external; - - /// @dev Takes a fork identifier created by `createFork` and sets the corresponding forked state as active. - function selectFork(uint256 forkId) external; - - /// @dev Sets the nonce of an account; must be higher than the current nonce of the account. - function setNonce(address account, uint64 newNonce) external; - - /// @dev Snapshot the current state of the EVM. - /// Returns the id of the snapshot that was created. - /// To revert a snapshot use `revertTo`. - function snapshot() external returns (uint256 snapshotId); - - /// @dev Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called. - function startPrank(address msgSender) external; - - /// @dev Sets all subsequent calls' msg.sender to be the input address until `stopPrank` is called, and - /// the tx.origin to be the second input. - function startPrank(address msgSender, address txOrigin) external; - - /// @dev Resets subsequent calls' msg.sender to be `address(this)`. - function stopPrank() external; - - /// @dev Stores a value to an address' storage slot. - function store(address target, bytes32 slot, bytes32 value) external; - - /// @dev Fetches the given transaction from the active fork and executes it on the current state - function transact(bytes32 txHash) external; - - /// @dev Fetches the given transaction from the given fork and executes it on the current state - function transact(uint256 forkId, bytes32 txHash) external; - - /// @dev Sets tx.gasprice. - function txGasPrice(uint256 newGasPrice) external; - - /// @dev Sets block.timestamp. - function warp(uint256 timestamp) external; -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/PRBTest.t.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/test/PRBTest.t.sol deleted file mode 100644 index e67efaa1..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/PRBTest.t.sol +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import { PRBTest } from "../src/PRBTest.sol"; -import { PRBTestMock } from "./PRBTestMock.t.sol"; - -contract PRBTest_Test is PRBTest { - /*////////////////////////////////////////////////////////////////////////// - CONSTANTS - //////////////////////////////////////////////////////////////////////////*/ - - string internal constant ERR = "bah!"; - bool internal constant EXPECT_FAIL = true; - bool internal constant EXPECT_PASS = false; - - /*////////////////////////////////////////////////////////////////////////// - TESTING CONTRACTS - //////////////////////////////////////////////////////////////////////////*/ - - PRBTestMock internal prbTest = new PRBTestMock(); -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/PRBTestMock.t.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/test/PRBTestMock.t.sol deleted file mode 100644 index e4a1e595..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/PRBTestMock.t.sol +++ /dev/null @@ -1,627 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import { PRBTest } from "../src/PRBTest.sol"; - -contract PRBTestMock is PRBTest { - /*////////////////////////////////////////////////////////////////////////// - FAILURE SYSTEM - //////////////////////////////////////////////////////////////////////////*/ - - /// @dev The HEVM will think that the test failed if it sees "failed" set to "0x01" at the end of the test. - /// But because we're testing test assertions, "failed" being set to "0x01" might mean that our test passed. - /// We need to set it back to "0x00". - /// - /// See https://github.com/dapphub/ds-test/pull/30. - modifier expectFailure(bool expectFail) { - // Load the previous state of the "failed" slot. - bool preFailed = vm.load(HEVM_ADDRESS, bytes32("failed")) == bytes32(uint256(0x01)); - - // The body of the function using this modifier is inserted here. - _; - - // If the state of the DSTest contract was failed even before running this test, stop here. - if (preFailed) { - return; - } - - // Load the current state of the "failed" slot. - bool postFailed = vm.load(HEVM_ADDRESS, bytes32("failed")) == bytes32(uint256(0x01)); - - // If the test expected the assertion to fail, then check if it did. - if (expectFail) { - require(postFailed, "expected failure not triggered"); - - // Unwind the expected failure so that the test passes. - vm.store(HEVM_ADDRESS, bytes32("failed"), bytes32(0x00)); - } else { - require(!postFailed, "unexpected failure was triggered"); - } - } - - function _fail() external expectFailure(true) { - fail(); - } - - function _fail(string memory err) external expectFailure(true) { - fail(err); - } - - /*////////////////////////////////////////////////////////////////////////// - BOOLEAN ASSERTIONS - //////////////////////////////////////////////////////////////////////////*/ - - function _assertFalse(bool condition, bool expectFail) external expectFailure(expectFail) { - assertFalse(condition); - } - - function _assertFalse(bool condition, string memory err, bool expectFail) external expectFailure(expectFail) { - assertFalse(condition, err); - } - - function _assertTrue(bool condition, bool expectFail) external expectFailure(expectFail) { - assertTrue(condition); - } - - function _assertTrue(bool condition, string memory err, bool expectFail) external expectFailure(expectFail) { - assertTrue(condition, err); - } - - /*////////////////////////////////////////////////////////////////////////// - EQUALITY ASSERTIONS - //////////////////////////////////////////////////////////////////////////*/ - - function _assertEq(address a, address b, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b); - } - - function _assertEq(address a, address b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b, err); - } - - function _assertEq(address[] memory a, address[] memory b, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b); - } - - function _assertEq( - address[] memory a, - address[] memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertEq(a, b, err); - } - - function _assertEq(bool a, bool b, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b); - } - - function _assertEq(bool a, bool b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b, err); - } - - function _assertEq(bool[] memory a, bool[] memory b, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b); - } - - function _assertEq( - bool[] memory a, - bool[] memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertEq(a, b, err); - } - - function _assertEq(bytes memory a, bytes memory b, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b); - } - - function _assertEq( - bytes memory a, - bytes memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertEq(a, b, err); - } - - function _assertEq(bytes32 a, bytes32 b, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b); - } - - function _assertEq(bytes32 a, bytes32 b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b, err); - } - - function _assertEq(bytes32[] memory a, bytes32[] memory b, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b); - } - - function _assertEq( - bytes32[] memory a, - bytes32[] memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertEq(a, b, err); - } - - function _assertEq(int256 a, int256 b, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b); - } - - function _assertEq(int256 a, int256 b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b, err); - } - - function _assertEq(int256[] memory a, int256[] memory b, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b); - } - - function _assertEq( - int256[] memory a, - int256[] memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertEq(a, b, err); - } - - function _assertEq(string memory a, string memory b, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b); - } - - function _assertEq( - string memory a, - string memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertEq(a, b, err); - } - - function _assertEq(string[] memory a, string[] memory b, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b); - } - - function _assertEq( - string[] memory a, - string[] memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertEq(a, b, err); - } - - function _assertEq(uint256 a, uint256 b, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b); - } - - function _assertEq(uint256 a, uint256 b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b, err); - } - - function _assertEq(uint256[] memory a, uint256[] memory b, bool expectFail) external expectFailure(expectFail) { - assertEq(a, b); - } - - function _assertEq( - uint256[] memory a, - uint256[] memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertEq(a, b, err); - } - - /*////////////////////////////////////////////////////////////////////////// - INEQUALITY ASSERTIONS - //////////////////////////////////////////////////////////////////////////*/ - - function _assertNotEq(address a, address b, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b); - } - - function _assertNotEq( - address a, - address b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertNotEq(a, b, err); - } - - function _assertNotEq(address[] memory a, address[] memory b, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b); - } - - function _assertNotEq( - address[] memory a, - address[] memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertNotEq(a, b, err); - } - - function _assertNotEq(bool a, bool b, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b); - } - - function _assertNotEq(bool a, bool b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b, err); - } - - function _assertNotEq(bool[] memory a, bool[] memory b, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b); - } - - function _assertNotEq( - bool[] memory a, - bool[] memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertNotEq(a, b, err); - } - - function _assertNotEq(bytes memory a, bytes memory b, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b); - } - - function _assertNotEq( - bytes memory a, - bytes memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertNotEq(a, b, err); - } - - function _assertNotEq(bytes32 a, bytes32 b, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b); - } - - function _assertNotEq( - bytes32 a, - bytes32 b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertNotEq(a, b, err); - } - - function _assertNotEq(bytes32[] memory a, bytes32[] memory b, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b); - } - - function _assertNotEq( - bytes32[] memory a, - bytes32[] memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertNotEq(a, b, err); - } - - function _assertNotEq(int256 a, int256 b, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b); - } - - function _assertNotEq(int256 a, int256 b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b, err); - } - - function _assertNotEq(int256[] memory a, int256[] memory b, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b); - } - - function _assertNotEq( - int256[] memory a, - int256[] memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertNotEq(a, b, err); - } - - function _assertNotEq(string memory a, string memory b, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b); - } - - function _assertNotEq( - string memory a, - string memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertNotEq(a, b, err); - } - - function _assertNotEq(string[] memory a, string[] memory b, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b); - } - - function _assertNotEq( - string[] memory a, - string[] memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertNotEq(a, b, err); - } - - function _assertNotEq(uint256 a, uint256 b, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b); - } - - function _assertNotEq( - uint256 a, - uint256 b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertNotEq(a, b, err); - } - - function _assertNotEq(uint256[] memory a, uint256[] memory b, bool expectFail) external expectFailure(expectFail) { - assertNotEq(a, b); - } - - function _assertNotEq( - uint256[] memory a, - uint256[] memory b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertNotEq(a, b, err); - } - - /*////////////////////////////////////////////////////////////////////////// - APPROXIMATE ASSERTIONS - //////////////////////////////////////////////////////////////////////////*/ - - function _assertAlmostEq( - int256 a, - int256 b, - uint256 maxDelta, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertAlmostEq(a, b, maxDelta); - } - - function _assertAlmostEq( - int256 a, - int256 b, - uint256 maxDelta, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertAlmostEq(a, b, maxDelta, err); - } - - function _assertAlmostEq( - uint256 a, - uint256 b, - uint256 maxDelta, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertAlmostEq(a, b, maxDelta); - } - - function _assertAlmostEq( - uint256 a, - uint256 b, - uint256 maxDelta, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertAlmostEq(a, b, maxDelta, err); - } - - /*////////////////////////////////////////////////////////////////////////// - NUMERICAL COMPARISON ASSERTIONS - //////////////////////////////////////////////////////////////////////////*/ - - function _assertGt(int256 a, int256 b, bool expectFail) external expectFailure(expectFail) { - assertGt(a, b); - } - - function _assertGt(int256 a, int256 b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertGt(a, b, err); - } - - function _assertGt(uint256 a, uint256 b, bool expectFail) external expectFailure(expectFail) { - assertGt(a, b); - } - - function _assertGt(uint256 a, uint256 b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertGt(a, b, err); - } - - function _assertGte(int256 a, int256 b, bool expectFail) external expectFailure(expectFail) { - assertGte(a, b); - } - - function _assertGte(int256 a, int256 b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertGte(a, b, err); - } - - function _assertGte(uint256 a, uint256 b, bool expectFail) external expectFailure(expectFail) { - assertGte(a, b); - } - - function _assertGte(uint256 a, uint256 b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertGte(a, b, err); - } - - function _assertLt(int256 a, int256 b, bool expectFail) external expectFailure(expectFail) { - assertLt(a, b); - } - - function _assertLt(int256 a, int256 b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertLt(a, b, err); - } - - function _assertLt(uint256 a, uint256 b, bool expectFail) external expectFailure(expectFail) { - assertLt(a, b); - } - - function _assertLt(uint256 a, uint256 b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertLt(a, b, err); - } - - function _assertLte(int256 a, int256 b, bool expectFail) external expectFailure(expectFail) { - assertLte(a, b); - } - - function _assertLte(int256 a, int256 b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertLte(a, b, err); - } - - function _assertLte(uint256 a, uint256 b, bool expectFail) external expectFailure(expectFail) { - assertLte(a, b); - } - - function _assertLte(uint256 a, uint256 b, string memory err, bool expectFail) external expectFailure(expectFail) { - assertLte(a, b, err); - } - - /*////////////////////////////////////////////////////////////////////////// - CONTAINMENT ASSERTIONS - //////////////////////////////////////////////////////////////////////////*/ - - function _assertContains(address[] memory a, address b, bool expectFail) external expectFailure(expectFail) { - assertContains(a, b); - } - - function _assertContains( - address[] memory a, - address b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertContains(a, b, err); - } - - function _assertContains(bytes32[] memory a, bytes32 b, bool expectFail) external expectFailure(expectFail) { - assertContains(a, b); - } - - function _assertContains( - bytes32[] memory a, - bytes32 b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertContains(a, b, err); - } - - function _assertContains(int256[] memory a, int256 b, bool expectFail) external expectFailure(expectFail) { - assertContains(a, b); - } - - function _assertContains( - int256[] memory a, - int256 b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertContains(a, b, err); - } - - function _assertContains(uint256[] memory a, uint256 b, bool expectFail) external expectFailure(expectFail) { - assertContains(a, b); - } - - function _assertContains( - uint256[] memory a, - uint256 b, - string memory err, - bool expectFail - ) - external - expectFailure(expectFail) - { - assertContains(a, b, err); - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-almost-eq/assertAlmostEq.t.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-almost-eq/assertAlmostEq.t.sol deleted file mode 100644 index 1929d83d..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-almost-eq/assertAlmostEq.t.sol +++ /dev/null @@ -1,60 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import "../../src/Helpers.sol" as Helpers; - -import { PRBTest_Test } from "../PRBTest.t.sol"; - -contract AssertAlmostEq_Test is PRBTest_Test { - function test_AssertAlmostEq_Int256_Fail(int256 a, int256 b, uint256 maxDelta) external { - vm.assume(Helpers.delta(a, b) > maxDelta); - - vm.expectEmit(); - emit Log("Error: a ~= b not satisfied [int256]"); - prbTest._assertAlmostEq(a, b, maxDelta, EXPECT_FAIL); - } - - function test_AssertAlmostEq_Int256_Err_Fail(int256 a, int256 b, uint256 maxDelta) external { - vm.assume(Helpers.delta(a, b) > maxDelta); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertAlmostEq(a, b, maxDelta, ERR, EXPECT_FAIL); - } - - function test_AssertAlmostEq_Int256_Err_Pass(int256 a, int256 b, uint256 maxDelta) external { - vm.assume(Helpers.delta(a, b) <= maxDelta); - prbTest._assertAlmostEq(a, b, maxDelta, ERR, EXPECT_PASS); - } - - function test_AssertAlmostEq_Int256_Pass(int256 a, int256 b, uint256 maxDelta) external { - vm.assume(Helpers.delta(a, b) <= maxDelta); - prbTest._assertAlmostEq(a, b, maxDelta, EXPECT_PASS); - } - - function test_AssertAlmostEq_Uint256_Fail(uint256 a, uint256 b, uint256 maxDelta) external { - vm.assume(Helpers.delta(a, b) > maxDelta); - - vm.expectEmit(); - emit Log("Error: a ~= b not satisfied [uint256]"); - prbTest._assertAlmostEq(a, b, maxDelta, EXPECT_FAIL); - } - - function test_AssertAlmostEq_Uint256_Err_Fail(uint256 a, uint256 b, uint256 maxDelta) external { - vm.assume(Helpers.delta(a, b) > maxDelta); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertAlmostEq(a, b, maxDelta, ERR, EXPECT_FAIL); - } - - function test_AssertAlmostEq_Uint256_Err_Pass(uint256 a, uint256 b, uint256 maxDelta) external { - vm.assume(Helpers.delta(a, b) <= maxDelta); - prbTest._assertAlmostEq(a, b, maxDelta, ERR, EXPECT_PASS); - } - - function test_AssertAlmostEq_Uint256_Pass(uint256 a, uint256 b, uint256 maxDelta) external { - vm.assume(Helpers.delta(a, b) <= maxDelta); - prbTest._assertAlmostEq(a, b, maxDelta, EXPECT_PASS); - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-contains/assertContains.t.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-contains/assertContains.t.sol deleted file mode 100644 index 26af3a78..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-contains/assertContains.t.sol +++ /dev/null @@ -1,182 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import { PRBTest_Test } from "../PRBTest.t.sol"; - -contract AssertContains_Test is PRBTest_Test { - function test_AssertContains_Address_Fail(address e0, address e1) external { - vm.assume(e0 != e1); - - address[] memory a = new address[](1); - a[0] = e0; - address b = e1; - - vm.expectEmit(); - emit Log("Error: a does not contain b [address[]]"); - prbTest._assertContains(a, b, EXPECT_FAIL); - } - - function test_AssertContains_Address_Err_Fail(address e0, address e1) external { - vm.assume(e0 != e1); - - address[] memory a = new address[](1); - a[0] = e0; - address b = e1; - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertContains(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertContains_Address_Err_Pass(address e0, address e1) external { - vm.assume(e0 != address(0)); - - address[] memory a = new address[](2); - a[0] = e0; - a[1] = e1; - address b = e1; - prbTest._assertContains(a, b, ERR, EXPECT_PASS); - } - - function test_AssertContains_Address_Pass(address e0, address e1) external { - vm.assume(e0 != address(0)); - - address[] memory a = new address[](2); - a[0] = e0; - a[1] = e1; - address b = e1; - prbTest._assertContains(a, b, EXPECT_PASS); - } - - function test_AssertContains_Bytes32_Fail(bytes32 e0, bytes32 e1) external { - vm.assume(e0 != e1); - - bytes32[] memory a = new bytes32[](1); - a[0] = e0; - bytes32 b = e1; - - vm.expectEmit(); - emit Log("Error: a does not contain b [bytes32[]]"); - prbTest._assertContains(a, b, EXPECT_FAIL); - } - - function test_AssertContains_Bytes32_Err_Fail(bytes32 e0, bytes32 e1) external { - vm.assume(e0 != e1); - - bytes32[] memory a = new bytes32[](1); - a[0] = e0; - bytes32 b = e1; - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertContains(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertContains_Bytes32_Err_Pass(bytes32 e0, bytes32 e1) external { - vm.assume(e0 != bytes32(uint256(0x00))); - - bytes32[] memory a = new bytes32[](2); - a[0] = e0; - a[1] = e1; - bytes32 b = e1; - prbTest._assertContains(a, b, ERR, EXPECT_PASS); - } - - function test_AssertContains_Bytes32_Pass(bytes32 e0, bytes32 e1) external { - vm.assume(e0 != bytes32(uint256(0x00))); - - bytes32[] memory a = new bytes32[](2); - a[0] = e0; - a[1] = e1; - bytes32 b = e1; - prbTest._assertContains(a, b, EXPECT_PASS); - } - - function test_AssertContains_Int256_Fail(int256 e0, int256 e1) external { - vm.assume(e0 != e1); - - int256[] memory a = new int256[](1); - a[0] = e0; - int256 b = e1; - - vm.expectEmit(); - emit Log("Error: a does not contain b [int256[]]"); - prbTest._assertContains(a, b, EXPECT_FAIL); - } - - function test_AssertContains_Int256_Err_Fail(int256 e0, int256 e1) external { - vm.assume(e0 != e1); - - int256[] memory a = new int256[](1); - a[0] = e0; - int256 b = e1; - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertContains(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertContains_Int256_Err_Pass(int256 e0, int256 e1) external { - vm.assume(e0 != 0); - - int256[] memory a = new int256[](2); - a[0] = e0; - a[1] = e1; - int256 b = e1; - prbTest._assertContains(a, b, ERR, EXPECT_PASS); - } - - function test_AssertContains_Int256_Pass(int256 e0, int256 e1) external { - vm.assume(e0 != 0); - - int256[] memory a = new int256[](2); - a[0] = e0; - a[1] = e1; - int256 b = e1; - prbTest._assertContains(a, b, EXPECT_PASS); - } - - function test_AssertContains_Uint256_Fail(uint256 e0, uint256 e1) external { - vm.assume(e0 != e1); - - uint256[] memory a = new uint256[](1); - a[0] = e0; - uint256 b = e1; - - vm.expectEmit(); - emit Log("Error: a does not contain b [uint256[]]"); - prbTest._assertContains(a, b, EXPECT_FAIL); - } - - function test_AssertContains_Uint256_Err_Fail(uint256 e0, uint256 e1) external { - vm.assume(e0 != e1); - - uint256[] memory a = new uint256[](1); - a[0] = e0; - uint256 b = e1; - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertContains(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertContains_Uint256_Err_Pass(uint256 e0, uint256 e1) external { - vm.assume(e0 != 0); - - uint256[] memory a = new uint256[](2); - a[0] = e0; - a[1] = e1; - uint256 b = e1; - prbTest._assertContains(a, b, ERR, EXPECT_PASS); - } - - function test_AssertContains_Uint256_Pass(uint256 e0, uint256 e1) external { - vm.assume(e0 != 0); - - uint256[] memory a = new uint256[](2); - a[0] = e0; - a[1] = e1; - uint256 b = e1; - prbTest._assertContains(a, b, EXPECT_PASS); - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-eq/assertEq.t.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-eq/assertEq.t.sol deleted file mode 100644 index 1e0431e9..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-eq/assertEq.t.sol +++ /dev/null @@ -1,663 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import "../../src/Helpers.sol" as Helpers; - -import { PRBTest_Test } from "../PRBTest.t.sol"; - -contract AssertEq_Test is PRBTest_Test { - /*////////////////////////////////////////////////////////////////////////// - BASIC TYPES - //////////////////////////////////////////////////////////////////////////*/ - - function test_AssertEq_Address_Fail(address a, address b) external { - vm.assume(a != b); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [address]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_Address_Err_Fail(address a, address b) external { - vm.assume(a != b); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_Address_Err_Pass(address a) external { - prbTest._assertEq(a, a, ERR, EXPECT_PASS); - } - - function test_AssertEq_Address_Pass(address a) external { - prbTest._assertEq(a, a, EXPECT_PASS); - } - - function test_AssertEq_Bool_Fail() external { - vm.expectEmit(); - emit Log("Error: a == b not satisfied [bool]"); - prbTest._assertEq({ a: false, b: true, expectFail: EXPECT_FAIL }); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [bool]"); - prbTest._assertEq({ a: true, b: false, expectFail: EXPECT_FAIL }); - } - - function test_AssertEq_Bool_Err_Fail() external { - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq({ a: false, b: true, err: ERR, expectFail: EXPECT_FAIL }); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq({ a: true, b: false, err: ERR, expectFail: EXPECT_FAIL }); - } - - function test_AssertEq_Bool_Err_Pass() external { - prbTest._assertEq({ a: false, b: false, err: ERR, expectFail: EXPECT_PASS }); - prbTest._assertEq({ a: true, b: true, err: ERR, expectFail: EXPECT_PASS }); - } - - function test_AssertEq_Bool_Pass() external { - prbTest._assertEq({ a: false, b: false, expectFail: EXPECT_PASS }); - prbTest._assertEq({ a: true, b: true, expectFail: EXPECT_PASS }); - } - - function test_AssertEq_Bytes_Fail(bytes memory a, bytes memory b) external { - vm.assume(!Helpers.eq(a, b)); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [bytes]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_Bytes_Err_Fail(bytes memory a, bytes memory b) external { - vm.assume(!Helpers.eq(a, b)); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_Bytes_Err_Pass(bytes memory a) external { - prbTest._assertEq(a, a, ERR, EXPECT_PASS); - } - - function test_AssertEq_Bytes_Pass(bytes memory a) external { - prbTest._assertEq(a, a, EXPECT_PASS); - } - - function test_AssertEq_Bytes32_Fail(bytes32 a, bytes32 b) external { - vm.assume(a != b); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [bytes32]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_Bytes32_Err_Fail(bytes32 a, bytes32 b) external { - vm.assume(a != b); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_Bytes32_Err_Pass(bytes32 a) external { - prbTest._assertEq(a, a, ERR, EXPECT_PASS); - } - - function test_AssertEq_Bytes32_Pass(bytes32 a) external { - prbTest._assertEq(a, a, EXPECT_PASS); - } - - function test_AssertEq_Int256_Fail(int256 a, int256 b) external { - vm.assume(a != b); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [int256]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_Int256_Err_Fail(int256 a, int256 b) external { - vm.assume(a != b); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_Int256_Err_Pass(int256 a) external { - prbTest._assertEq(a, a, ERR, EXPECT_PASS); - } - - function test_AssertEq_Int256_Pass(int256 a) external { - prbTest._assertEq(a, a, EXPECT_PASS); - } - - function test_AssertEq_String_Fail(string memory a, string memory b) external { - vm.assume(!Helpers.eq(a, b)); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [string]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_String_Err_Fail(string memory a, string memory b) external { - vm.assume(!Helpers.eq(a, b)); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_String_Err_Pass(string memory a) external { - prbTest._assertEq(a, a, ERR, EXPECT_PASS); - } - - function test_AssertEq_String_Pass(string memory a) external { - prbTest._assertEq(a, a, EXPECT_PASS); - } - - function test_AssertEq_Uint256_Fail(uint256 a, uint256 b) external { - vm.assume(a != b); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [uint256]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_Uint256_Err_Fail(uint256 a, uint256 b) external { - vm.assume(a != b); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_Uint256_Err_Pass(uint256 a) external { - prbTest._assertEq(a, a, ERR, EXPECT_PASS); - } - - function test_AssertEq_Uint256_Pass(uint256 a) external { - prbTest._assertEq(a, a, EXPECT_PASS); - } - - /*////////////////////////////////////////////////////////////////////////// - ARRAYS - //////////////////////////////////////////////////////////////////////////*/ - - function test_AssertEq_AddressArray_FailElements(address e1) external { - vm.assume(e1 != address(0)); - - address[] memory a = new address[](3); - address[] memory b = new address[](3); - b[1] = e1; - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [address[]]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_AddressArray_FailLengths(uint256 lenA, uint256 lenB) external { - vm.assume(lenA != lenB); - vm.assume(lenA <= 10_000); - vm.assume(lenB <= 10_000); - - address[] memory a = new address[](lenA); - address[] memory b = new address[](lenB); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [address[]]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_AddressArray_Err_FailElements(address e1) external { - vm.assume(e1 != address(0)); - - address[] memory a = new address[](3); - address[] memory b = new address[](3); - b[1] = e1; - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_AddressArray_Err_FailLengths(uint256 lenA, uint256 lenB) external { - vm.assume(lenA != lenB); - vm.assume(lenA <= 10_000); - vm.assume(lenB <= 10_000); - - address[] memory a = new address[](lenA); - address[] memory b = new address[](lenB); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_AddressArray_Err_Pass(address e0, address e1, address e2) external { - address[] memory a = new address[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - address[] memory b = new address[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - prbTest._assertEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertEq_AddressArray_Pass(address e0, address e1, address e2) external { - address[] memory a = new address[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - address[] memory b = new address[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - prbTest._assertEq(a, b, EXPECT_PASS); - } - - function test_AssertEq_BoolArray_FailElements() external { - bool[] memory a = new bool[](1); - bool[] memory b = new bool[](1); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [bool[]]"); - a[0] = false; - b[0] = true; - prbTest._assertEq(a, b, EXPECT_FAIL); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [bool[]]"); - a[0] = true; - b[0] = false; - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_BoolArray_FailLengths(uint256 lenA, uint256 lenB) external { - vm.assume(lenA != lenB); - vm.assume(lenA <= 10_000); - vm.assume(lenB <= 10_000); - - bool[] memory a = new bool[](lenA); - bool[] memory b = new bool[](lenB); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [bool[]]"); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_BoolArray_Err_FailElements() external { - bool[] memory a = new bool[](1); - bool[] memory b = new bool[](1); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - a[0] = false; - b[0] = true; - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - a[0] = true; - b[0] = false; - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_BoolArray_Err_FailLengths(uint256 lenA, uint256 lenB) external { - vm.assume(lenA != lenB); - vm.assume(lenA <= 10_000); - vm.assume(lenB <= 10_000); - - bool[] memory a = new bool[](lenA); - bool[] memory b = new bool[](lenB); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_BoolArray_Pass() external { - bool[] memory a = new bool[](1); - bool[] memory b = new bool[](1); - - a[0] = false; - b[0] = false; - prbTest._assertEq(a, b, EXPECT_PASS); - - a[0] = true; - b[0] = true; - prbTest._assertEq(a, b, EXPECT_PASS); - } - - function test_AssertEq_BoolArray_Err_Pass() external { - bool[] memory a = new bool[](1); - bool[] memory b = new bool[](1); - - a[0] = false; - b[0] = false; - prbTest._assertEq(a, b, ERR, EXPECT_PASS); - - a[0] = true; - b[0] = true; - prbTest._assertEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertEq_Bytes32Array_FailElements(bytes32 e1) external { - vm.assume(e1 != bytes32(uint256(0x00))); - - bytes32[] memory a = new bytes32[](3); - bytes32[] memory b = new bytes32[](3); - b[1] = e1; - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [bytes32[]]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_Bytes32Array_FailLengths(uint256 lenA, uint256 lenB) external { - vm.assume(lenA != lenB); - vm.assume(lenA <= 10_000); - vm.assume(lenB <= 10_000); - - bytes32[] memory a = new bytes32[](lenA); - bytes32[] memory b = new bytes32[](lenB); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [bytes32[]]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_Bytes32Array_Err_FailElements(bytes32 e1) external { - vm.assume(e1 != bytes32(uint256(0x00))); - - bytes32[] memory a = new bytes32[](3); - bytes32[] memory b = new bytes32[](3); - b[1] = e1; - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_Bytes32Array_Err_FailLengths(uint256 lenA, uint256 lenB) external { - vm.assume(lenA != lenB); - vm.assume(lenA <= 10_000); - vm.assume(lenB <= 10_000); - - bytes32[] memory a = new bytes32[](lenA); - bytes32[] memory b = new bytes32[](lenB); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_Bytes32Array_Err_Pass(bytes32 e0, bytes32 e1, bytes32 e2) external { - bytes32[] memory a = new bytes32[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - bytes32[] memory b = new bytes32[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - prbTest._assertEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertEq_Bytes32Array_Pass(bytes32 e0, bytes32 e1, bytes32 e2) external { - bytes32[] memory a = new bytes32[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - bytes32[] memory b = new bytes32[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - prbTest._assertEq(a, b, EXPECT_PASS); - } - - function test_AssertEq_Int256Array_FailElements(int256 e1) external { - vm.assume(e1 != 0); - - int256[] memory a = new int256[](3); - int256[] memory b = new int256[](3); - b[1] = e1; - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [int256[]]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_Int256Array_FailLengths(uint256 lenA, uint256 lenB) external { - vm.assume(lenA != lenB); - vm.assume(lenA <= 10_000); - vm.assume(lenB <= 10_000); - - int256[] memory a = new int256[](lenA); - int256[] memory b = new int256[](lenB); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [int256[]]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_Int256Array_Err_FailElements(int256 e1) external { - vm.assume(e1 != 0); - - int256[] memory a = new int256[](3); - int256[] memory b = new int256[](3); - b[1] = e1; - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_Int256Array_Err_FailLengths(uint256 lenA, uint256 lenB) external { - vm.assume(lenA != lenB); - vm.assume(lenA <= 10_000); - vm.assume(lenB <= 10_000); - - int256[] memory a = new int256[](lenA); - int256[] memory b = new int256[](lenB); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_Int256Array_Err_Pass(int256 e0, int256 e1, int256 e2) external { - int256[] memory a = new int256[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - int256[] memory b = new int256[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - prbTest._assertEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertEq_Int256Array_Pass(int256 e0, int256 e1, int256 e2) external { - int256[] memory a = new int256[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - int256[] memory b = new int256[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - prbTest._assertEq(a, b, EXPECT_PASS); - } - - function test_AssertEq_StringArray_FailElements(string memory e1) external { - vm.assume(!Helpers.eq(e1, "")); - - string[] memory a = new string[](3); - string[] memory b = new string[](3); - b[1] = e1; - vm.expectEmit(); - emit Log("Error: a == b not satisfied [string[]]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_StringArray_FailLengths(uint256 lenA, uint256 lenB) external { - vm.assume(lenA != lenB); - vm.assume(lenA <= 10_000); - vm.assume(lenB <= 10_000); - - string[] memory a = new string[](lenA); - string[] memory b = new string[](lenB); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [string[]]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_StringArray_Err_FailElements(string memory e1) external { - vm.assume(!Helpers.eq(e1, "")); - - string[] memory a = new string[](3); - string[] memory b = new string[](3); - b[1] = e1; - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_StringArray_Err_FailLengths(uint256 lenA, uint256 lenB) external { - vm.assume(lenA != lenB); - vm.assume(lenA <= 10_000); - vm.assume(lenB <= 10_000); - - string[] memory a = new string[](lenA); - string[] memory b = new string[](lenB); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_StringArray_Err_Pass(string memory e0, string memory e1, string memory e2) external { - string[] memory a = new string[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - string[] memory b = new string[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - prbTest._assertEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertEq_StringArray_Pass(string memory e0, string memory e1, string memory e2) external { - string[] memory a = new string[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - string[] memory b = new string[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - prbTest._assertEq(a, b, EXPECT_PASS); - } - - function test_AssertEq_Uint256Array_FailElements(uint256 e1) external { - vm.assume(e1 != 0); - - uint256[] memory a = new uint256[](3); - uint256[] memory b = new uint256[](3); - b[1] = e1; - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [uint256[]]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_Uint256Array_FailLengths(uint256 lenA, uint256 lenB) external { - vm.assume(lenA != lenB); - vm.assume(lenA <= 10_000); - vm.assume(lenB <= 10_000); - - uint256[] memory a = new uint256[](lenA); - uint256[] memory b = new uint256[](lenB); - - vm.expectEmit(); - emit Log("Error: a == b not satisfied [uint256[]]"); - prbTest._assertEq(a, b, EXPECT_FAIL); - } - - function test_AssertEq_Uint256Array_Err_FailElements(uint256 e1) external { - vm.assume(e1 != 0); - - uint256[] memory a = new uint256[](3); - uint256[] memory b = new uint256[](3); - b[1] = e1; - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_Uint256Array_Err_FailElements(uint256 lenA, uint256 lenB) external { - vm.assume(lenA != lenB); - vm.assume(lenA <= 10_000); - vm.assume(lenB <= 10_000); - - uint256[] memory a = new uint256[](lenA); - uint256[] memory b = new uint256[](lenB); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertEq_Uint256Array_Err_Pass(uint256 e0, uint256 e1, uint256 e2) external { - uint256[] memory a = new uint256[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - uint256[] memory b = new uint256[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - prbTest._assertEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertEq_Uint256Array_Pass(uint256 e0, uint256 e1, uint256 e2) external { - uint256[] memory a = new uint256[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - uint256[] memory b = new uint256[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - prbTest._assertEq(a, b, EXPECT_PASS); - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-false/assertFalse.t.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-false/assertFalse.t.sol deleted file mode 100644 index d14d4925..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-false/assertFalse.t.sol +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import { PRBTest_Test } from "../PRBTest.t.sol"; - -contract AssertFalse_Test is PRBTest_Test { - function test_AssertFalse_Pass() external { - prbTest._assertFalse({ condition: false, expectFail: EXPECT_PASS }); - } - - function test_AssertFalse_Fail() external { - vm.expectEmit(); - emit Log("Error: Assertion Failed"); - prbTest._assertFalse({ condition: true, expectFail: EXPECT_FAIL }); - } - - function test_AssertFalse_Err_Pass() external { - prbTest._assertFalse({ condition: false, err: ERR, expectFail: EXPECT_PASS }); - } - - function test_AssertFalse_Err_Fail() external { - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertFalse({ condition: true, err: ERR, expectFail: EXPECT_FAIL }); - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-gt/assertGt.t.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-gt/assertGt.t.sol deleted file mode 100644 index 8adedde1..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-gt/assertGt.t.sol +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import { PRBTest_Test } from "../PRBTest.t.sol"; - -contract AssertGt_Test is PRBTest_Test { - function test_AssertGt_Fail(int256 a, int256 b) external { - vm.assume(a <= b); - - vm.expectEmit(); - emit Log("Error: a > b not satisfied [int256]"); - prbTest._assertGt(a, b, EXPECT_FAIL); - } - - function test_AssertGt_Err_Fail(int256 a, int256 b) external { - vm.assume(a <= b); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertGt(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertGt_Err_Pass(int256 a, int256 b) external { - vm.assume(a > b); - - prbTest._assertGt(a, b, ERR, EXPECT_PASS); - } - - function test_AssertGt_Pass(int256 a, int256 b) external { - vm.assume(a > b); - - prbTest._assertGt(a, b, EXPECT_PASS); - } - - function test_AssertGt_Fail(uint256 a, uint256 b) external { - vm.assume(a <= b); - - vm.expectEmit(); - emit Log("Error: a > b not satisfied [uint256]"); - prbTest._assertGt(a, b, EXPECT_FAIL); - } - - function test_AssertGt_Err_Fail(uint256 a, uint256 b) external { - vm.assume(a <= b); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertGt(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertGt_Err_Pass(uint256 a, uint256 b) external { - vm.assume(a > b); - - prbTest._assertGt(a, b, ERR, EXPECT_PASS); - } - - function test_AssertGt_Pass(uint256 a, uint256 b) external { - vm.assume(a > b); - - prbTest._assertGt(a, b, EXPECT_PASS); - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-gte/assertGte.t.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-gte/assertGte.t.sol deleted file mode 100644 index 3b1d47b0..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-gte/assertGte.t.sol +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import { PRBTest_Test } from "../PRBTest.t.sol"; - -contract AssertGte_Test is PRBTest_Test { - function test_AssertGte_Fail(int256 a, int256 b) external { - vm.assume(a < b); - - vm.expectEmit(); - emit Log("Error: a >= b not satisfied [int256]"); - prbTest._assertGte(a, b, EXPECT_FAIL); - } - - function test_AssertGte_Err_Fail(int256 a, int256 b) external { - vm.assume(a < b); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertGte(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertGte_Err_Pass(int256 a, int256 b) external { - vm.assume(a >= b); - - prbTest._assertGte(a, b, ERR, EXPECT_PASS); - } - - function test_AssertGte_Pass(int256 a, int256 b) external { - vm.assume(a >= b); - - prbTest._assertGte(a, b, EXPECT_PASS); - } - - function test_AssertGte_Fail(uint256 a, uint256 b) external { - vm.assume(a < b); - - vm.expectEmit(); - emit Log("Error: a >= b not satisfied [uint256]"); - prbTest._assertGte(a, b, EXPECT_FAIL); - } - - function test_AssertGte_Err_Fail(uint256 a, uint256 b) external { - vm.assume(a < b); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertGte(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertGte_Err_Pass(uint256 a, uint256 b) external { - vm.assume(a >= b); - - prbTest._assertGte(a, b, ERR, EXPECT_PASS); - } - - function test_AssertGte_Pass(uint256 a, uint256 b) external { - vm.assume(a >= b); - - prbTest._assertGte(a, b, EXPECT_PASS); - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-lt/assertLt.t.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-lt/assertLt.t.sol deleted file mode 100644 index e5a07cd8..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-lt/assertLt.t.sol +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import { PRBTest_Test } from "../PRBTest.t.sol"; - -contract AssertLt_Test is PRBTest_Test { - function test_AssertLt_Fail(int256 a, int256 b) external { - vm.assume(a >= b); - - vm.expectEmit(); - emit Log("Error: a < b not satisfied [int256]"); - prbTest._assertLt(a, b, EXPECT_FAIL); - } - - function test_AssertLt_Err_Fail(int256 a, int256 b) external { - vm.assume(a >= b); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertLt(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertLt_Err_Pass(int256 a, int256 b) external { - vm.assume(a < b); - - prbTest._assertLt(a, b, ERR, EXPECT_PASS); - } - - function test_AssertLt_Pass(int256 a, int256 b) external { - vm.assume(a < b); - - prbTest._assertLt(a, b, EXPECT_PASS); - } - - function test_AssertLt_Fail(uint256 a, uint256 b) external { - vm.assume(a >= b); - - vm.expectEmit(); - emit Log("Error: a < b not satisfied [uint256]"); - prbTest._assertLt(a, b, EXPECT_FAIL); - } - - function test_AssertLt_Err_Fail(uint256 a, uint256 b) external { - vm.assume(a >= b); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertLt(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertLt_Err_Pass(uint256 a, uint256 b) external { - vm.assume(a < b); - - prbTest._assertLt(a, b, ERR, EXPECT_PASS); - } - - function test_AssertLt_Pass(uint256 a, uint256 b) external { - vm.assume(a < b); - - prbTest._assertLt(a, b, EXPECT_PASS); - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-lte/assertLte.t.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-lte/assertLte.t.sol deleted file mode 100644 index a53e93ef..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-lte/assertLte.t.sol +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import { PRBTest_Test } from "../PRBTest.t.sol"; - -contract AssertLte_Test is PRBTest_Test { - function test_AssertLte_Fail(int256 a, int256 b) external { - vm.assume(a > b); - - vm.expectEmit(); - emit Log("Error: a <= b not satisfied [int256]"); - prbTest._assertLte(a, b, EXPECT_FAIL); - } - - function test_AssertLte_Err_Fail(int256 a, int256 b) external { - vm.assume(a > b); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertLte(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertLte_Err_Pass(int256 a, int256 b) external { - vm.assume(a <= b); - - prbTest._assertLte(a, b, ERR, EXPECT_PASS); - } - - function test_AssertLte_Pass(int256 a, int256 b) external { - vm.assume(a <= b); - - prbTest._assertLte(a, b, EXPECT_PASS); - } - - function test_AssertLte_Fail(uint256 a, uint256 b) external { - vm.assume(a > b); - - vm.expectEmit(); - emit Log("Error: a <= b not satisfied [uint256]"); - prbTest._assertLte(a, b, EXPECT_FAIL); - } - - function test_AssertLte_Err_Fail(uint256 a, uint256 b) external { - vm.assume(a > b); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertLte(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertLte_Err_Pass(uint256 a, uint256 b) external { - vm.assume(a <= b); - - prbTest._assertLte(a, b, ERR, EXPECT_PASS); - } - - function test_AssertLte_Pass(uint256 a, uint256 b) external { - vm.assume(a <= b); - - prbTest._assertLte(a, b, EXPECT_PASS); - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-not-eq/assertNotEq.t.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-not-eq/assertNotEq.t.sol deleted file mode 100644 index d907a855..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-not-eq/assertNotEq.t.sol +++ /dev/null @@ -1,606 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import "../../src/Helpers.sol" as Helpers; - -import { PRBTest_Test } from "../PRBTest.t.sol"; - -contract AssertNotEq_Test is PRBTest_Test { - /*////////////////////////////////////////////////////////////////////////// - BASIC TYPES - //////////////////////////////////////////////////////////////////////////*/ - - function test_AssertNotEq_Address_Fail(address a) external { - vm.expectEmit(); - emit Log("Error: a != b not satisfied [address]"); - prbTest._assertNotEq(a, a, EXPECT_FAIL); - } - - function test_AssertNotEq_Address_Err_Fail(address a) external { - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, a, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_Address_Err_Pass(address a, address b) external { - vm.assume(a != b); - prbTest._assertNotEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertNotEq_Address_Pass(address a, address b) external { - vm.assume(a != b); - prbTest._assertNotEq(a, b, EXPECT_PASS); - } - - function test_AssertNotEq_Bool_Fail() external { - vm.expectEmit(); - emit Log("Error: a != b not satisfied [bool]"); - prbTest._assertNotEq({ a: false, b: false, expectFail: EXPECT_FAIL }); - - vm.expectEmit(); - emit Log("Error: a != b not satisfied [bool]"); - prbTest._assertNotEq({ a: true, b: true, expectFail: EXPECT_FAIL }); - } - - function test_AssertNotEq_Bool_Err_Pass() external { - prbTest._assertNotEq({ a: false, b: true, err: ERR, expectFail: EXPECT_PASS }); - prbTest._assertNotEq({ a: true, b: false, err: ERR, expectFail: EXPECT_PASS }); - } - - function test_AssertNotEq_Bool_Err_Fail() external { - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq({ a: false, b: false, err: ERR, expectFail: EXPECT_FAIL }); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq({ a: true, b: true, err: ERR, expectFail: EXPECT_FAIL }); - } - - function test_AssertNotEq_Bool_Pass() external { - prbTest._assertNotEq({ a: false, b: true, expectFail: EXPECT_PASS }); - prbTest._assertNotEq({ a: true, b: false, expectFail: EXPECT_PASS }); - } - - function test_AssertNotEq_BoolArray_Pass() external { - bool[] memory a = new bool[](1); - bool[] memory b = new bool[](1); - - a[0] = false; - b[0] = true; - prbTest._assertNotEq(a, b, EXPECT_PASS); - - a[0] = true; - b[0] = false; - prbTest._assertNotEq(a, b, EXPECT_PASS); - } - - function test_AssertNotEq_BoolArray_Err_Pass() external { - bool[] memory a = new bool[](1); - bool[] memory b = new bool[](1); - - a[0] = false; - b[0] = true; - prbTest._assertNotEq(a, b, ERR, EXPECT_PASS); - - a[0] = true; - b[0] = false; - prbTest._assertNotEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertNotEq_BoolArray_Fail() external { - bool[] memory a = new bool[](1); - bool[] memory b = new bool[](1); - - a[0] = false; - b[0] = false; - vm.expectEmit(); - emit Log("Error: a != b not satisfied [bool[]]"); - prbTest._assertNotEq(a, b, EXPECT_FAIL); - - a[0] = true; - b[0] = true; - prbTest._assertNotEq(a, b, EXPECT_FAIL); - } - - function test_AssertNotEq_BoolArray_Err_Fail() external { - bool[] memory a = new bool[](1); - bool[] memory b = new bool[](1); - - a[0] = false; - b[0] = false; - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, b, ERR, EXPECT_FAIL); - - a[0] = true; - b[0] = true; - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_Bytes_Fail(uint256 e0, uint256 e1) external { - vm.assume(e0 == e1); - bytes memory a = abi.encode(e0); - bytes memory b = abi.encode(e1); - - vm.expectEmit(); - emit Log("Error: a != b not satisfied [bytes]"); - prbTest._assertNotEq(a, b, EXPECT_FAIL); - } - - function test_AssertNotEq_Bytes_Err_Fail(uint256 e0, uint256 e1) external { - vm.assume(e0 == e1); - bytes memory a = abi.encode(e0); - bytes memory b = abi.encode(e1); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_Bytes_Err_Pass(uint256 e1) external { - vm.assume(e1 != 0); - bytes memory a = new bytes(32); - bytes memory b = abi.encode(e1); - prbTest._assertNotEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertNotEq_Bytes_Pass(uint256 e1) external { - vm.assume(e1 != 0); - bytes memory a = new bytes(32); - bytes memory b = abi.encode(e1); - prbTest._assertNotEq(a, b, EXPECT_PASS); - } - - function test_AssertNotEq_Bytes32_Fail(bytes32 a) external { - vm.expectEmit(); - emit Log("Error: a != b not satisfied [bytes32]"); - prbTest._assertNotEq(a, a, EXPECT_FAIL); - } - - function test_AssertNotEq_Bytes32_Err_Fail(bytes32 a) external { - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, a, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_Bytes32_Err_Pass(bytes32 a, bytes32 b) external { - vm.assume(a != b); - - prbTest._assertNotEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertNotEq_Bytes32_Pass(bytes32 a, bytes32 b) external { - vm.assume(a != b); - - prbTest._assertNotEq(a, b, EXPECT_PASS); - } - - function test_AssertNotEq_Int256_Fail(int256 a) external { - vm.expectEmit(); - emit Log("Error: a != b not satisfied [int256]"); - prbTest._assertNotEq(a, a, EXPECT_FAIL); - } - - function test_AssertNotEq_Int256_Err_Fail(int256 a) external { - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, a, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_Int256_Err_Pass(int256 a, int256 b) external { - vm.assume(a != b); - prbTest._assertNotEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertNotEq_Int256_Pass(int256 a, int256 b) external { - vm.assume(a != b); - prbTest._assertNotEq(a, b, EXPECT_PASS); - } - - function test_AssertNotEq_String_Fail(string memory a) external { - vm.expectEmit(); - emit Log("Error: a != b not satisfied [string]"); - prbTest._assertNotEq(a, a, EXPECT_FAIL); - } - - function test_AssertNotEq_String_Err_Fail(string memory a) external { - prbTest._assertNotEq(a, a, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_String_Err_Pass(string memory a, string memory b) external { - vm.assume(!Helpers.eq(a, b)); - prbTest._assertNotEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertNotEq_String_Pass(string memory a, string memory b) external { - vm.assume(!Helpers.eq(a, b)); - prbTest._assertNotEq(a, b, EXPECT_PASS); - } - - function test_AssertNotEq_Uint256_Fail(uint256 a) external { - vm.expectEmit(); - emit Log("Error: a != b not satisfied [uint256]"); - prbTest._assertNotEq(a, a, EXPECT_FAIL); - } - - function test_AssertNotEq_Uint256_Err_Fail(uint256 a) external { - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, a, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_Uint256_Err_Pass(uint256 a, uint256 b) external { - vm.assume(a != b); - prbTest._assertNotEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertNotEq_Uint256_Pass(uint256 a, uint256 b) external { - vm.assume(a != b); - prbTest._assertNotEq(a, b, EXPECT_PASS); - } - - /*////////////////////////////////////////////////////////////////////////// - ARRAYS - //////////////////////////////////////////////////////////////////////////*/ - - function test_AssertNotEq_AddressArray_FailElements(address e0, address e1, address e2) external { - address[] memory a = new address[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - address[] memory b = new address[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - vm.expectEmit(); - emit Log("Error: a != b not satisfied [address[]]"); - prbTest._assertNotEq(a, b, EXPECT_FAIL); - } - - function test_AssertNotEq_AddressArray_FailLengths(uint256 len) external { - vm.assume(len <= 10_000); - - address[] memory a = new address[](len); - address[] memory b = new address[](len); - - vm.expectEmit(); - emit Log("Error: a != b not satisfied [address[]]"); - prbTest._assertNotEq(a, b, EXPECT_FAIL); - } - - function test_AssertNotEq_AddressArray_Err_FailElements(address e0, address e1, address e2) external { - address[] memory a = new address[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - address[] memory b = new address[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_AddressArray_Err_FailElements(uint256 len) external { - vm.assume(len <= 10_000); - - address[] memory a = new address[](len); - address[] memory b = new address[](len); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_AddressArray_Err_Pass(address e1) external { - vm.assume(e1 != address(0)); - address[] memory a = new address[](3); - address[] memory b = new address[](3); - b[1] = e1; - prbTest._assertNotEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertNotEq_AddressArray_Pass(address e1) external { - vm.assume(e1 != address(0)); - address[] memory a = new address[](3); - address[] memory b = new address[](3); - b[1] = e1; - prbTest._assertNotEq(a, b, EXPECT_PASS); - } - - function test_AssertNotEq_Bytes32Array_FailElements(bytes32 e0, bytes32 e1, bytes32 e2) external { - bytes32[] memory a = new bytes32[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - bytes32[] memory b = new bytes32[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - vm.expectEmit(); - emit Log("Error: a != b not satisfied [bytes32[]]"); - prbTest._assertNotEq(a, b, EXPECT_FAIL); - } - - function test_AssertNotEq_Bytes32Array_FailElements(uint256 len) external { - vm.assume(len <= 10_000); - - bytes32[] memory a = new bytes32[](len); - bytes32[] memory b = new bytes32[](len); - - vm.expectEmit(); - emit Log("Error: a != b not satisfied [bytes32[]]"); - prbTest._assertNotEq(a, b, EXPECT_FAIL); - } - - function test_AssertNotEq_Bytes32Array_Err_FailElements(bytes32 e0, bytes32 e1, bytes32 e2) external { - bytes32[] memory a = new bytes32[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - bytes32[] memory b = new bytes32[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_Bytes32Array_Err_FailLengths(uint256 len) external { - vm.assume(len <= 10_000); - - bytes32[] memory a = new bytes32[](len); - bytes32[] memory b = new bytes32[](len); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_Bytes32Array_Err_Pass(bytes32 e1) external { - vm.assume(e1 != bytes32(uint256(0x00))); - - bytes32[] memory a = new bytes32[](3); - bytes32[] memory b = new bytes32[](3); - b[1] = e1; - prbTest._assertNotEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertNotEq_Bytes32Array_Pass(bytes32 e1) external { - vm.assume(e1 != 0); - - bytes32[] memory a = new bytes32[](3); - bytes32[] memory b = new bytes32[](3); - b[1] = e1; - prbTest._assertNotEq(a, b, EXPECT_PASS); - } - - function test_AssertNotEq_Int256Array_FailElements(int256 e0, int256 e1, int256 e2) external { - int256[] memory a = new int256[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - int256[] memory b = new int256[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - vm.expectEmit(); - emit Log("Error: a != b not satisfied [int256[]]"); - prbTest._assertNotEq(a, b, EXPECT_FAIL); - } - - function test_AssertNotEq_Int256Array_FailLengths(uint256 len) external { - vm.assume(len <= 10_000); - - int256[] memory a = new int256[](len); - int256[] memory b = new int256[](len); - - vm.expectEmit(); - emit Log("Error: a != b not satisfied [int256[]]"); - prbTest._assertNotEq(a, b, EXPECT_FAIL); - } - - function test_AssertNotEq_Int256Array_Err_FailElements(int256 e0, int256 e1, int256 e2) external { - int256[] memory a = new int256[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - int256[] memory b = new int256[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_Int256Array_Err_FailLengths(uint256 len) external { - vm.assume(len <= 10_000); - - int256[] memory a = new int256[](len); - int256[] memory b = new int256[](len); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_Int256Array_Err_Pass(int256 e1) external { - vm.assume(e1 != 0); - int256[] memory a = new int256[](3); - int256[] memory b = new int256[](3); - b[1] = e1; - prbTest._assertNotEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertNotEq_Int256Array_Pass(int256 e1) external { - vm.assume(e1 != 0); - int256[] memory a = new int256[](3); - int256[] memory b = new int256[](3); - b[1] = e1; - prbTest._assertNotEq(a, b, EXPECT_PASS); - } - - function test_AssertNotEq_StringArray_FailElements(string memory e0, string memory e1, string memory e2) external { - string[] memory a = new string[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - string[] memory b = new string[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - vm.expectEmit(); - emit Log("Error: a != b not satisfied [string[]]"); - prbTest._assertNotEq(a, b, EXPECT_FAIL); - } - - function test_AssertNotEq_StringArray_FailLengths(uint256 len) external { - vm.assume(len <= 10_000); - - string[] memory a = new string[](len); - string[] memory b = new string[](len); - - vm.expectEmit(); - emit Log("Error: a != b not satisfied [string[]]"); - prbTest._assertNotEq(a, b, EXPECT_FAIL); - } - - function test_AssertNotEq_StringArray_Err_FailElements( - string memory e0, - string memory e1, - string memory e2 - ) - external - { - string[] memory a = new string[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - string[] memory b = new string[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_StringArray_Err_FailLengths(uint256 len) external { - vm.assume(len <= 10_000); - - string[] memory a = new string[](len); - string[] memory b = new string[](len); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_StringArray_Err_Pass(string memory e1) external { - vm.assume(!Helpers.eq(e1, "")); - string[] memory a = new string[](3); - string[] memory b = new string[](3); - b[1] = e1; - prbTest._assertNotEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertNotEq_StringArray_Pass(string memory e1) external { - vm.assume(!Helpers.eq(e1, "")); - string[] memory a = new string[](3); - string[] memory b = new string[](3); - b[1] = e1; - prbTest._assertNotEq(a, b, EXPECT_PASS); - } - - function test_AssertNotEq_Uint256Array_FailElements(uint256 e0, uint256 e1, uint256 e2) external { - uint256[] memory a = new uint256[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - uint256[] memory b = new uint256[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - vm.expectEmit(); - emit Log("Error: a != b not satisfied [uint256[]]"); - prbTest._assertNotEq(a, b, EXPECT_FAIL); - } - - function test_AssertNotEq_Uint256Array_FailLengths(uint256 len) external { - vm.assume(len <= 10_000); - - uint256[] memory a = new uint256[](len); - uint256[] memory b = new uint256[](len); - - vm.expectEmit(); - emit Log("Error: a != b not satisfied [uint256[]]"); - prbTest._assertNotEq(a, b, EXPECT_FAIL); - } - - function test_AssertNotEq_Uint256Array_Err_FailElements(uint256 e0, uint256 e1, uint256 e2) external { - uint256[] memory a = new uint256[](3); - a[0] = e0; - a[1] = e1; - a[2] = e2; - - uint256[] memory b = new uint256[](3); - b[0] = e0; - b[1] = e1; - b[2] = e2; - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_Uint256Array_Err_FailLengths(uint256 len) external { - vm.assume(len <= 10_000); - - uint256[] memory a = new uint256[](len); - uint256[] memory b = new uint256[](len); - - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertNotEq(a, b, ERR, EXPECT_FAIL); - } - - function test_AssertNotEq_Uint256Array_Err_Pass(uint256 e1) external { - vm.assume(e1 != 0); - uint256[] memory a = new uint256[](3); - uint256[] memory b = new uint256[](3); - b[1] = e1; - prbTest._assertNotEq(a, b, ERR, EXPECT_PASS); - } - - function test_AssertNotEq_Uint256Array_Pass(uint256 e1) external { - vm.assume(e1 != 0); - uint256[] memory a = new uint256[](3); - uint256[] memory b = new uint256[](3); - b[1] = e1; - prbTest._assertNotEq(a, b, EXPECT_PASS); - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-true/assertTrue.t.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-true/assertTrue.t.sol deleted file mode 100644 index 6194528e..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/assert-true/assertTrue.t.sol +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import { PRBTest_Test } from "../PRBTest.t.sol"; - -contract AssertTrue_Test is PRBTest_Test { - function test_AssertTrue_Pass() external { - prbTest._assertTrue({ condition: true, expectFail: EXPECT_PASS }); - } - - function test_AssertTrue_Fail() external { - vm.expectEmit(); - emit Log("Error: Assertion Failed"); - prbTest._assertTrue({ condition: false, expectFail: EXPECT_FAIL }); - } - - function test_AssertTrue_Err_Pass() external { - prbTest._assertTrue({ condition: true, err: ERR, expectFail: EXPECT_PASS }); - } - - function test_AssertTrue_Err_Fail() external { - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._assertTrue({ condition: false, err: ERR, expectFail: EXPECT_FAIL }); - } -} diff --git a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/fail/fail.t.sol b/Week16/my-create-web3-dapp/contract/lib/prb-test/test/fail/fail.t.sol deleted file mode 100644 index 6732504f..00000000 --- a/Week16/my-create-web3-dapp/contract/lib/prb-test/test/fail/fail.t.sol +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import { PRBTest_Test } from "../PRBTest.t.sol"; - -contract Fail_Test is PRBTest_Test { - function test_Fail_Pass() external { - prbTest._fail(); - } - - function test_Fail_Err_Pass() external { - vm.expectEmit(); - emit LogNamedString("Error", ERR); - prbTest._fail(ERR); - } -} diff --git a/Week16/my-create-web3-dapp/contract/package.json b/Week16/my-create-web3-dapp/contract/package.json deleted file mode 100644 index fe4558ef..00000000 --- a/Week16/my-create-web3-dapp/contract/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "@prb/foundry-template", - "description": "Foundry-based template for developing Solidity smart contracts", - "version": "1.0.0", - "author": { - "name": "Paul Razvan Berg", - "url": "https://github.com/PaulRBerg" - }, - "devDependencies": { - "prettier": "^2.8.7", - "solhint": "^3.4.0" - }, - "keywords": [ - "blockchain", - "ethereum", - "forge", - "foundry", - "smart-contracts", - "solidity", - "template" - ], - "private": true, - "scripts": { - "clean": "rm -rf cache out", - "lint": "pnpm lint:sol && pnpm prettier:check", - "lint:sol": "forge fmt --check && pnpm solhint \"{script,src,test}/**/*.sol\"", - "prettier:check": "prettier --check \"**/*.{json,md,yml}\"", - "prettier:write": "prettier --write \"**/*.{json,md,yml}\"" - } -} diff --git a/Week16/my-create-web3-dapp/contract/pnpm-lock.yaml b/Week16/my-create-web3-dapp/contract/pnpm-lock.yaml deleted file mode 100644 index ad7b3d55..00000000 --- a/Week16/my-create-web3-dapp/contract/pnpm-lock.yaml +++ /dev/null @@ -1,437 +0,0 @@ -lockfileVersion: '6.0' - -devDependencies: - prettier: - specifier: ^2.8.7 - version: 2.8.7 - solhint: - specifier: ^3.4.0 - version: 3.4.1 - -packages: - - /@babel/code-frame@7.18.6: - resolution: {integrity: sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/highlight': 7.18.6 - dev: true - - /@babel/helper-validator-identifier@7.19.1: - resolution: {integrity: sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==} - engines: {node: '>=6.9.0'} - dev: true - - /@babel/highlight@7.18.6: - resolution: {integrity: sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/helper-validator-identifier': 7.19.1 - chalk: 2.4.2 - js-tokens: 4.0.0 - dev: true - - /@solidity-parser/parser@0.16.0: - resolution: {integrity: sha512-ESipEcHyRHg4Np4SqBCfcXwyxxna1DgFVz69bgpLV8vzl/NP1DtcKsJ4dJZXWQhY/Z4J2LeKBiOkOVZn9ct33Q==} - dependencies: - antlr4ts: 0.5.0-alpha.4 - dev: true - - /ajv@6.12.6: - resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} - dependencies: - fast-deep-equal: 3.1.3 - fast-json-stable-stringify: 2.1.0 - json-schema-traverse: 0.4.1 - uri-js: 4.4.1 - dev: true - - /ajv@8.12.0: - resolution: {integrity: sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==} - dependencies: - fast-deep-equal: 3.1.3 - json-schema-traverse: 1.0.0 - require-from-string: 2.0.2 - uri-js: 4.4.1 - dev: true - - /ansi-regex@5.0.1: - resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} - engines: {node: '>=8'} - dev: true - - /ansi-styles@3.2.1: - resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} - engines: {node: '>=4'} - dependencies: - color-convert: 1.9.3 - dev: true - - /ansi-styles@4.3.0: - resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} - engines: {node: '>=8'} - dependencies: - color-convert: 2.0.1 - dev: true - - /antlr4@4.12.0: - resolution: {integrity: sha512-23iB5IzXJZRZeK9TigzUyrNc9pSmNqAerJRBcNq1ETrmttMWRgaYZzC561IgEO3ygKsDJTYDTozABXa4b/fTQQ==} - engines: {node: '>=16'} - dev: true - - /antlr4ts@0.5.0-alpha.4: - resolution: {integrity: sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ==} - dev: true - - /argparse@2.0.1: - resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} - dev: true - - /ast-parents@0.0.1: - resolution: {integrity: sha512-XHusKxKz3zoYk1ic8Un640joHbFMhbqneyoZfoKnEGtf2ey9Uh/IdpcQplODdO/kENaMIWsD0nJm4+wX3UNLHA==} - dev: true - - /astral-regex@2.0.0: - resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} - engines: {node: '>=8'} - dev: true - - /balanced-match@1.0.2: - resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - dev: true - - /brace-expansion@2.0.1: - resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} - dependencies: - balanced-match: 1.0.2 - dev: true - - /callsites@3.1.0: - resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} - engines: {node: '>=6'} - dev: true - - /chalk@2.4.2: - resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} - engines: {node: '>=4'} - dependencies: - ansi-styles: 3.2.1 - escape-string-regexp: 1.0.5 - supports-color: 5.5.0 - dev: true - - /chalk@4.1.2: - resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} - engines: {node: '>=10'} - dependencies: - ansi-styles: 4.3.0 - supports-color: 7.2.0 - dev: true - - /color-convert@1.9.3: - resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} - dependencies: - color-name: 1.1.3 - dev: true - - /color-convert@2.0.1: - resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} - engines: {node: '>=7.0.0'} - dependencies: - color-name: 1.1.4 - dev: true - - /color-name@1.1.3: - resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} - dev: true - - /color-name@1.1.4: - resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - dev: true - - /commander@10.0.0: - resolution: {integrity: sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA==} - engines: {node: '>=14'} - dev: true - - /cosmiconfig@8.1.0: - resolution: {integrity: sha512-0tLZ9URlPGU7JsKq0DQOQ3FoRsYX8xDZ7xMiATQfaiGMz7EHowNkbU9u1coAOmnh9p/1ySpm0RB3JNWRXM5GCg==} - engines: {node: '>=14'} - dependencies: - import-fresh: 3.3.0 - js-yaml: 4.1.0 - parse-json: 5.2.0 - path-type: 4.0.0 - dev: true - - /emoji-regex@8.0.0: - resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - dev: true - - /error-ex@1.3.2: - resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} - dependencies: - is-arrayish: 0.2.1 - dev: true - - /escape-string-regexp@1.0.5: - resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} - engines: {node: '>=0.8.0'} - dev: true - - /fast-deep-equal@3.1.3: - resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} - dev: true - - /fast-diff@1.2.0: - resolution: {integrity: sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==} - dev: true - - /fast-json-stable-stringify@2.1.0: - resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} - dev: true - - /fs.realpath@1.0.0: - resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} - dev: true - - /glob@8.1.0: - resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} - engines: {node: '>=12'} - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 5.1.6 - once: 1.4.0 - dev: true - - /has-flag@3.0.0: - resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} - engines: {node: '>=4'} - dev: true - - /has-flag@4.0.0: - resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} - engines: {node: '>=8'} - dev: true - - /ignore@5.2.4: - resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} - engines: {node: '>= 4'} - dev: true - - /import-fresh@3.3.0: - resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} - engines: {node: '>=6'} - dependencies: - parent-module: 1.0.1 - resolve-from: 4.0.0 - dev: true - - /inflight@1.0.6: - resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} - dependencies: - once: 1.4.0 - wrappy: 1.0.2 - dev: true - - /inherits@2.0.4: - resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} - dev: true - - /is-arrayish@0.2.1: - resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} - dev: true - - /is-fullwidth-code-point@3.0.0: - resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} - engines: {node: '>=8'} - dev: true - - /js-tokens@4.0.0: - resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - dev: true - - /js-yaml@4.1.0: - resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} - dependencies: - argparse: 2.0.1 - dev: true - - /json-parse-even-better-errors@2.3.1: - resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} - dev: true - - /json-schema-traverse@0.4.1: - resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} - dev: true - - /json-schema-traverse@1.0.0: - resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==} - dev: true - - /lines-and-columns@1.2.4: - resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - dev: true - - /lodash.truncate@4.4.2: - resolution: {integrity: sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==} - dev: true - - /lodash@4.17.21: - resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} - dev: true - - /minimatch@5.1.6: - resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} - engines: {node: '>=10'} - dependencies: - brace-expansion: 2.0.1 - dev: true - - /once@1.4.0: - resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} - dependencies: - wrappy: 1.0.2 - dev: true - - /parent-module@1.0.1: - resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} - engines: {node: '>=6'} - dependencies: - callsites: 3.1.0 - dev: true - - /parse-json@5.2.0: - resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} - engines: {node: '>=8'} - dependencies: - '@babel/code-frame': 7.18.6 - error-ex: 1.3.2 - json-parse-even-better-errors: 2.3.1 - lines-and-columns: 1.2.4 - dev: true - - /path-type@4.0.0: - resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} - engines: {node: '>=8'} - dev: true - - /pluralize@8.0.0: - resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} - engines: {node: '>=4'} - dev: true - - /prettier@2.8.7: - resolution: {integrity: sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==} - engines: {node: '>=10.13.0'} - hasBin: true - dev: true - - /punycode@2.3.0: - resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==} - engines: {node: '>=6'} - dev: true - - /require-from-string@2.0.2: - resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} - engines: {node: '>=0.10.0'} - dev: true - - /resolve-from@4.0.0: - resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} - engines: {node: '>=4'} - dev: true - - /semver@6.3.0: - resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==} - dev: true - - /slice-ansi@4.0.0: - resolution: {integrity: sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==} - engines: {node: '>=10'} - dependencies: - ansi-styles: 4.3.0 - astral-regex: 2.0.0 - is-fullwidth-code-point: 3.0.0 - dev: true - - /solhint@3.4.1: - resolution: {integrity: sha512-pzZn2RlZhws1XwvLPVSsxfHrwsteFf5eySOhpAytzXwKQYbTCJV6z8EevYDiSVKMpWrvbKpEtJ055CuEmzp4Xg==} - dependencies: - '@solidity-parser/parser': 0.16.0 - ajv: 6.12.6 - antlr4: 4.12.0 - ast-parents: 0.0.1 - chalk: 4.1.2 - commander: 10.0.0 - cosmiconfig: 8.1.0 - fast-diff: 1.2.0 - glob: 8.1.0 - ignore: 5.2.4 - js-yaml: 4.1.0 - lodash: 4.17.21 - pluralize: 8.0.0 - semver: 6.3.0 - strip-ansi: 6.0.1 - table: 6.8.1 - text-table: 0.2.0 - optionalDependencies: - prettier: 2.8.7 - dev: true - - /string-width@4.2.3: - resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} - engines: {node: '>=8'} - dependencies: - emoji-regex: 8.0.0 - is-fullwidth-code-point: 3.0.0 - strip-ansi: 6.0.1 - dev: true - - /strip-ansi@6.0.1: - resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} - engines: {node: '>=8'} - dependencies: - ansi-regex: 5.0.1 - dev: true - - /supports-color@5.5.0: - resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} - engines: {node: '>=4'} - dependencies: - has-flag: 3.0.0 - dev: true - - /supports-color@7.2.0: - resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} - engines: {node: '>=8'} - dependencies: - has-flag: 4.0.0 - dev: true - - /table@6.8.1: - resolution: {integrity: sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA==} - engines: {node: '>=10.0.0'} - dependencies: - ajv: 8.12.0 - lodash.truncate: 4.4.2 - slice-ansi: 4.0.0 - string-width: 4.2.3 - strip-ansi: 6.0.1 - dev: true - - /text-table@0.2.0: - resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} - dev: true - - /uri-js@4.4.1: - resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} - dependencies: - punycode: 2.3.0 - dev: true - - /wrappy@1.0.2: - resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} - dev: true diff --git a/Week16/my-create-web3-dapp/contract/remappings.txt b/Week16/my-create-web3-dapp/contract/remappings.txt deleted file mode 100644 index 0c4be51a..00000000 --- a/Week16/my-create-web3-dapp/contract/remappings.txt +++ /dev/null @@ -1,3 +0,0 @@ -@prb/test/=lib/prb-test/src/ -forge-std/=lib/forge-std/src/ -src/=src/ diff --git a/Week16/my-create-web3-dapp/contract/script/Base.s.sol b/Week16/my-create-web3-dapp/contract/script/Base.s.sol deleted file mode 100644 index 9a145824..00000000 --- a/Week16/my-create-web3-dapp/contract/script/Base.s.sol +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.19; - -import { Script } from "forge-std/Script.sol"; - -abstract contract BaseScript is Script { - /// @dev Included to enable compilation of the script without a $MNEMONIC environment variable. - string internal constant TEST_MNEMONIC = "test test test test test test test test test test test junk"; - - /// @dev Needed for the deterministic deployments. - bytes32 internal constant ZERO_SALT = bytes32(0); - - /// @dev The address of the contract deployer. - address internal deployer; - - /// @dev Used to derive the deployer's address. - string internal mnemonic; - - constructor() { - mnemonic = vm.envOr("MNEMONIC", TEST_MNEMONIC); - (deployer,) = deriveRememberKey({ mnemonic: mnemonic, index: 0 }); - } - - modifier broadcaster() { - vm.startBroadcast(deployer); - _; - vm.stopBroadcast(); - } -} diff --git a/Week16/my-create-web3-dapp/contract/script/Counter.s.sol b/Week16/my-create-web3-dapp/contract/script/Counter.s.sol new file mode 100644 index 00000000..0e546aba --- /dev/null +++ b/Week16/my-create-web3-dapp/contract/script/Counter.s.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "forge-std/Script.sol"; + +contract CounterScript is Script { + function setUp() public {} + + function run() public { + vm.broadcast(); + } +} diff --git a/Week16/my-create-web3-dapp/contract/script/Deploy.s.sol b/Week16/my-create-web3-dapp/contract/script/Deploy.s.sol deleted file mode 100644 index d03ea2e6..00000000 --- a/Week16/my-create-web3-dapp/contract/script/Deploy.s.sol +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19; - -import { Foo } from "../src/Foo.sol"; - -import { BaseScript } from "./Base.s.sol"; - -/// @dev See the Solidity Scripting tutorial: https://book.getfoundry.sh/tutorials/solidity-scripting -contract Deploy is BaseScript { - function run() public broadcaster returns (Foo foo) { - foo = new Foo(); - } -} diff --git a/Week16/my-create-web3-dapp/contract/src/Counter.sol b/Week16/my-create-web3-dapp/contract/src/Counter.sol new file mode 100644 index 00000000..aded7997 --- /dev/null +++ b/Week16/my-create-web3-dapp/contract/src/Counter.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +contract Counter { + uint256 public number; + + function setNumber(uint256 newNumber) public { + number = newNumber; + } + + function increment() public { + number++; + } +} diff --git a/Week16/my-create-web3-dapp/contract/src/Foo.sol b/Week16/my-create-web3-dapp/contract/src/Foo.sol deleted file mode 100644 index d69be052..00000000 --- a/Week16/my-create-web3-dapp/contract/src/Foo.sol +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19; - -contract Foo { - function id(uint256 value) external pure returns (uint256) { - return value; - } -} diff --git a/Week16/my-create-web3-dapp/contract/test/Counter.t.sol b/Week16/my-create-web3-dapp/contract/test/Counter.t.sol new file mode 100644 index 00000000..30235e8a --- /dev/null +++ b/Week16/my-create-web3-dapp/contract/test/Counter.t.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.13; + +import "forge-std/Test.sol"; +import "../src/Counter.sol"; + +contract CounterTest is Test { + Counter public counter; + + function setUp() public { + counter = new Counter(); + counter.setNumber(0); + } + + function testIncrement() public { + counter.increment(); + assertEq(counter.number(), 1); + } + + function testSetNumber(uint256 x) public { + counter.setNumber(x); + assertEq(counter.number(), x); + } +} diff --git a/Week16/my-create-web3-dapp/contract/test/Foo.t.sol b/Week16/my-create-web3-dapp/contract/test/Foo.t.sol deleted file mode 100644 index 080f3229..00000000 --- a/Week16/my-create-web3-dapp/contract/test/Foo.t.sol +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.8.19 <0.9.0; - -import { PRBTest } from "@prb/test/PRBTest.sol"; -import { console2 } from "forge-std/console2.sol"; -import { StdCheats } from "forge-std/StdCheats.sol"; - -interface IERC20 { - function balanceOf(address account) external view returns (uint256); -} - -/// @dev If this is your first time with Forge, see the "Writing Tests" tutorial in the Foundry Book. -/// https://book.getfoundry.sh/forge/writing-tests -contract FooTest is PRBTest, StdCheats { - /// @dev An optional function invoked before each test case is run. - function setUp() public virtual { - // solhint-disable-previous-line no-empty-blocks - } - - /// @dev Basic test. Run it with `-vvv` to see the console log. - function test_Example() external { - console2.log("Hello World"); - assertTrue(true); - } - - /// @dev Fuzz test that provides random values for an unsigned integer, but it rejects zero as an input. - /// If you need more sophisticated input validation, use the `bound` utility instead. - /// See https://twitter.com/PaulRBerg/status/1622558791685242880 - function testFuzz_Example(uint256 x) external { - vm.assume(x != 0); // or x = bound(x, 1, 100) - assertGt(x, 0); - } - - /// @dev Fork test that runs against an Ethereum Mainnet fork. For this to work, you need to set `API_KEY_ALCHEMY` - /// in your environment You can get an API key for free at https://alchemy.com. - function testFork_Example() external { - // Silently pass this test if there is no API key. - string memory alchemyApiKey = vm.envOr("API_KEY_ALCHEMY", string("")); - if (bytes(alchemyApiKey).length == 0) { - return; - } - - // Otherwise, run the test against the mainnet fork. - vm.createSelectFork({ urlOrAlias: "mainnet", blockNumber: 16_428_000 }); - address usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; - address holder = 0x7713974908Be4BEd47172370115e8b1219F4A5f0; - uint256 actualBalance = IERC20(usdc).balanceOf(holder); - uint256 expectedBalance = 196_307_713.810457e6; - assertEq(actualBalance, expectedBalance); - } -}