forked from cerc-io/laconicd-deprecated
fix: align empty account result for old blocks as ethereum (#1484)
* align result account as ethereum * add test_get_transaction_count * add change doc * sync gomod2nix * Apply suggestions from code review * crosscheck with ws & geth * sync gomod2nix * Update rpc/backend/utils.go * use session provider Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
co-authored by
Federico Kunze Küllmer
parent
f7f1e1c18c
commit
f4c7be2efc
@@ -0,0 +1,32 @@
|
||||
import os
|
||||
|
||||
from eth_account import Account
|
||||
|
||||
from .utils import ADDRS, w3_wait_for_new_blocks
|
||||
|
||||
|
||||
def test_get_transaction_count(ethermint_rpc_ws, geth):
|
||||
for p in [ethermint_rpc_ws, geth]:
|
||||
w3 = p.w3
|
||||
blk = hex(w3.eth.block_number)
|
||||
sender = ADDRS["validator"]
|
||||
|
||||
# derive a new address
|
||||
account_path = "m/44'/60'/0'/0/1"
|
||||
mnemonic = os.getenv("COMMUNITY_MNEMONIC")
|
||||
receiver = (Account.from_mnemonic(mnemonic, account_path=account_path)).address
|
||||
n0 = w3.eth.get_transaction_count(receiver, blk)
|
||||
# ensure transaction send in new block
|
||||
w3_wait_for_new_blocks(w3, 1, sleep=0.1)
|
||||
txhash = w3.eth.send_transaction(
|
||||
{
|
||||
"from": sender,
|
||||
"to": receiver,
|
||||
"value": 1000,
|
||||
}
|
||||
)
|
||||
receipt = w3.eth.wait_for_transaction_receipt(txhash)
|
||||
assert receipt.status == 1
|
||||
[n1, n2] = [w3.eth.get_transaction_count(receiver, b) for b in [blk, "latest"]]
|
||||
assert n0 == n1
|
||||
assert n0 == n2
|
||||
@@ -63,10 +63,10 @@ def wait_for_port(port, host="127.0.0.1", timeout=40.0):
|
||||
) from ex
|
||||
|
||||
|
||||
def w3_wait_for_new_blocks(w3, n):
|
||||
def w3_wait_for_new_blocks(w3, n, sleep=0.5):
|
||||
begin_height = w3.eth.block_number
|
||||
while True:
|
||||
time.sleep(0.5)
|
||||
time.sleep(sleep)
|
||||
cur_height = w3.eth.block_number
|
||||
if cur_height - begin_height >= n:
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user