forked from cerc-io/laconicd-deprecated
e1560849dd
* Set priority for eth transactions Set the tx priority to the lowest priority in the messages. fix unit tests code cleanup and spec update spec fix go lint add priority integration test add python linter job add access list tx type fix gas limit remove ledger tag, so no need to replace hid dependency fix earlier check ibc-go v5.0.0-beta1 * fix pruned node integration test * Update x/feemarket/spec/09_antehandlers.md Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
import os
|
|
import socket
|
|
import time
|
|
|
|
from eth_account import Account
|
|
from web3._utils.transactions import fill_nonce, fill_transaction_defaults
|
|
|
|
Account.enable_unaudited_hdwallet_features()
|
|
|
|
ACCOUNTS = {
|
|
"validator": Account.from_mnemonic(os.getenv("VALIDATOR1_MNEMONIC")),
|
|
"community": Account.from_mnemonic(os.getenv("COMMUNITY_MNEMONIC")),
|
|
"signer1": Account.from_mnemonic(os.getenv("SIGNER1_MNEMONIC")),
|
|
"signer2": Account.from_mnemonic(os.getenv("SIGNER2_MNEMONIC")),
|
|
}
|
|
KEYS = {name: account.key for name, account in ACCOUNTS.items()}
|
|
ADDRS = {name: account.address for name, account in ACCOUNTS.items()}
|
|
|
|
|
|
def wait_for_port(port, host="127.0.0.1", timeout=40.0):
|
|
start_time = time.perf_counter()
|
|
while True:
|
|
try:
|
|
with socket.create_connection((host, port), timeout=timeout):
|
|
break
|
|
except OSError as ex:
|
|
time.sleep(0.1)
|
|
if time.perf_counter() - start_time >= timeout:
|
|
raise TimeoutError(
|
|
"Waited too long for the port {} on host {} to start accepting "
|
|
"connections.".format(port, host)
|
|
) from ex
|
|
|
|
|
|
def fill_defaults(w3, tx):
|
|
return fill_nonce(w3, fill_transaction_defaults(w3, tx))
|
|
|
|
|
|
def sign_transaction(w3, tx, key=KEYS["validator"]):
|
|
"fill default fields and sign"
|
|
acct = Account.from_key(key)
|
|
tx["from"] = acct.address
|
|
tx = fill_defaults(w3, tx)
|
|
return acct.sign_transaction(tx)
|
|
|
|
|
|
def send_transaction(w3, tx, key=KEYS["validator"]):
|
|
signed = sign_transaction(w3, tx, key)
|
|
txhash = w3.eth.send_raw_transaction(signed.rawTransaction)
|
|
return w3.eth.wait_for_transaction_receipt(txhash)
|