Skip to content

Commit

Permalink
fix(pytests): fix rpc_finality.py (#10148)
Browse files Browse the repository at this point in the history
#9644 added a new RPC method for
sending transactions, and added unused "wait_until" arguments to the
existing ones. This change was actually not a no-op for the
"broadcast_tx_commit" method, since now that method will wait until all
transactions and descendant receipts are final, whereas the previous
behavior was closer to the new "INCLUDED" "wait_until" parameter, and we
used to just wait for the receipt outcomes to show up, but would return
before they're executed and finalized.

So fix it by making send_tx_and_wait() call the send_tx method to get
something closer to the old behavior.

Also, an unrelated problem with this test is that the "consensus" change
to the config were put in the wrong place, so that measure to decrease
the flakiness of this test wasn't actually in place
  • Loading branch information
marcelo-gonzalez authored Nov 10, 2023
1 parent 363de57 commit 777fe0f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
7 changes: 7 additions & 0 deletions pytest/lib/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ def send_tx_and_wait(self, signed_tx, timeout):
[base64.b64encode(signed_tx).decode('utf8')],
timeout=timeout)

def send_tx_rpc(self, signed_tx, timeout, wait_until='FINAL'):
return self.json_rpc('send_tx', {
'signed_tx_base64': base64.b64encode(signed_tx).decode('utf8'),
'wait_until': wait_until
},
timeout=timeout)

def get_status(self,
check_storage: bool = True,
timeout: float = 4,
Expand Down
26 changes: 12 additions & 14 deletions pytest/tests/sanity/rpc_finality.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,17 @@ def test_finality(self):
min_block_delay = 3

consensus = {
"consensus": {
"min_block_production_delay": {
"secs": min_block_delay,
"nanos": 0,
},
"max_block_production_delay": {
"secs": min_block_delay * 2,
"nanos": 0,
},
"max_block_wait_delay": {
"secs": min_block_delay * 3,
"nanos": 0,
}
"min_block_production_delay": {
"secs": min_block_delay,
"nanos": 0,
},
"max_block_production_delay": {
"secs": min_block_delay * 2,
"nanos": 0,
},
"max_block_wait_delay": {
"secs": min_block_delay * 3,
"nanos": 0,
}
}

Expand All @@ -62,7 +60,7 @@ def test_finality(self):
# this transaction will be added to the block (probably around block 5)
# and the the receipts & transfers will happen in the next block (block 6).
# This function should return as soon as block 6 arrives in node0.
logger.info(nodes[0].send_tx_and_wait(tx, timeout=10))
logger.info(nodes[0].send_tx_rpc(tx, wait_until='INCLUDED', timeout=10))
logger.info("Done")

# kill one validating node so that block cannot be finalized.
Expand Down

0 comments on commit 777fe0f

Please sign in to comment.