-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75d2e85
commit 52582c2
Showing
11 changed files
with
120 additions
and
107 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
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
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
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 |
---|---|---|
@@ -1,32 +1,47 @@ | ||
import os | ||
import sys | ||
from subprocess import Popen | ||
|
||
import boa | ||
import pytest | ||
from boa.rpc import EthereumRPC | ||
from eth_account import Account | ||
|
||
from boa_zksync.environment import ZksyncEnv | ||
from boa_zksync.util import find_free_port, wait_url, stop_subprocess | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def rpc(era_test_node): | ||
return EthereumRPC(era_test_node) | ||
|
||
def zksync_env(era_test_node, account): | ||
old_env = boa.env | ||
boa.set_zksync_env(era_test_node) | ||
boa.env.add_account(account) | ||
yield boa.env | ||
boa.set_env(old_env) | ||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
def zksync_env(rpc, account): | ||
env = ZksyncEnv(rpc) | ||
env.add_account(account) | ||
with boa.swap_env(env): | ||
yield env | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def cleanup_env(zksync_env): | ||
with zksync_env.anchor(): | ||
yield | ||
@pytest.fixture(scope="module") | ||
def zksync_fork_env(account): | ||
old_env = boa.env | ||
fork_url = os.getenv("FORK_URL", "https://sepolia.era.zksync.dev") | ||
boa.set_zksync_fork(fork_url) | ||
boa.env.add_account(account) | ||
yield boa.env | ||
boa.set_env(old_env) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def account(): | ||
return Account.from_key( | ||
"0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e" | ||
) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def era_test_node(): | ||
era_port = find_free_port() | ||
era_node = Popen( | ||
["era_test_node", "--show-calls", "user", "--port", f"{era_port}", "run"], | ||
stdout=sys.stdout, | ||
stderr=sys.stderr, | ||
) | ||
yield wait_url(f"http://localhost:{era_port}") | ||
stop_subprocess(era_node) |
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,21 @@ | ||
import os | ||
import sys | ||
from subprocess import Popen | ||
|
||
import boa | ||
import pytest | ||
|
||
from boa_zksync.util import find_free_port, stop_subprocess, wait_url | ||
|
||
|
||
def test_dummy_contract(zksync_fork_env): | ||
code = """ | ||
@external | ||
@view | ||
def foo() -> bool: | ||
return True | ||
""" | ||
c = boa.loads_partial(code).at("0xB27cCfd5909f46F5260Ca01BA27f591868D08704") | ||
assert c.foo() is True | ||
c = boa.loads(code) | ||
assert c.foo() is True |
Oops, something went wrong.