diff --git a/.default.properties b/.default.properties index 48ec2d04..3333cab5 100644 --- a/.default.properties +++ b/.default.properties @@ -165,7 +165,8 @@ Validator2Address = 0xf3549165e6AE699B73349dd81a69d005d0add92a L1DeployerAddress = 0x5EE3113aA489A61c5E17cC17f09a10218498b9BC FaucetAddress = L2GasPaymentAddress = -WethContractAddress = 1000000000000000000000000000000000000042 +L2WethContractAddress = 1000000000000000000000000000000000000042 +L1WethContractAddress = 1000000000000000000000000000000000000042 L1Abstraction = TenL1Ethereum L1NodeHostHTTP = http://l1.mainnet.ten.xyz L1NodeHostWS = ws://l1.mainnet.ten.xyz @@ -202,7 +203,8 @@ Validator2Address = 0xF7E8fb5b78dA9e37F1Ed210196e5EddbB7f868Fd L1DeployerAddress = 0x5555E184dDC7de1A1fD0FF237CcA77338cE7162D FaucetAddress = 0xA58C60cc047592DE97BF1E8d2f225Fc5D959De77 L2GasPaymentAddress = -WethContractAddress = 1000000000000000000000000000000000000042 +L2WethContractAddress = 1000000000000000000000000000000000000042 +L1WethContractAddress = 7b79995e5f793A07Bc00c21412e50Ecae098E7f9 L1Abstraction = TenL1Sepolia L1NodeHostHTTP = https://eth-sepolia.g.alchemy.com/v2 L1NodeHostWS = wss://eth-sepolia.g.alchemy.com/v2 @@ -239,7 +241,8 @@ Validator1Address = 0x53D3015D0D8Fc5Ad68484866Bb9Ae60ebb5277cb Validator2Address = 0x274Ab98679e3fb2e05a1E22c6A6fBF8fbe6515B1 L1DeployerAddress = 0xD35CE8575dC1816e560E16534eB7ea5D368255B7 L2GasPaymentAddress = -WethContractAddress = 1000000000000000000000000000000000000042 +L2WethContractAddress = 1000000000000000000000000000000000000042 +L1WethContractAddress = 7b79995e5f793A07Bc00c21412e50Ecae098E7f9 # uncomment if using geth as the L1 #L1Abstraction = TenL1Geth #L1NodeHostHTTP = http://uat-testnet-eth2network.uksouth.cloudapp.azure.com @@ -281,7 +284,8 @@ SequencerAddress = Validator1Address = Validator2Address = L2GasPaymentAddress = -WethContractAddress = 1000000000000000000000000000000000000042 +L2WethContractAddress = 1000000000000000000000000000000000000042 +L1WethContractAddress = 1000000000000000000000000000000000000042 L1DeployerAddress = L1Abstraction = TenL1Geth L1NodeHostHTTP = http://dev-testnet-eth2network-522.uksouth.cloudapp.azure.com @@ -318,7 +322,8 @@ SequencerAddress = Validator1Address = Validator2Address = L2GasPaymentAddress = -WethContractAddress = 1000000000000000000000000000000000000042 +L2WethContractAddress = 1000000000000000000000000000000000000042 +L1WethContractAddress = 1000000000000000000000000000000000000042 L1DeployerAddress = L1Abstraction = TenL1Geth L1NodeHostHTTP = http://127.0.0.1 diff --git a/src/python/ten/test/contracts/weth.py b/src/python/ten/test/contracts/weth.py index 131b7a68..8c7e7581 100644 --- a/src/python/ten/test/contracts/weth.py +++ b/src/python/ten/test/contracts/weth.py @@ -1,19 +1,17 @@ import os.path, json from pysys.constants import * -from ten.test.utils.properties import Properties class WETH: GAS_LIMIT = 3_000_000 - def __init__(self, test, web3): + def __init__(self, test, web3, address): self.test = test self.web3 = web3 self.name = 'WETH' self.symbol = 'WETH' - self.address = web3.to_checksum_address(Properties().weth_contract_address(test.env)) + self.address = address self.abi_path = os.path.join(PROJECT.root, 'src', 'solidity', 'contracts', 'weth', 'weth.json') with open(self.abi_path, 'r') as fp: self.abi = json.load(fp) self.contract = self.web3.eth.contract(address=self.address, abi=self.abi) - diff --git a/src/python/ten/test/utils/bridge.py b/src/python/ten/test/utils/bridge.py index df1b7e0c..65a8a839 100644 --- a/src/python/ten/test/utils/bridge.py +++ b/src/python/ten/test/utils/bridge.py @@ -1,5 +1,6 @@ import time, os, rlp from web3._utils.events import EventLogErrorFlags +from ten.test.utils.properties import Properties from ten.test.contracts.erc20 import ERC20Token from ten.test.contracts.weth import WETH from ten.test.contracts.bridge import WrappedERC20 @@ -85,7 +86,7 @@ def __init__(self, test, pk, name, check_funds=True): xchain = L1CrossChainMessenger(test, web3) self.management = CrossChainManagement(test, web3) super().__init__(test, web3, account, network, bridge, bus, xchain, name) - self.tokens = {'WETH': WETH(self.test, self.web3)} + self.tokens = {'WETH': WETH(self.test, self.web3, web3.to_checksum_address(Properties().l1_weth_contract_address(test.env)))} def add_token_contract(self, address, name, symbol): """Store a reference to the ERC20 token, keyed on its symbol. """ @@ -223,7 +224,7 @@ def __init__(self, test, pk, name, check_funds=True): bus = L2MessageBus(test, web3) xchain = L2CrossChainMessenger(test, web3) super().__init__(test, web3, account, network, bridge, bus, xchain, name) - self.tokens = {'WETH': WETH(self.test, self.web3)} + self.tokens = {'WETH': WETH(self.test, self.web3, web3.to_checksum_address(Properties().l2_weth_contract_address(test.env)))} def set_token_contract(self, address, name, symbol): """Store a reference to the ERC20 token, keyed on its symbol. """ diff --git a/src/python/ten/test/utils/properties.py b/src/python/ten/test/utils/properties.py index 7d8c1c84..4d8dd917 100644 --- a/src/python/ten/test/utils/properties.py +++ b/src/python/ten/test/utils/properties.py @@ -186,7 +186,9 @@ def validator1_address(self, key): return self.get('env.' + key, 'Validator1Addr def validator2_address(self, key): return self.get('env.' + key, 'Validator2Address') - def weth_contract_address(self, key): return self.get('env.' + key, 'WethContractAddress') + def l2_weth_contract_address(self, key): return self.get('env.' + key, 'L2WethContractAddress') + + def l1_weth_contract_address(self, key): return self.get('env.' + key, 'L1WethContractAddress') def l1_deployer_address(self, key): return self.get('env.'+key, 'L1DeployerAddress') diff --git a/tests/network/ten/ten_cor_047/run.py b/tests/network/ten/ten_cor_047/run.py index 3c136fbc..e3ad60b6 100644 --- a/tests/network/ten/ten_cor_047/run.py +++ b/tests/network/ten/ten_cor_047/run.py @@ -1,24 +1,30 @@ from ten.test.basetest import TenNetworkTest from ten.test.contracts.weth import WETH +from ten.test.utils.properties import Properties class PySysTest(TenNetworkTest): def execute(self): # run on the l1 - if self.is_local_ten(): - network = self.get_l1_network_connection() - web3, account = network.connect_account1(self) - self.run_for_network(network, web3, account, persist_nonce=False) + self.log.info('') + self.log.info('Running for the L1') + network = self.get_l1_network_connection() + web3, account = network.connect_account1(self) + address = web3.to_checksum_address(Properties().l1_weth_contract_address(self.env)) + self.run_for_network(network, web3, account, address, persist_nonce=False) # run on the l2 + self.log.info('') + self.log.info('Running for the L2') network = self.get_network_connection() web3, account = network.connect_account1(self) - self.run_for_network(network, web3, account, persist_nonce=True) + address = web3.to_checksum_address(Properties().l2_weth_contract_address(self.env)) + self.run_for_network(network, web3, account, address, persist_nonce=True) - def run_for_network(self, network, web3, account, persist_nonce): + def run_for_network(self, network, web3, account, address, persist_nonce): # create an instance of the weth contract wrapper and check it is deployed - weth = WETH(self, web3) + weth = WETH(self, web3, address) self.log.info('Contract address is %s' % weth.address) code = web3.eth.get_code(weth.address) @@ -33,12 +39,14 @@ def run_for_network(self, network, web3, account, persist_nonce): # deposit eth network.transact(self, web3, weth.contract.functions.deposit(), account, weth.GAS_LIMIT, persist_nonce=persist_nonce, value=100) + self.wait(2.0) deposit_balance = weth.contract.functions.balanceOf(account.address).call() self.log.info('After deposit balance is %d' % deposit_balance) self.assertTrue(deposit_balance-initial_balance == 100, assertMessage='Balance should increase by 100') # withdraw eth network.transact(self, web3, weth.contract.functions.withdraw(10), account, weth.GAS_LIMIT, persist_nonce=persist_nonce) + self.wait(2.0) withdraw_balance = weth.contract.functions.balanceOf(account.address).call() self.log.info('After withdrawal balance is %d' % withdraw_balance) self.assertTrue(withdraw_balance-deposit_balance == -10, assertMessage='Balance should decrease by 10')