Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored tests #55

Merged
merged 49 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
b8510fa
setting up, fixed version for boa==0.1.10
heswithme Aug 22, 2024
b33a1d5
cleanup
heswithme Aug 22, 2024
896d6fa
some coverage runs
heswithme Aug 23, 2024
816dcd9
gitignore for test logs
heswithme Aug 23, 2024
3b71f2c
test framework
heswithme Aug 23, 2024
55334a5
improving test framework
heswithme Aug 23, 2024
02f8e16
added selective tests run
heswithme Aug 23, 2024
c6a566d
wip
heswithme Aug 23, 2024
07bab1e
upload
heswithme Aug 23, 2024
4c5578a
fixed report gen
heswithme Aug 23, 2024
4911e6c
import order, removes warnings
heswithme Aug 23, 2024
b69e367
initital report added for comparisons
heswithme Aug 23, 2024
89c9ef1
resolved issues in test_approve and test_token
heswithme Aug 27, 2024
5afbd99
id change
heswithme Aug 27, 2024
da1ed53
commented transactions util
heswithme Aug 27, 2024
a6164e4
gauge debug, create2 boa issues
heswithme Aug 29, 2024
efd1513
gauge errs fixed, conftest for auto
heswithme Aug 30, 2024
1028097
progress with rebasing tokens in test_min_dy
heswithme Sep 3, 2024
06c0e70
added relative tolerance
heswithme Sep 3, 2024
f886db6
combined parametrization
heswithme Sep 4, 2024
f674e60
finished with rebasing tokens and swap.exchange() test
heswithme Sep 4, 2024
161fbcc
wip oracle unbalanced swaps
heswithme Sep 4, 2024
6d9375d
we test all token types everywhere
heswithme Sep 5, 2024
0d0fb83
remove_liquidity test passing
heswithme Sep 16, 2024
50d0d9c
remove liquidity tests wip
heswithme Sep 17, 2024
b465cea
liquidity add tests
heswithme Sep 18, 2024
f0cbe07
test: line-length=100
heswithme Sep 20, 2024
577f110
test: fixed test_exchange_received
heswithme Sep 20, 2024
13aba85
test: alter testgen for extensive token pairs
heswithme Sep 20, 2024
bea2451
test: rebasing token issue, using skip, todo
heswithme Sep 20, 2024
7cf59b7
test: rebasing token investigation
heswithme Sep 20, 2024
84ec2b9
test: rebasing token investigation
heswithme Sep 20, 2024
701e343
test suite run with extensive tokens
heswithme Sep 23, 2024
f7515f0
skipping unfixable tests
heswithme Sep 23, 2024
b9e16c4
meta tests corrected
heswithme Sep 23, 2024
7a16d9c
more progress on failing tests
heswithme Sep 23, 2024
9176ff0
hunting the rebasing token inconsistency
heswithme Sep 24, 2024
3653c93
oracle tests passing
heswithme Sep 24, 2024
4ef57f3
fixed all
heswithme Sep 24, 2024
543610f
mock commit to re-run actions
heswithme Sep 25, 2024
f3714d8
pre-commit linting
heswithme Sep 25, 2024
26bdcd9
pre-commit runs
heswithme Sep 25, 2024
2392e23
Bumped requirements versions
heswithme Sep 25, 2024
7a531be
testfiles cleanup, remove some comments
heswithme Sep 27, 2024
a64616a
dev: removed zero-transfer rebase
heswithme Sep 27, 2024
526f34c
removed test_suite harness, fresh .lock file
heswithme Sep 27, 2024
f65736a
dev: altered rebasing logic #2
heswithme Sep 27, 2024
2cfde09
chore: trigger tests on pr
heswithme Sep 27, 2024
b3647bb
chore: rpc fixture change
heswithme Sep 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push]
on: [push, pull_request]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -27,6 +27,7 @@ jobs:
fail-fast: false
matrix:
name:
- token
- gauge
- pools/exchange
- pools/general
Expand All @@ -51,7 +52,7 @@ jobs:

- name: Install Requirements
run: |
pip install poetry==1.5.1
pip install poetry==1.8.3
poetry config virtualenvs.in-project true
poetry install --no-interaction --without dev

Expand All @@ -60,4 +61,8 @@ jobs:
WEB3_PROVIDER_URL: ${{ secrets.WEB3_PROVIDER_URL }}
run: |
source .venv/bin/activate
pytest --numprocesses=auto tests/${{ matrix.name }}/
if [[ ${{ matrix.name }} == "pools/oracle" ]]; then
pytest --numprocesses=auto --dist=loadscope tests/${{ matrix.name }}/
else
pytest --numprocesses=auto tests/${{ matrix.name }}/
fi
166 changes: 166 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,169 @@ scripts/experiments/get_p.py
todo.txt
AuditorComments.md
set_env.py

# test logs
all_tests.log
test_suite/test_reports/
wip_diary.m# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
**/.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
profile-venv/
profilingenv/
ENV/
env.bak/
venv.bak/
apeenv/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# eth-brownie/ape
.history
.build
reports/

# pycharm/vscode
.DS_Store
.idea
**/.idea
.vscode
*.csv

# misc
/data
todo.txt
node_modules
*.json
/audits

# temp
docs/
scripts/experiments/get_p.py
.python-version
todo.txt
AuditorComments.md
set_env.py

# test logs
all_tests.log
test_suite/test_reports/
wip_diary.mdd
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repos:
hooks:
- id: black
args:
- --line-length=120
- --skip-magic-trailing-comma
- --target-version=py310
- repo: https://github.com/PyCQA/flake8
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ See the [documentation](https://docs.curve.fi) for more detailed information.
Install dependencies using poetry (python ^3.10.4)

```shell
pip install poetry==1.5.1
pip install poetry==1.8.3
poetry install
```

Expand Down
15 changes: 9 additions & 6 deletions contracts/mocks/ERC20Rebasing.vy
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def allowance(_owner: address, _spender: address) -> uint256:
def transfer(_to: address, _value: uint256) -> bool:
self._rebase()
_shares: uint256 = self._get_shares_by_coins(_value)

self.shares[msg.sender] -= _shares
self.shares[_to] += _shares
log Transfer(msg.sender, _to, _value)
Expand All @@ -74,9 +73,13 @@ 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)

Expand All @@ -99,20 +102,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
Expand Down
Loading
Loading