From 589a3663410768b9bd95db5d7375e30a6b36cb8b Mon Sep 17 00:00:00 2001 From: heswithme Date: Fri, 27 Sep 2024 15:04:48 +0200 Subject: [PATCH] testfiles cleanup, remove some comments --- contracts/mocks/ERC20Rebasing.vy | 14 +- poetry.lock | 133 +++++++++--------- pyproject.toml | 10 +- tests/conftest.py | 18 +-- tests/fixtures/accounts.py | 11 -- tests/pools/exchange/test_exchange_reverts.py | 2 +- tests/pools/liquidity/test_add_liquidity.py | 6 - .../pools/liquidity/test_remove_liquidity.py | 1 - .../test_remove_liquidity_one_coin.py | 2 - tests/pools/oracle/test_oracles.py | 2 - tests/utils/tokens.py | 2 - tests/utils/transactions.py | 40 +----- 12 files changed, 80 insertions(+), 161 deletions(-) diff --git a/contracts/mocks/ERC20Rebasing.vy b/contracts/mocks/ERC20Rebasing.vy index f32d4c4e..14e9579c 100644 --- a/contracts/mocks/ERC20Rebasing.vy +++ b/contracts/mocks/ERC20Rebasing.vy @@ -74,13 +74,9 @@ def transfer(_to: address, _value: uint256) -> bool: @external def transferFrom(_from: address, _to: address, _value: uint256) -> bool: + self._rebase() _shares: uint256 = self._get_shares_by_coins(_value) _shares = min(self.shares[_from], _shares) - - if _shares > 0: - # only rebase on nonzero transfers - self._rebase() - # Value can be less than expected even if self.shares[_from] > _shares _new_value: uint256 = self._get_coins_by_shares(_shares) @@ -103,20 +99,20 @@ def approve(_spender: address, _value: uint256) -> bool: @view def _share_price() -> uint256: if self.totalShares == 0: - return 10**self.decimals - return self.totalCoin * 10**self.decimals / self.totalShares + return 10 ** self.decimals + return self.totalCoin * 10 ** self.decimals / self.totalShares @internal @view def _get_coins_by_shares(_shares: uint256) -> uint256: - return _shares * self._share_price() / 10**self.decimals + return _shares * self._share_price() / 10 ** self.decimals @internal @view def _get_shares_by_coins(_coins: uint256) -> uint256: - return _coins * 10**self.decimals / self._share_price() + return _coins * 10 ** self.decimals / self._share_price() @external diff --git a/poetry.lock b/poetry.lock index 10e4dbc7..ba7b49f5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -181,46 +181,47 @@ files = [ [[package]] name = "black" -version = "22.3.0" +version = "24.8.0" description = "The uncompromising code formatter." optional = false -python-versions = ">=3.6.2" -files = [ - {file = "black-22.3.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:2497f9c2386572e28921fa8bec7be3e51de6801f7459dffd6e62492531c47e09"}, - {file = "black-22.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:5795a0375eb87bfe902e80e0c8cfaedf8af4d49694d69161e5bd3206c18618bb"}, - {file = "black-22.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e3556168e2e5c49629f7b0f377070240bd5511e45e25a4497bb0073d9dda776a"}, - {file = "black-22.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:67c8301ec94e3bcc8906740fe071391bce40a862b7be0b86fb5382beefecd968"}, - {file = "black-22.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:fd57160949179ec517d32ac2ac898b5f20d68ed1a9c977346efbac9c2f1e779d"}, - {file = "black-22.3.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:cc1e1de68c8e5444e8f94c3670bb48a2beef0e91dddfd4fcc29595ebd90bb9ce"}, - {file = "black-22.3.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d2fc92002d44746d3e7db7cf9313cf4452f43e9ea77a2c939defce3b10b5c82"}, - {file = "black-22.3.0-cp36-cp36m-win_amd64.whl", hash = "sha256:a6342964b43a99dbc72f72812bf88cad8f0217ae9acb47c0d4f141a6416d2d7b"}, - {file = "black-22.3.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:328efc0cc70ccb23429d6be184a15ce613f676bdfc85e5fe8ea2a9354b4e9015"}, - {file = "black-22.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06f9d8846f2340dfac80ceb20200ea5d1b3f181dd0556b47af4e8e0b24fa0a6b"}, - {file = "black-22.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:ad4efa5fad66b903b4a5f96d91461d90b9507a812b3c5de657d544215bb7877a"}, - {file = "black-22.3.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:e8477ec6bbfe0312c128e74644ac8a02ca06bcdb8982d4ee06f209be28cdf163"}, - {file = "black-22.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:637a4014c63fbf42a692d22b55d8ad6968a946b4a6ebc385c5505d9625b6a464"}, - {file = "black-22.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:863714200ada56cbc366dc9ae5291ceb936573155f8bf8e9de92aef51f3ad0f0"}, - {file = "black-22.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10dbe6e6d2988049b4655b2b739f98785a884d4d6b85bc35133a8fb9a2233176"}, - {file = "black-22.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:cee3e11161dde1b2a33a904b850b0899e0424cc331b7295f2a9698e79f9a69a0"}, - {file = "black-22.3.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:5891ef8abc06576985de8fa88e95ab70641de6c1fca97e2a15820a9b69e51b20"}, - {file = "black-22.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:30d78ba6bf080eeaf0b7b875d924b15cd46fec5fd044ddfbad38c8ea9171043a"}, - {file = "black-22.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ee8f1f7228cce7dffc2b464f07ce769f478968bfb3dd1254a4c2eeed84928aad"}, - {file = "black-22.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6ee227b696ca60dd1c507be80a6bc849a5a6ab57ac7352aad1ffec9e8b805f21"}, - {file = "black-22.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:9b542ced1ec0ceeff5b37d69838106a6348e60db7b8fdd245294dc1d26136265"}, - {file = "black-22.3.0-py3-none-any.whl", hash = "sha256:bc58025940a896d7e5356952228b68f793cf5fcb342be703c3a2669a1488cb72"}, - {file = "black-22.3.0.tar.gz", hash = "sha256:35020b8886c022ced9282b51b5a875b6d1ab0c387b31a065b84db7c33085ca79"}, +python-versions = ">=3.8" +files = [ + {file = "black-24.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:09cdeb74d494ec023ded657f7092ba518e8cf78fa8386155e4a03fdcc44679e6"}, + {file = "black-24.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:81c6742da39f33b08e791da38410f32e27d632260e599df7245cccee2064afeb"}, + {file = "black-24.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:707a1ca89221bc8a1a64fb5e15ef39cd755633daa672a9db7498d1c19de66a42"}, + {file = "black-24.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:d6417535d99c37cee4091a2f24eb2b6d5ec42b144d50f1f2e436d9fe1916fe1a"}, + {file = "black-24.8.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:fb6e2c0b86bbd43dee042e48059c9ad7830abd5c94b0bc518c0eeec57c3eddc1"}, + {file = "black-24.8.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:837fd281f1908d0076844bc2b801ad2d369c78c45cf800cad7b61686051041af"}, + {file = "black-24.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:62e8730977f0b77998029da7971fa896ceefa2c4c4933fcd593fa599ecbf97a4"}, + {file = "black-24.8.0-cp311-cp311-win_amd64.whl", hash = "sha256:72901b4913cbac8972ad911dc4098d5753704d1f3c56e44ae8dce99eecb0e3af"}, + {file = "black-24.8.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:7c046c1d1eeb7aea9335da62472481d3bbf3fd986e093cffd35f4385c94ae368"}, + {file = "black-24.8.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:649f6d84ccbae73ab767e206772cc2d7a393a001070a4c814a546afd0d423aed"}, + {file = "black-24.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2b59b250fdba5f9a9cd9d0ece6e6d993d91ce877d121d161e4698af3eb9c1018"}, + {file = "black-24.8.0-cp312-cp312-win_amd64.whl", hash = "sha256:6e55d30d44bed36593c3163b9bc63bf58b3b30e4611e4d88a0c3c239930ed5b2"}, + {file = "black-24.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:505289f17ceda596658ae81b61ebbe2d9b25aa78067035184ed0a9d855d18afd"}, + {file = "black-24.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:b19c9ad992c7883ad84c9b22aaa73562a16b819c1d8db7a1a1a49fb7ec13c7d2"}, + {file = "black-24.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1f13f7f386f86f8121d76599114bb8c17b69d962137fc70efe56137727c7047e"}, + {file = "black-24.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:f490dbd59680d809ca31efdae20e634f3fae27fba3ce0ba3208333b713bc3920"}, + {file = "black-24.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:eab4dd44ce80dea27dc69db40dab62d4ca96112f87996bca68cd75639aeb2e4c"}, + {file = "black-24.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3c4285573d4897a7610054af5a890bde7c65cb466040c5f0c8b732812d7f0e5e"}, + {file = "black-24.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9e84e33b37be070ba135176c123ae52a51f82306def9f7d063ee302ecab2cf47"}, + {file = "black-24.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:73bbf84ed136e45d451a260c6b73ed674652f90a2b3211d6a35e78054563a9bb"}, + {file = "black-24.8.0-py3-none-any.whl", hash = "sha256:972085c618ee94f402da1af548a4f218c754ea7e5dc70acb168bfaca4c2542ed"}, + {file = "black-24.8.0.tar.gz", hash = "sha256:2500945420b6784c38b9ee885af039f5e7471ef284ab03fa35ecdde4688cd83f"}, ] [package.dependencies] click = ">=8.0.0" mypy-extensions = ">=0.4.3" +packaging = ">=22.0" pathspec = ">=0.9.0" platformdirs = ">=2" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} [package.extras] colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)"] +d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] uvloop = ["uvloop (>=0.15.2)"] @@ -1115,20 +1116,20 @@ tools = ["hypothesis (>=4.18.2,<5.0.0)"] [[package]] name = "eth-account" -version = "0.13.3" +version = "0.13.4" description = "eth-account: Sign Ethereum transactions and messages with local private keys" optional = false python-versions = "<4,>=3.8" files = [ - {file = "eth_account-0.13.3-py3-none-any.whl", hash = "sha256:c8f3dae3403b8647f386fcc081fb8c2a0970991cf3e00af7e7ebd73f95d6a319"}, - {file = "eth_account-0.13.3.tar.gz", hash = "sha256:03d6af5d314e64b3dd53283e15b24736c5caa24542e5edac0455d6ff87d8b1e0"}, + {file = "eth_account-0.13.4-py3-none-any.whl", hash = "sha256:a4c109e9bad3a278243fcc028b755fb72b43e25b1e6256b3f309a44f5f7d87c3"}, + {file = "eth_account-0.13.4.tar.gz", hash = "sha256:2e1f2de240bef3d9f3d8013656135d2a79b6be6d4e7885bce9cace4334a4a376"}, ] [package.dependencies] bitarray = ">=2.4.0" ckzg = ">=2.0.0" eth-abi = ">=4.0.0-b.2" -eth-keyfile = ">=0.7.0" +eth-keyfile = ">=0.7.0,<0.9.0" eth-keys = ">=0.4.0" eth-rlp = ">=2.1.0" eth-utils = ">=2.0.0" @@ -1392,19 +1393,19 @@ typing = ["typing-extensions (>=4.12.2)"] [[package]] name = "flake8" -version = "4.0.1" +version = "7.1.1" description = "the modular source code checker: pep8 pyflakes and co" optional = false -python-versions = ">=3.6" +python-versions = ">=3.8.1" files = [ - {file = "flake8-4.0.1-py2.py3-none-any.whl", hash = "sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d"}, - {file = "flake8-4.0.1.tar.gz", hash = "sha256:806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d"}, + {file = "flake8-7.1.1-py2.py3-none-any.whl", hash = "sha256:597477df7860daa5aa0fdd84bf5208a043ab96b8e96ab708770ae0364dd03213"}, + {file = "flake8-7.1.1.tar.gz", hash = "sha256:049d058491e228e03e67b390f311bbf88fce2dbaa8fa673e7aea87b7198b8d38"}, ] [package.dependencies] -mccabe = ">=0.6.0,<0.7.0" -pycodestyle = ">=2.8.0,<2.9.0" -pyflakes = ">=2.4.0,<2.5.0" +mccabe = ">=0.7.0,<0.8.0" +pycodestyle = ">=2.12.0,<2.13.0" +pyflakes = ">=3.2.0,<3.3.0" [[package]] name = "hexbytes" @@ -1568,20 +1569,17 @@ test-extra = ["curio", "ipython[test]", "matplotlib (!=3.2.0)", "nbformat", "num [[package]] name = "isort" -version = "5.12.0" +version = "5.13.2" description = "A Python utility / library to sort Python imports." optional = false python-versions = ">=3.8.0" files = [ - {file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"}, - {file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"}, + {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, + {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, ] [package.extras] -colors = ["colorama (>=0.4.3)"] -pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"] -plugins = ["setuptools"] -requirements-deprecated-finder = ["pip-api", "pipreqs"] +colors = ["colorama (>=0.4.6)"] [[package]] name = "jaraco-classes" @@ -1770,22 +1768,23 @@ test = ["pytest"] [[package]] name = "mamushi" -version = "0.0.2b0" +version = "0.0.4a3" description = "Vyper formatter" optional = false python-versions = ">=3.9" files = [ - {file = "mamushi-0.0.2b0-py3-none-any.whl", hash = "sha256:53379ea746cea4b8e0acb573c063e5fb6a42b8bd1b6b4c121e6c3e9eaab5beb7"}, - {file = "mamushi-0.0.2b0.tar.gz", hash = "sha256:f8dabbb783c6803b8b4a60506a63263947a5f80e0e07588799935e837abc7f82"}, + {file = "mamushi-0.0.4a3-py3-none-any.whl", hash = "sha256:e2c0edbb75c218d354105b3b4d75a5f95a23f3ce02919b81cf123aca0ecf374b"}, + {file = "mamushi-0.0.4a3.tar.gz", hash = "sha256:2423a88c324405cff3fd2d6ff63140f57b5575bb5b315be9ae3e6b6c6d8081de"}, ] [package.dependencies] click = ">=8.0.0" lark = ">=1.0.0" +mypy-extensions = "0.4.3" pathspec = ">=0.9.0" [package.extras] -dev = ["black (>=22.6.0)", "bump2version (>=1.0.0)", "coverage (>=6.0.0)", "flake8 (==5.0.4)", "mypy (>=0.900)", "mypy-extensions (==0.4.3)", "pylint (==2.14.5)", "pytest (>=6.0.0)", "pytest-cov (>=3.0.0)"] +dev = ["black (==23.1.0)", "bump2version (>=1.0.0)", "coverage (>=6.0.0)", "flake8 (==5.0.4)", "mypy (>=0.900)", "mypy-extensions (==0.4.3)", "pre-commit (==2.20.0)", "pylint (==2.14.5)", "pytest (>=6.0.0)", "pytest-cov (>=3.0.0)"] [[package]] name = "markdown-it-py" @@ -1827,13 +1826,13 @@ traitlets = "*" [[package]] name = "mccabe" -version = "0.6.1" +version = "0.7.0" description = "McCabe checker, plugin for flake8" optional = false -python-versions = "*" +python-versions = ">=3.6" files = [ - {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, - {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, + {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, + {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, ] [[package]] @@ -1933,13 +1932,13 @@ files = [ [[package]] name = "mypy-extensions" -version = "1.0.0" -description = "Type system extensions for programs checked with the mypy type checker." +version = "0.4.3" +description = "Experimental type system extensions for programs checked with the mypy typechecker." optional = false -python-versions = ">=3.5" +python-versions = "*" files = [ - {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, - {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, + {file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"}, + {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, ] [[package]] @@ -2267,13 +2266,13 @@ test = ["factory-boy (>=3.0.0)", "hypothesis (>=6,<7)", "pytest (>=7.0.0)", "pyt [[package]] name = "pycodestyle" -version = "2.8.0" +version = "2.12.1" description = "Python style guide checker" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +python-versions = ">=3.8" files = [ - {file = "pycodestyle-2.8.0-py2.py3-none-any.whl", hash = "sha256:720f8b39dde8b293825e7ff02c475f3077124006db4f440dcbc9a20b76548a20"}, - {file = "pycodestyle-2.8.0.tar.gz", hash = "sha256:eddd5847ef438ea1c7870ca7eb78a9d47ce0cdb4851a5523949f2601d0cbbe7f"}, + {file = "pycodestyle-2.12.1-py2.py3-none-any.whl", hash = "sha256:46f0fb92069a7c28ab7bb558f05bfc0110dac69a0cd23c61ea0040283a9d78b3"}, + {file = "pycodestyle-2.12.1.tar.gz", hash = "sha256:6838eae08bbce4f6accd5d5572075c63626a15ee3e6f842df996bf62f6d73521"}, ] [[package]] @@ -2454,13 +2453,13 @@ typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" [[package]] name = "pyflakes" -version = "2.4.0" +version = "3.2.0" description = "passive checker of Python programs" optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +python-versions = ">=3.8" files = [ - {file = "pyflakes-2.4.0-py2.py3-none-any.whl", hash = "sha256:3bb3a3f256f4b7968c9c788781e4ff07dce46bdf12339dcda61053375426ee2e"}, - {file = "pyflakes-2.4.0.tar.gz", hash = "sha256:05a85c2872edf37a4ed30b0cce2f6093e1d0581f8c19d7393122da7e25b2b24c"}, + {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, + {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, ] [[package]] @@ -3355,4 +3354,4 @@ type = ["pytest-mypy"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "dda59083754d1dcbe1946819d6a8c08fdb2f148b17f5ba8651b819294e223dc4" +content-hash = "374aae5736c6ee579b0abe6acfc03c15f511fe0cd67fcbdb296489951cfcd632" diff --git a/pyproject.toml b/pyproject.toml index 417c1fb3..6be8fe09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,17 +10,17 @@ package-mode = false [tool.poetry.dependencies] python = "^3.10" -poetry = "1.8.3" +poetry = "^1.8.0" vyper = "0.3.10" pycryptodome = "^3.18.0" pre-commit = "^3.3.3" titanoboa-zksync = {git = "https://github.com/DanielSchiavini/titanoboa-zksync.git", tag = "v0.1.2"} # inherits titanoboa 0.1.10 [tool.poetry.group.dev.dependencies] -black = "22.3.0" -flake8 = "4.0.1" -isort = "5.12.0" -mamushi = "^0.0.2a1" +black = "^24.0.0" +flake8 = "^7.0.0" +isort = "^5.0.0" +mamushi = "^0.0.4a3" [tool.poetry.group.testing.dependencies] diff --git a/tests/conftest.py b/tests/conftest.py index bff1fb62..a9f1206b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -22,18 +22,6 @@ def pytest_generate_tests(metafunc): - # some targeted debug - # if metafunc.function.__name__ == "test_price_ema_remove_imbalance": - # print("Debugging...") - # metafunc.parametrize("pool_type", [0]) - # metafunc.parametrize("pool_token_types", [(0, 0)]) - # # metafunc.parametrize("sending,receiving", [(0, 1)]) - # metafunc.parametrize("metapool_token_type", [None]) - # metafunc.parametrize("initial_decimals", [(18, 18)]) - # return - # Combined parametrization of pool_type and metapool_token_type (to avoid repeating tests in basic_pools - # for various metapool_token_types) - if ALL_TOKEN_PAIRS and not EXTENSIVE_TOKEN_PAIRS: metafunc.definition.add_marker(pytest.mark.all_token_pairs) if EXTENSIVE_TOKEN_PAIRS: @@ -92,17 +80,15 @@ def get_pool_token_pairs(metafunc): items = get_tokens_for_metafunc(metafunc) # make all combinations possible all_combinations = list(combinations_with_replacement(items, 2)) # 6 combinations (1,0 == 0,1) - all_all_combinations = list(product(items, items)) # 9 combinations (1,0 != 0,1) + extensive_combinations = list(product(items, items)) # 9 combinations (1,0 != 0,1) if len(all_combinations) < 2 or metafunc.definition.get_closest_marker("all_token_pairs"): return all_combinations if metafunc.definition.get_closest_marker("extensive_token_pairs"): - return all_all_combinations + return extensive_combinations # make sure we get the same result in each worker random = Random(len(metafunc.fixturenames)) # take 2 combinations for smaller test set return sorted(random.sample(all_combinations, k=2)) - # Q: why sample only 2 when we have 6? and even 9? - # todo - ideally we test all possible combinations # dev: added all_ and extensive_token_pairs marker to test all combinations diff --git a/tests/fixtures/accounts.py b/tests/fixtures/accounts.py index 2d9f89e5..e2066bf9 100644 --- a/tests/fixtures/accounts.py +++ b/tests/fixtures/accounts.py @@ -164,7 +164,6 @@ def basic_setup( pool_tokens, metapool_token_type, ): - # assert metapool_token_type is not None, "Fixture required downstream" # bob and alice have tokens from pool for user in [alice, bob]: mint_account(user, pool_tokens, initial_balance, basic_initial_amounts) @@ -173,14 +172,6 @@ def basic_setup( with boa.env.prank(alice): basic_swap.add_liquidity(deposit_basic_amounts, 0) - # mint_account(bob, pool_tokens, initial_balance, basic_initial_amounts) - # approve_account(bob, pool_tokens, basic_swap) - # @dev small cleanup, code was not consistent - # mint_for_testing(bob, 1 * 10**18, None, True) - # with boa.env.prank(bob): - # for token in pool_tokens: - # token.approve(basic_swap.address, 2**256 - 1) - @pytest.fixture() def meta_setup( @@ -196,8 +187,6 @@ def meta_setup( meta_initial_amounts, underlying_tokens, pool_tokens, - # add_initial_liquidity_owner_meta, # - this fixture leads to doubled liquidity in metapool, - # results in failing some tests metapool_token, ): approve_account(alice, pool_tokens, meta_swap) diff --git a/tests/pools/exchange/test_exchange_reverts.py b/tests/pools/exchange/test_exchange_reverts.py index b9df774d..4241d842 100644 --- a/tests/pools/exchange/test_exchange_reverts.py +++ b/tests/pools/exchange/test_exchange_reverts.py @@ -39,7 +39,7 @@ def test_insufficient_balance( # the transfer of tokens. Otherwise, the pool is safe. # !!!!!!! Fixed with changing rebase logic to not rebase at 0 transfer !!!!!!!!!! # - # what is not fixed - is that this min function transfers 0 evein if + # what is not fixed - is that this min function transfers 0 even if # non-0 is requested, and this bypasses dx > 0 assert in the contract, # resulting in a 0->swap (that fails the test in some cases) # Thus still skipping problematic tests. diff --git a/tests/pools/liquidity/test_add_liquidity.py b/tests/pools/liquidity/test_add_liquidity.py index 1c8b2cbc..64dcd81e 100644 --- a/tests/pools/liquidity/test_add_liquidity.py +++ b/tests/pools/liquidity/test_add_liquidity.py @@ -110,10 +110,6 @@ def test_insufficient_balance(charlie, swap, pool_type, decimals, meta_decimals, amounts = [(10**i) for i in decimals] else: amounts = [(10**i) for i in [meta_decimals, 18]] - # if pool_type == 0 and pool_token_types[0] == pool_token_types[1] == 2: - # swap.add_liquidity(amounts, 0, sender=charlie) - # pass - # else: with boa.reverts(): # invalid approval or balance swap.add_liquidity(amounts, 0, sender=charlie) @@ -128,8 +124,6 @@ def test_min_amount_too_high(bob, swap, pool_type, deposit_amounts, pool_tokens) def test_event(bob, swap, pool_type, deposit_amounts, pool_tokens, pool_token_types, metapool_token_type): - # if pool_type == 1 and metapool_token_type == 0: - # pytest.xfail("pool_type = meta, meta token type = plain - should be fixed") size = 2 check_invariant = True if pool_type == 0: diff --git a/tests/pools/liquidity/test_remove_liquidity.py b/tests/pools/liquidity/test_remove_liquidity.py index 0d524d8f..2cba0c2f 100644 --- a/tests/pools/liquidity/test_remove_liquidity.py +++ b/tests/pools/liquidity/test_remove_liquidity.py @@ -38,7 +38,6 @@ def test_remove_liquidity( assert amount_after == pytest.approx( amount_before * 2, rel=1.5e-2 ) # we deposit half of all balance value (approx for orcales, rebasing etc) - if (pool_type == 0 and coin_type == 2) or (pool_type == 1 and metapool_token_type == 2): assert coin.balanceOf(swap) == pytest.approx( 0, abs=(amount_after - amount_before) * (1 - 1000000 / 1000001) # approx for rebasing tokens diff --git a/tests/pools/liquidity/test_remove_liquidity_one_coin.py b/tests/pools/liquidity/test_remove_liquidity_one_coin.py index 26e89f77..f4a4490c 100644 --- a/tests/pools/liquidity/test_remove_liquidity_one_coin.py +++ b/tests/pools/liquidity/test_remove_liquidity_one_coin.py @@ -12,8 +12,6 @@ def test_amount_received( ): coins = pool_tokens if pool_type == 0 else underlying_tokens[:2] initial_amount = coins[idx].balanceOf(alice) - # if pool_token_types[0] == pool_token_types[1] == 2: - # pass swap.remove_liquidity_one_coin(10**18, idx, 0, sender=alice) if (pool_type == 0 and pool_token_types[idx] == 2) or ( # rebase token in base pool pool_type == 1 and metapool_token_type == 2 and idx == 0 # rebase token in metapool diff --git a/tests/pools/oracle/test_oracles.py b/tests/pools/oracle/test_oracles.py index afc85148..8dda521b 100644 --- a/tests/pools/oracle/test_oracles.py +++ b/tests/pools/oracle/test_oracles.py @@ -131,8 +131,6 @@ def test_price_ema_remove_one(swap, alice, amount, dt0, dt): dt=strategy("uint256", min_value=0, max_value=10**6), ) @settings(**SETTINGS) -# @pytest.mark.parametrize("amount, dt0, dt", [(99190, 12, 12)]) -# @pytest.mark.parametrize("amount, dt0, dt", [(94741, 12, 12)]) def test_price_ema_remove_imbalance(swap, alice, dt0, dt, pool_size, deposit_amounts, amount): i = random.choice(range(swap.N_COINS())) # i = 1 diff --git a/tests/utils/tokens.py b/tests/utils/tokens.py index 187b2b05..8223aa03 100644 --- a/tests/utils/tokens.py +++ b/tests/utils/tokens.py @@ -1,6 +1,4 @@ import boa - -# from boa.contracts.vyper import VyperContract from boa.contracts.vyper.vyper_contract import VyperContract from eth_utils import to_checksum_address diff --git a/tests/utils/transactions.py b/tests/utils/transactions.py index abee4c53..b1189263 100644 --- a/tests/utils/transactions.py +++ b/tests/utils/transactions.py @@ -1,45 +1,7 @@ from typing import Any from boa.contracts.vyper.event import Event -from boa.contracts.vyper.vyper_contract import VyperContract, VyperFunction - -# from boa.vyper.contract import VyperContract, VyperFunction -# from boa.vyper.event import Event - - -def call_returning_result_and_logs_old( - # previous function, commits by Oleg 14 months ago - # I assume it was copied from legacy stableswap, when boa fucntionality was not there yet - contract: VyperContract, - function_name: str, - *args, - value=0, - gas=None, - sender=None, - **kwargs, -) -> tuple[Any, list[Event]]: - func: VyperFunction = getattr(contract, function_name) - calldata_bytes = func.prepare_calldata(*args, **kwargs) - override_bytecode = getattr(func, "override_bytecode", None) - - with func.contract._anchor_source_map(func._source_map): - computation = func.env.execute_code( - to_address=func.contract.address, - sender=sender, - data=calldata_bytes, - value=value, - gas=gas, - is_modifying=func.func_t.is_mutable, - override_bytecode=override_bytecode, - contract=func.contract, - ) - - typ = func.func_t.return_type - res = func.contract.marshal_to_python(computation, typ) - - events = contract.get_logs(computation) - - return res, events +from boa.contracts.vyper.vyper_contract import VyperContract def call_returning_result_and_logs(