19
19
from zksync2 .signer .eth_signer import PrivateKeyEthSigner
20
20
from tests .contracts .utils import contract_path
21
21
from zksync2 .transaction .transaction_builders import TxFunctionCall , TxCreateContract , TxCreate2Contract , TxWithdraw
22
- from test_config import ZKSYNC_TEST_URL , ETH_TEST_URL , PRIVATE_KEY2 , PRIVATE_KEY_BOB
22
+ from test_config import LOCAL_ENV , PRIVATE_KEY2 , PRIVATE_KEY_BOB , EnvType
23
23
24
24
25
25
def generate_random_salt () -> bytes :
@@ -31,20 +31,19 @@ class ZkSyncWeb3Tests(TestCase):
31
31
ETH_TEST_NET_AMOUNT_BALANCE = Decimal (1 )
32
32
33
33
def setUp (self ) -> None :
34
- self .web3 = ZkSyncBuilder .build (ZKSYNC_TEST_URL )
34
+ self .env = LOCAL_ENV
35
+ self .web3 = ZkSyncBuilder .build (self .env .zksync_server )
35
36
self .account : LocalAccount = Account .from_key (PRIVATE_KEY2 )
36
37
self .chain_id = self .web3 .zksync .chain_id
37
38
self .signer = PrivateKeyEthSigner (self .account , self .chain_id )
38
39
self .counter_address = None
39
40
self .test_tx_hash = None
40
41
# INFO: use deploy_erc20_token_builder to get new address
41
- # self.some_erc20_address = Web3.to_checksum_address("0x37b96512962FC7773E06237116BE693Eb2b3cD51")
42
- self .some_erc20_address = Web3 .to_checksum_address ("0xd782e03F4818A7eDb0bc5f70748F67B4e59CdB33" )
43
- # https://goerli.explorer.zksync.io/address/0xd782e03F4818A7eDb0bc5f70748F67B4e59CdB33#contract
44
- # Mint from site:
45
- # https://goerli.explorer.zksync.io/tx/0xad2f582bed2ca5a35db47db21f0dc06eba29273531abc1bc32b8a9112520a3d2
46
- # https://goerli.explorer.zksync.io/tx/0x7b34f26f92eb86e5d0e0f5afd19dd279de90d771b38a9e5f7efb26d791b52423
47
-
42
+ if self .env .type == EnvType .LOCAL_HOST :
43
+ self .some_erc20_address = Web3 .to_checksum_address ("0x37b96512962FC7773E06237116BE693Eb2b3cD51" )
44
+ if self .env .type == EnvType .TESTNET :
45
+ # https://goerli.explorer.zksync.io/address/0xd782e03F4818A7eDb0bc5f70748F67B4e59CdB33#contract
46
+ self .some_erc20_address = Web3 .to_checksum_address ("0xd782e03F4818A7eDb0bc5f70748F67B4e59CdB33" )
48
47
self .ERC20_Token = Token (l1_address = ADDRESS_DEFAULT ,
49
48
l2_address = self .some_erc20_address ,
50
49
symbol = "SERC20" ,
@@ -53,7 +52,7 @@ def setUp(self) -> None:
53
52
@skip ("Integration test, used for develop purposes only" )
54
53
def test_send_money (self ):
55
54
gas_limit = 21000
56
- web3 = Web3 (Web3 .HTTPProvider (ETH_TEST_URL ))
55
+ web3 = Web3 (Web3 .HTTPProvider (self . env . eth_server ))
57
56
web3 .middleware_onion .inject (geth_poa_middleware , layer = 0 )
58
57
account = web3 .eth .accounts [0 ]
59
58
transaction : TxParams = {
@@ -72,7 +71,7 @@ def test_get_l1_balance(self):
72
71
"""
73
72
INFO: For minting use: https://goerli-faucet.pk910.de
74
73
"""
75
- eth_web3 = Web3 (Web3 .HTTPProvider (ETH_TEST_URL ))
74
+ eth_web3 = Web3 (Web3 .HTTPProvider (self . env . eth_server ))
76
75
eth_balance = eth_web3 .eth .get_balance (self .account .address )
77
76
print (f"Eth: balance: { Web3 .from_wei (eth_balance , 'ether' )} " )
78
77
self .assertNotEqual (eth_balance , 0 )
@@ -226,7 +225,7 @@ def mint_some_erc20(self, amount: int):
226
225
nonce = self .web3 .zksync .get_transaction_count (self .account .address , EthBlockParams .LATEST .value )
227
226
gas_price = self .web3 .zksync .gas_price
228
227
229
- args = (self .account .address , amount )
228
+ args = (self .account .address , self . ERC20_Token . to_int ( amount ) )
230
229
call_data = some_erc20_encoder .encode_method (fn_name = 'mint' , args = args )
231
230
func_call = TxFunctionCall (chain_id = self .chain_id ,
232
231
nonce = nonce ,
@@ -348,7 +347,7 @@ def test_estimate_gas_withdraw(self):
348
347
# @skip("Integration test, used for develop purposes only")
349
348
def test_withdraw (self ):
350
349
amount = 0.1
351
- eth_web3 = Web3 (Web3 .HTTPProvider (ETH_TEST_URL ))
350
+ eth_web3 = Web3 (Web3 .HTTPProvider (self . env . eth_server ))
352
351
eth_web3 .middleware_onion .inject (geth_poa_middleware , layer = 0 )
353
352
354
353
eth_balance = eth_web3 .eth .get_balance (self .account .address )
0 commit comments