-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from BalancerMaxis/deployments
Deployments fetch
- Loading branch information
Showing
9 changed files
with
255 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 10 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: [3.9, '3.10'] | ||
os: [ubuntu-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
make | ||
- name: Run tests | ||
run: | | ||
make ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.PHONY: docs | ||
init: | ||
pip install -e .[socks] | ||
pip install -r bal_addresses/requirements.txt | ||
pip install -r bal_addresses/requirements-dev.txt | ||
ci: | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class MultipleMatchesError(Exception): | ||
pass | ||
|
||
|
||
class NoResultError(Exception): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pytest-mock | ||
responses | ||
pytest-cov | ||
pytest==7.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ pathlib>=1.0 | |
requests | ||
pandas | ||
web3==5.31.3 | ||
dotmap | ||
dotmap | ||
munch==4.0.0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import pytest | ||
import responses | ||
|
||
from bal_addresses import AddrBook | ||
|
||
|
||
@responses.activate | ||
def test_deployments_populated(): | ||
responses.add( | ||
responses.GET, | ||
"https://raw.githubusercontent.com/BalancerMaxis" | ||
"/bal_addresses/main/outputs/deployments.json", | ||
json={ | ||
"BFactory": "0x9424B1412450D0f8Fc2255FAf6046b98213B76Bd", | ||
} | ||
) | ||
responses.add( | ||
responses.GET, | ||
"https://raw.githubusercontent.com/balancer" | ||
"/balancer-deployments/master/addresses/mainnet.json", | ||
json={ | ||
"20210418-vault": { | ||
"contracts": [ | ||
{ | ||
"name": "Vault", | ||
"address": "0xBA12222222228d8Ba445958a75a0704d566BF2C8" | ||
}, | ||
{ | ||
"name": "BalancerHelpers", | ||
"address": "0x5aDDCCa35b7A0D07C74063c48700C8590E87864E" | ||
}, | ||
{ | ||
"name": "ProtocolFeesCollector", | ||
"address": "0xce88686553686DA562CE7Cea497CE749DA109f9F" | ||
} | ||
], | ||
"status": "ACTIVE" | ||
} | ||
} | ||
) | ||
a = AddrBook("mainnet") | ||
|
||
a.populate_deployments() | ||
assert a.deployments.vault.status == "ACTIVE" | ||
assert a.deployments.vault.contracts.Vault.name == "Vault" | ||
assert ( | ||
a.deployments.vault.contracts.Vault.address == "0xBA12222222228d8Ba445958a75a0704d566BF2C8" | ||
) | ||
assert a.deployments.vault.contracts.BalancerHelpers.name == "BalancerHelpers" | ||
# Make sure that when we try to access a non-existing attribute, we get an error | ||
with pytest.raises(AttributeError): | ||
assert a.deployments.vault.non_existing_attribute | ||
|
||
|
||
@responses.activate | ||
def test_deployments_invalid_format(): | ||
""" | ||
Make sure that library is data agnostic and can handle different formats | ||
""" | ||
responses.add( | ||
responses.GET, | ||
"https://raw.githubusercontent.com/BalancerMaxis" | ||
"/bal_addresses/main/outputs/deployments.json", | ||
json={ | ||
"BFactory": "0x9424B1412450D0f8Fc2255FAf6046b98213B76Bd", | ||
} | ||
) | ||
responses.add( | ||
responses.GET, | ||
"https://raw.githubusercontent.com/balancer" | ||
"/balancer-deployments/master/addresses/mainnet.json", | ||
json={ | ||
"20210418-vault": { | ||
"contracts": {'name': 'Vault'}, | ||
"status": "ACTIVE" | ||
} | ||
} | ||
) | ||
a = AddrBook("mainnet") | ||
|
||
a.populate_deployments() | ||
assert a.deployments.vault.contracts.name == "Vault" | ||
|
||
|
||
@responses.activate | ||
def test_deployments_not_populated(): | ||
responses.add( | ||
responses.GET, | ||
"https://raw.githubusercontent.com/BalancerMaxis" | ||
"/bal_addresses/main/outputs/deployments.json", | ||
json={ | ||
"BFactory": "0x9424B1412450D0f8Fc2255FAf6046b98213B76Bd", | ||
} | ||
) | ||
responses.add( | ||
responses.GET, | ||
"https://raw.githubusercontent.com/balancer" | ||
"/balancer-deployments/master/addresses/mainnet.json", | ||
json={}, | ||
status=404 | ||
) | ||
a = AddrBook("mainnet") | ||
assert a.deployments is None | ||
with pytest.raises(AttributeError): | ||
assert a.deployments.vault.non_existing_attribute |