Skip to content

Commit

Permalink
Merge pull request #1 from tradingstrategy-ai/test-branch
Browse files Browse the repository at this point in the history
See if Github Actions fire
  • Loading branch information
miohtama authored Jan 9, 2024
2 parents fa44e96 + 15ab299 commit 622bc98
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 19 deletions.
34 changes: 21 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Run ape test on Github CI
name: Automated test suite

on:
push:
branches: [ master ]
branches: [ main ]
pull_request:
branches: [ master ]
branches: [ main ]

jobs:

Expand All @@ -19,23 +20,30 @@ jobs:
cancel-in-progress: true

steps:
# TODO: we only need contracts/aave-v3-deploy for tests
# but there does not seem to be an option to choose which submodules to checkout
# https://github.com/actions/checkout
- uses: actions/checkout@v3
with:
submodules: true
- name: Install poetry
run: pipx install poetry
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: '3.12'
cache: 'poetry'
- name: Install dependencies
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Install Ape and dependencies
run: |
poetry env use '3.12'
poetry install --all-extras
- name: Install Ape plugins
run: |
poetry run ape plugins install .
- name: Compile smart contract dependency packages
run: |
poetry run ape pm compile
- name: Compile our smart contracts
run: |
poetry run ape compile
- name: Run test scripts
run: |
poetry run pytest
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ has accepted the latest terms of service.

- Record on-chain that users have accepted some sort of a disclaimer
- Enforce users to accept disclaimers when they use with the smart contract
- User signs an [EIP-191 message](https://eips.ethereum.org/EIPS/eip-191) from their wallet
- Multisignature wallet and protocol friendly [EIP-1271](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/SignatureChecker.sol) is supported

## Requirements

Expand Down Expand Up @@ -71,3 +73,10 @@ poetry shell
ape test
```

## More information

- [Join Discord for any questions](https://tradingstrategy.ai/community).
- [Watch tutorials on YouTube](https://www.youtube.com/@tradingstrategyprotocol)
- [Follow on Twitter](https://twitter.com/TradingProtocol)
- [Follow on Telegram](https://t.me/trading_protocol)
- [Follow on LinkedIn](https://www.linkedin.com/company/trading-strategy/)
18 changes: 17 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ packages = [{include = "terms_of_service"}]
[tool.poetry.dependencies]
python = "^3.10"
eth-ape = "^0.7.3"
setuptools = "^69.0.3"


[tool.poetry.group.dev.dependencies]
Expand Down
10 changes: 5 additions & 5 deletions tests/test_update_terms_of_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ def tos(networks, project, deployer):

def test_start_zero_version(tos: ContractInstance):
assert tos.latestTermsOfServiceVersion() == 0
assert tos.latestTermsOfServiceHash() == HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000')
assert tos.latestAcceptanceMessageHash() == HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000')


def test_first_terms_of_service(tos: ContractInstance, deployer: TestAccount):
new_version = 1
new_hash = random.randbytes(32)
tx = tos.updateTermsOfService(new_version, new_hash, sender=deployer)
assert tos.latestTermsOfServiceVersion() == 1
assert tos.latestTermsOfServiceHash() == new_hash
assert tos.latestAcceptanceMessageHash() == new_hash

# https://academy.apeworx.io/articles/testing
logs = list(tx.decode_logs(tos.UpdateTermsOfService))
assert len(logs) == 1
assert logs[0].version == new_version
assert logs[0].textHash == new_hash
assert logs[0].acceptanceMessageHash == new_hash

assert tos.getTextHash(new_version) == new_hash

Expand All @@ -50,13 +50,13 @@ def test_second_terms_of_service(tos: ContractInstance, deployer: TestAccount):
new_hash = random.randbytes(32)
tos.updateTermsOfService(new_version, new_hash, sender=deployer)
assert tos.latestTermsOfServiceVersion() == 1
assert tos.latestTermsOfServiceHash() == new_hash
assert tos.latestAcceptanceMessageHash() == new_hash

new_version = 2
new_hash = random.randbytes(32)
tos.updateTermsOfService(new_version, new_hash, sender=deployer)
assert tos.latestTermsOfServiceVersion() == 2
assert tos.latestTermsOfServiceHash() == new_hash
assert tos.latestAcceptanceMessageHash() == new_hash


def test_wrong_owner(tos: ContractInstance, random_user: TestAccount):
Expand Down

0 comments on commit 622bc98

Please sign in to comment.