Skip to content

Commit

Permalink
fix broken tests. (#91)
Browse files Browse the repository at this point in the history
* fix broken tests.

* fix broken tests.

---------

Co-authored-by: BIP Bot <[email protected]>
  • Loading branch information
Tritium-VLK and BIP Bot authored Jul 29, 2023
1 parent 9a0a50d commit 9da8f16
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
22 changes: 15 additions & 7 deletions bal_addresses/addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def populate_extras(self) -> None:
if chain_extras.ok:
self._extras = Munch.fromDict(self.checksum_address_dict(chain_extras.json()))
else:
print(f"Warning: No extras for chain {self.chain}, multisigs must be added in extras/chain.json")
print(f"Warning: No extras for chain {self.chain}, extras must be added in extras/chain.json")
self._extras = Munch.fromDict({})
def populate_eoas(self) -> None:
eoas = requests.get(
Expand Down Expand Up @@ -217,12 +217,16 @@ def checksum_address_dict(addresses):
"""
checksummed = {}
for k, v in addresses.items():
if isinstance(v, str):
checksummed[k] = Web3.toChecksumAddress(v)
elif isinstance(v, dict):
if isinstance(v, dict):
checksummed[k] = checksum_address_dict(v)
elif isinstance(v, str):
try:
checksummed[k] = Web3.toChecksumAddress(v)
except:
checksummed[k] = v
else:
print(k, v, "formatted incorrectly")
checksummed[k] = v
return checksummed

def flatten_dict(self, d, parent_key='', sep='/'):
Expand Down Expand Up @@ -259,10 +263,14 @@ def checksum_address_dict(addresses):
"""
checksummed = {}
for k, v in addresses.items():
if isinstance(v, str):
checksummed[k] = Web3.toChecksumAddress(v)
elif isinstance(v, dict):
if isinstance(v, dict):
checksummed[k] = checksum_address_dict(v)
elif isinstance(v, str):
try:
checksummed[k] = Web3.toChecksumAddress(v)
except:
checksummed[k] = v
else:
print(k, v, "formatted incorrectly")
checksummed[k] = v
return checksummed
7 changes: 4 additions & 3 deletions tests/test_addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ def test_deployments_invalid_format():
a.populate_deployments()
assert a.deployments.vault.contracts.name == "Vault"
a.populate_extras()
print(a.extras.vault.status)
assert a.extras.vault.status == "ACTIVE"
a.populate_multisigs()
assert a.multisigs.status == "ACTIVE"
assert str(a.multisigs.status) == "ACTIVE"


@responses.activate
Expand Down Expand Up @@ -172,9 +173,9 @@ def test_deployments_not_populated():
assert a.deployments is None
with pytest.raises(AttributeError):
assert a.deployments.vault.non_existing_attribute
assert a.extras is None
assert a.extras == {}
with pytest.raises(AttributeError):
assert a.extras.non_existing_attribute
assert a.multisigs is None
assert a.multisigs == {}
with pytest.raises(AttributeError):
assert a.multisigs.non_existing_attribute

0 comments on commit 9da8f16

Please sign in to comment.