Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ Validator2Address = 0xf3549165e6AE699B73349dd81a69d005d0add92a
L1DeployerAddress = 0x5EE3113aA489A61c5E17cC17f09a10218498b9BC
FaucetAddress = <not set for this environment>
L2GasPaymentAddress =
WethContractAddress = 1000000000000000000000000000000000000042
L2WethContractAddress = 1000000000000000000000000000000000000042
L1WethContractAddress = 1000000000000000000000000000000000000042
L1Abstraction = TenL1Ethereum
L1NodeHostHTTP = http://l1.mainnet.ten.xyz
L1NodeHostWS = ws://l1.mainnet.ten.xyz
Expand Down Expand Up @@ -202,7 +203,8 @@ Validator2Address = 0xF7E8fb5b78dA9e37F1Ed210196e5EddbB7f868Fd
L1DeployerAddress = 0x5555E184dDC7de1A1fD0FF237CcA77338cE7162D
FaucetAddress = 0xA58C60cc047592DE97BF1E8d2f225Fc5D959De77
L2GasPaymentAddress = <set in user.properties>
WethContractAddress = 1000000000000000000000000000000000000042
L2WethContractAddress = 1000000000000000000000000000000000000042
L1WethContractAddress = 7b79995e5f793A07Bc00c21412e50Ecae098E7f9
L1Abstraction = TenL1Sepolia
L1NodeHostHTTP = https://eth-sepolia.g.alchemy.com/v2
L1NodeHostWS = wss://eth-sepolia.g.alchemy.com/v2
Expand Down Expand Up @@ -239,7 +241,8 @@ Validator1Address = 0x53D3015D0D8Fc5Ad68484866Bb9Ae60ebb5277cb
Validator2Address = 0x274Ab98679e3fb2e05a1E22c6A6fBF8fbe6515B1
L1DeployerAddress = 0xD35CE8575dC1816e560E16534eB7ea5D368255B7
L2GasPaymentAddress = <set in user.properties>
WethContractAddress = 1000000000000000000000000000000000000042
L2WethContractAddress = 1000000000000000000000000000000000000042
L1WethContractAddress = 7b79995e5f793A07Bc00c21412e50Ecae098E7f9
# uncomment if using geth as the L1
#L1Abstraction = TenL1Geth
#L1NodeHostHTTP = http://uat-testnet-eth2network.uksouth.cloudapp.azure.com
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -318,7 +322,8 @@ SequencerAddress =
Validator1Address =
Validator2Address =
L2GasPaymentAddress =
WethContractAddress = 1000000000000000000000000000000000000042
L2WethContractAddress = 1000000000000000000000000000000000000042
L1WethContractAddress = 1000000000000000000000000000000000000042
L1DeployerAddress =
L1Abstraction = TenL1Geth
L1NodeHostHTTP = http://127.0.0.1
Expand Down
6 changes: 2 additions & 4 deletions src/python/ten/test/contracts/weth.py
Original file line number Diff line number Diff line change
@@ -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)

5 changes: 3 additions & 2 deletions src/python/ten/test/utils/bridge.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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. """
Expand Down Expand Up @@ -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. """
Expand Down
4 changes: 3 additions & 1 deletion src/python/ten/test/utils/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
22 changes: 15 additions & 7 deletions tests/network/ten/ten_cor_047/run.py
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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')
Expand Down
Loading