Skip to content

Commit

Permalink
Merge pull request #55 from heswithme/test/fixed-testsuite
Browse files Browse the repository at this point in the history
Refactored tests
  • Loading branch information
bout3fiddy authored Nov 27, 2024
2 parents 0227f4d + b3647bb commit fd54b9a
Show file tree
Hide file tree
Showing 29 changed files with 1,787 additions and 1,447 deletions.
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

0 comments on commit fd54b9a

Please sign in to comment.