From 195208cb9b7add79ed756de781d49d010ada5349 Mon Sep 17 00:00:00 2001 From: Hieu Nguyen Date: Wed, 24 Jul 2024 16:56:37 +0300 Subject: [PATCH] Fix failing tests due to inter node delay change --- eth_defi/confirmation.py | 21 +++++++++------------ tests/rpc/test_out_of_gas.py | 10 +++++----- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/eth_defi/confirmation.py b/eth_defi/confirmation.py index ae7faac3..048e02f6 100644 --- a/eth_defi/confirmation.py +++ b/eth_defi/confirmation.py @@ -8,27 +8,24 @@ import datetime import logging import time -from _decimal import Decimal -from typing import Dict, List, Set, Union, cast, Collection, TypeAlias +from typing import Collection, Dict, List, Set, TypeAlias, Union, cast +from _decimal import Decimal from eth_account.datastructures import SignedTransaction -from eth_typing import HexStr, Address - -from eth_defi.provider.anvil import mine -from eth_defi.provider.named import get_provider_name +from eth_typing import Address, HexStr from hexbytes import HexBytes from web3 import Web3 from web3.exceptions import TransactionNotFound +from web3.providers import BaseProvider from eth_defi.hotwallet import SignedTransactionWithNonce +from eth_defi.provider.anvil import mine +from eth_defi.provider.fallback import FallbackProvider, get_fallback_provider +from eth_defi.provider.named import get_provider_name from eth_defi.timestamp import get_latest_block_timestamp from eth_defi.tx import decode_signed_transaction -from eth_defi.provider.fallback import FallbackProvider, get_fallback_provider -from web3.providers import BaseProvider - from eth_defi.utils import to_unix_timestamp - logger = logging.getLogger(__name__) @@ -196,7 +193,7 @@ def wait_transactions_to_complete( logger.warning( "Timeout warning threshold %s reached when trying to confirm txs, still trying:\n%s", node_switch_timeout, - unconfirmed_txs + unconfirmed_txs, ) provider.switch_provider() next_node_switch = datetime.datetime.utcnow() + node_switch_timeout @@ -600,7 +597,7 @@ def wait_and_broadcast_multiple_nodes( # Initial broadcast of txs for tx in txs: try: - _broadcast_multiple_nodes(providers, tx, inter_node_delay=inter_node_delay,) + _broadcast_multiple_nodes(providers, tx) last_exception = None except NonRetryableBroadcastException: # Don't try to handle diff --git a/tests/rpc/test_out_of_gas.py b/tests/rpc/test_out_of_gas.py index 98687b85..4214ab07 100644 --- a/tests/rpc/test_out_of_gas.py +++ b/tests/rpc/test_out_of_gas.py @@ -1,16 +1,16 @@ """Out of gas tests.""" + import os import pytest - from eth_account import Account -from web3 import Web3, HTTPProvider +from web3 import HTTPProvider, Web3 -from eth_defi.confirmation import wait_and_broadcast_multiple_nodes, OutOfGasFunds -from eth_defi.gas import estimate_gas_fees, apply_gas +from eth_defi.confirmation import OutOfGasFunds, wait_and_broadcast_multiple_nodes +from eth_defi.gas import apply_gas, estimate_gas_fees from eth_defi.hotwallet import HotWallet from eth_defi.provider.multi_provider import create_multi_provider_web3 -from eth_defi.token import fetch_erc20_details, TokenDetails +from eth_defi.token import TokenDetails, fetch_erc20_details from eth_defi.uniswap_v2.deployment import UniswapV2Deployment, fetch_deployment JSON_RPC_POLYGON = os.environ.get("JSON_RPC_POLYGON", "https://polygon-rpc.com")