Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
Log address as hex in update_abi (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau authored Nov 15, 2022
1 parent 1254a9a commit 52f58f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/nile/deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ def update_abi(address_or_alias, abi, network):
identifiers = aliases

if address_or_alias in identifiers:
logging.info(f"📦 Updating deployment {address_or_alias} in {file}")

# Save address as hex
address = hex_address(address)
logging.info(f"📦 Updating {address} in {file}")
replacement = f"{address}:{abi}"
if len(aliases) > 0:
replacement += ":" + ":".join(str(x) for x in aliases)
Expand Down
14 changes: 12 additions & 2 deletions tests/test_deployments.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""Tests for deployments file."""
import logging

import pytest

from nile.common import DECLARATIONS_FILENAME, DEPLOYMENTS_FILENAME
from nile.deployments import register, register_class_hash, unregister, update_abi
from nile.utils import hex_class_hash, normalize_number
from nile.utils import hex_address, hex_class_hash, normalize_number

LOCALHOST = "localhost"

Expand Down Expand Up @@ -81,7 +83,7 @@ def tmp_working_dir(monkeypatch, tmp_path):
),
],
)
def test_update_deployment(address_or_alias, abi, expected_lines):
def test_update_deployment(address_or_alias, abi, expected_lines, caplog):
register(normalize_number(A_ADDR), A_ABI, LOCALHOST, f"{A_ALIAS}:{A_ALIAS_ALT}")
register(normalize_number(B_ADDR), B_ABI, LOCALHOST, B_ALIAS)
register(normalize_number(C_ADDR), C_ABI, LOCALHOST, None)
Expand All @@ -90,8 +92,16 @@ def test_update_deployment(address_or_alias, abi, expected_lines):
lines = fp.readlines()
assert len(lines) == 3

# make logs visible to test
logging.getLogger().setLevel(logging.INFO)

update_abi(address_or_alias, abi, LOCALHOST)

identifier = address_or_alias
if type(address_or_alias) == int:
identifier = hex_address(address_or_alias)
assert f"Updating {identifier} in {LOCALHOST}.{DEPLOYMENTS_FILENAME}"

with open(f"{LOCALHOST}.{DEPLOYMENTS_FILENAME}", "r") as fp:
lines = fp.readlines()
assert len(lines) == 3
Expand Down

0 comments on commit 52f58f5

Please sign in to comment.