Skip to content

Commit

Permalink
Problem: tx inclusion logic when block gas limit exceeded is not test…
Browse files Browse the repository at this point in the history
…ed (#380)

Closes: #379
Solution:
- add integration test to test tx inclusion logic when block gas limit exceeded.
  • Loading branch information
yihuang authored Mar 11, 2022
1 parent 847d73e commit 58085b5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,3 +598,39 @@ def test_contract(cronos):
# call contract
greeter_call_result = contract.caller.greet()
assert "world" == greeter_call_result


def test_tx_inclusion(cronos):
"""
- send multiple heavy transactions at the same time.
- check they are included in consecutively blocks without failure.
"""
w3 = cronos.w3
# bigger than block_gas_limit/2, so at most one tx in a block
tx_gas_limit = 80000000
amount = 1000
# use different sender accounts to be able be send concurrently
signed_txs = []
for account in ["validator", "community", "signer1", "signer2"]:
signed_txs.append(
sign_transaction(
w3,
{
"to": ADDRS["validator"],
"value": amount,
"gas": tx_gas_limit,
},
KEYS[account],
)
)

for signed in signed_txs:
w3.eth.send_raw_transaction(signed.rawTransaction)

receipts = [
w3.eth.wait_for_transaction_receipt(signed.hash) for signed in signed_txs
]

# the transactions should be included in differnt but consecutive blocks
for receipt, next_receipt in zip(receipts, receipts[1:]):
assert next_receipt.blockNumber == receipt.blockNumber + 1
2 changes: 1 addition & 1 deletion integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def post_init(path, base_port, config):
ini_path = path / chain_id / SUPERVISOR_CONFIG_FILE
ini = configparser.RawConfigParser()
ini.read_file(ini_path.open())
reg = re.compile(fr"^program:{chain_id}-node(\d+)")
reg = re.compile(rf"^program:{chain_id}-node(\d+)")
for section in ini.sections():
m = reg.match(section)
if m:
Expand Down

0 comments on commit 58085b5

Please sign in to comment.