Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
fix test priority
Browse files Browse the repository at this point in the history
  • Loading branch information
ramacarlucho committed Nov 24, 2022
1 parent 91056b4 commit 20094cd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/integration_tests/test_priority.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import sys

from web3.exceptions import TimeExhausted

from .network import Ethermint
from .utils import ADDRS, KEYS, eth_to_bech32, sign_transaction, wait_for_new_blocks

Expand Down Expand Up @@ -27,6 +29,17 @@ def tx_priority(tx, base_fee):
return (tx["gasPrice"] - base_fee) // PRIORITY_REDUCTION


def send_signed_txs(w3, signed, i=0):
if i > 3:
return TimeExhausted
txhashes = [w3.eth.send_raw_transaction(tx.rawTransaction) for tx in signed]
try:
return [w3.eth.wait_for_transaction_receipt(txhash, timeout=20)
for txhash in txhashes]
except TimeExhausted:
return send_signed_txs(w3, signed, ++i)


def test_priority(ethermint: Ethermint):
"""
test priorities of different tx types
Expand Down Expand Up @@ -98,9 +111,8 @@ def test_priority(ethermint: Ethermint):
signed = [sign_transaction(w3, tx, key=KEYS[sender]) for sender, tx in test_cases]
# send the txs from low priority to high,
# but the later sent txs should be included earlier.
txhashes = [w3.eth.send_raw_transaction(tx.rawTransaction) for tx in signed]

receipts = [w3.eth.wait_for_transaction_receipt(txhash) for txhash in txhashes]
receipts = send_signed_txs(w3, signed)
print(receipts)
assert all(receipt.status == 1 for receipt in receipts), "expect all txs success"

Expand Down

0 comments on commit 20094cd

Please sign in to comment.