def source_ethereum_address(is_ropsten_testnet, smart_contracts_dir): """account with some starting eth that can be transferred out""" addr = test_utilities.get_optional_env_var("ETHEREUM_ADDRESS", "") if is_ropsten_testnet: assert addr return addr else: if addr: logging.debug("using ETHEREUM_ADDRESS provided for source_ethereum_address") return addr else: result = test_utilities.ganache_owner_account(smart_contracts_dir) logging.debug( f"Using source_ethereum_address {result} from ganache_owner_account. (Set ETHEREUM_ADDRESS env var to set it manually)") assert result return result
def source_ethereum_address(is_ropsten_testnet, smart_contracts_dir): """ Account with some starting eth that can be transferred out. Our test wallet can only use one address/privatekey combination, so if you set OPERATOR_ACCOUNT you have to set ETHEREUM_PRIVATE_KEY to the operator private key """ addr = test_utilities.get_optional_env_var("ETHEREUM_ADDRESS", "") if addr: logging.debug("using ETHEREUM_ADDRESS provided for source_ethereum_address") return addr if is_ropsten_testnet: # Ropsten requires that you manually set the ETHEREUM_ADDRESS environment variable assert addr result = test_utilities.ganache_owner_account(smart_contracts_dir) logging.debug( f"Using source_ethereum_address {result} from ganache_owner_account. (Set ETHEREUM_ADDRESS env var to set it manually)") assert result return result
def operator_address(smart_contracts_dir): return test_utilities.get_optional_env_var("OPERATOR_ADDRESS", test_utilities.ganache_owner_account(smart_contracts_dir))
from functools import lru_cache from json import JSONDecodeError import pytest import burn_lock_functions from burn_lock_functions import EthereumToSifchainTransferRequest from integration_env_credentials import sifchain_cli_credentials_for_test import test_utilities from test_utilities import get_required_env_var, get_shell_output, SifchaincliCredentials, amount_in_wei, \ get_optional_env_var, ganache_owner_account smart_contracts_dir = get_required_env_var("SMART_CONTRACTS_DIR") ethereum_address = get_optional_env_var( "ETHEREUM_ADDRESS", ganache_owner_account(smart_contracts_dir)) def build_request( ) -> (EthereumToSifchainTransferRequest, SifchaincliCredentials): new_account_key = get_shell_output("uuidgen") credentials = sifchain_cli_credentials_for_test(new_account_key) new_addr = burn_lock_functions.create_new_sifaddr(credentials=credentials, keyname=new_account_key) credentials.from_key = new_addr["name"] request = EthereumToSifchainTransferRequest( sifchain_address=new_addr["address"], smart_contracts_dir=smart_contracts_dir, ethereum_address=ethereum_address, ethereum_private_key_env_var="ETHEREUM_PRIVATE_KEY", bridgebank_address=get_required_env_var("BRIDGE_BANK_ADDRESS"),
from test_utilities import get_required_env_var, SifchaincliCredentials, get_optional_env_var, \ ganache_owner_account logging.basicConfig( level=logging.DEBUG, format="%(asctime)s [%(levelname)s] %(message)s", handlers=[logging.StreamHandler(sys.stdout)] ) logging.debug("starting") smart_contracts_dir = get_required_env_var("SMART_CONTRACTS_DIR") ethereum_address = get_optional_env_var( "ETHEREUM_ADDRESS", ganache_owner_account(smart_contracts_dir) ) def build_request() -> (EthereumToSifchainTransferRequest, SifchaincliCredentials): new_account_key = 'user1' credentials = sifchain_cli_credentials_for_test(new_account_key) new_addr = burn_lock_functions.create_new_sifaddr(credentials=credentials, keyname=new_account_key) credentials.from_key = new_addr["name"] request = EthereumToSifchainTransferRequest( sifchain_address=new_addr["address"], smart_contracts_dir=smart_contracts_dir, ethereum_address=ethereum_address, ethereum_private_key_env_var="ETHEREUM_PRIVATE_KEY", bridgebank_address=get_required_env_var("BRIDGE_BANK_ADDRESS"), ethereum_network=(os.environ.get("ETHEREUM_NETWORK") or ""),