def test_3_confirm_and_finalize_eth_tx(web3_provider, ethr_signers,
                                       configuration: Config):
    # To allow the new EthrSigner to "catch up", we start it after the event submission event in Ethereum
    secret_token_addr = TokenPairing.objects().get(src_network="Ethereum",
                                                   src_coin="ETH").dst_address
    prev_bal = web3_provider.eth.getBalance(zero_address, "latest")
    prev_bal_fee = web3_provider.eth.getBalance(PAYABLE_ADDRESS, "latest")
    ethr_signers[-1].start()
    sleep(1)
    assert increase_block_number(web3_provider,
                                 configuration.eth_confirmations)

    sleep(configuration.sleep_interval * 5)
    # Validate the tx is confirmed in the smart contract
    last_nonce = SwapTrackerObject.last_processed(secret_token_addr)
    # ethr_signers[-1].signer.multisig_contract.contract.functions.confirmations(last_nonce,
    #                                                                            ethr_signers[-1].account).call()

    assert last_nonce >= 0

    bal_fee = web3_provider.eth.getBalance(PAYABLE_ADDRESS, "latest")
    assert bal_fee > prev_bal_fee

    bal = web3_provider.eth.getBalance(zero_address, "latest")
    assert bal > prev_bal

    last_nonce = SwapTrackerObject.last_processed(secret_token_addr)

    swap = Swap.objects().get(src_tx_hash=f'{last_nonce}|{secret_token_addr}')
    assert swap.status == Status.SWAP_CONFIRMED
    configuration.eth_start_block = web3_provider.eth.blockNumber
Exemple #2
0
def ethr_leader(multisig_account, configuration: Config, web3_provider,
                erc20_token, multisig_wallet, ether_accounts):
    configuration.leader_key = ether_accounts[0].key
    configuration.leader_acc_addr = normalize_address(
        ether_accounts[0].address)
    configuration.eth_start_block = web3_provider.eth.blockNumber

    # token_map = configuration["token_map_scrt"]
    signer = LocalCryptoStore(private_key=configuration.leader_key,
                              account=configuration.leader_acc_addr)
    leader = EtherLeader(multisig_wallet,
                         signer,
                         dst_network="Secret",
                         config=configuration)

    leader.start()
    yield leader
    leader.stop()