Skip to content

Commit

Permalink
remove unused function
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Sep 20, 2024
1 parent 3c8be96 commit a9253af
Showing 1 changed file with 1 addition and 43 deletions.
44 changes: 1 addition & 43 deletions testground/benchmark/benchmark/sendtx.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import asyncio
import time

import aiohttp
import ujson
import web3
from eth_account import Account

from .utils import gen_account, send_transaction
from .utils import gen_account

GAS_PRICE = 1000000000
CHAIN_ID = 777
Expand All @@ -25,45 +22,6 @@ def test_tx(nonce: int):
}


def sendtx(w3: web3.Web3, acct: Account, tx_amount: int):
initial_nonce = w3.eth.get_transaction_count(acct.address)
print(
"test begin, address:",
acct.address,
"balance:",
w3.eth.get_balance(acct.address),
"nonce:",
initial_nonce,
)

nonce = initial_nonce
while nonce < initial_nonce + tx_amount:
try:
send_transaction(w3, test_tx(nonce), acct, wait=False)
except ValueError as e:
msg = str(e)
if "invalid nonce" in msg:
print("invalid nonce and retry", nonce)
time.sleep(1)
continue
if "tx already in mempool" not in msg:
raise

nonce += 1

if nonce % 100 == 0:
print(f"{acct.address} sent {nonce} transactions")

print(
"test end, address:",
acct.address,
"balance:",
w3.eth.get_balance(acct.address),
"nonce:",
w3.eth.get_transaction_count(acct.address),
)


def prepare_txs(global_seq, num_accounts, num_txs):
accounts = [gen_account(global_seq, i + 1) for i in range(num_accounts)]
txs = []
Expand Down

0 comments on commit a9253af

Please sign in to comment.