From 1038b4201505d3bd61c33349118182759018945c Mon Sep 17 00:00:00 2001 From: Trey Del Bonis Date: Mon, 2 Dec 2024 19:05:59 -0500 Subject: [PATCH] fntest: shortened epoch length, added new `wait_until_checkpoint` util fn --- functional-tests/constants.py | 2 +- functional-tests/fn_bridge_deposit_happy.py | 19 +++++++++++-------- functional-tests/utils.py | 13 +++++++++++++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/functional-tests/constants.py b/functional-tests/constants.py index 4719141bc..736f346a7 100644 --- a/functional-tests/constants.py +++ b/functional-tests/constants.py @@ -26,7 +26,7 @@ # Network times and stuff DEFAULT_BLOCK_TIME_SEC = 1 -DEFAULT_EPOCH_SLOTS = 64 +DEFAULT_EPOCH_SLOTS = 16 DEFAULT_GENESIS_TRIGGER_HT = 5 DEFAULT_OPERATOR_CNT = 2 DEFAULT_PROOF_TIMEOUT = 5 # Secs diff --git a/functional-tests/fn_bridge_deposit_happy.py b/functional-tests/fn_bridge_deposit_happy.py index 4e8fdb1d1..6a9d01a9f 100644 --- a/functional-tests/fn_bridge_deposit_happy.py +++ b/functional-tests/fn_bridge_deposit_happy.py @@ -5,7 +5,7 @@ from strata_utils import deposit_request_transaction, drain_wallet from constants import DEFAULT_ROLLUP_PARAMS -from utils import get_bridge_pubkey, get_logger +from utils import get_bridge_pubkey, get_logger, wait_until_checkpoint @flexitest.register @@ -55,8 +55,8 @@ def make_drt(self, ctx: flexitest.RunContext, el_address, musig_bridge_pk): seq = ctx.get_service("sequencer") btcrpc: BitcoindClient = btc.create_rpc() btc_url = btcrpc.base_url - btc_user = btc.props["rpc_user"] - btc_password = btc.props["rpc_password"] + btc_user = btc.get_prop("rpc_user") + btc_password = btc.get_prop("rpc_password") seq_addr = seq.get_prop("address") # Create the deposit request transaction @@ -79,7 +79,10 @@ def make_drt(self, ctx: flexitest.RunContext, el_address, musig_bridge_pk): # time to mature DT btcrpc.proxy.generatetoaddress(6, seq_addr) - time.sleep(3) + + # time for the deposit inclusion + timeout = 70 # TODO needs to be until the end of the epoch + wait_until_checkpoint(seq.create_rpc(), timeout) def drain_wallet(self, ctx: flexitest.RunContext): """ @@ -89,8 +92,8 @@ def drain_wallet(self, ctx: flexitest.RunContext): seq = ctx.get_service("sequencer") btcrpc: BitcoindClient = btc.create_rpc() btc_url = btcrpc.base_url - btc_user = btc.props["rpc_user"] - btc_password = btc.props["rpc_password"] + btc_user = btc.get_prop("rpc_user") + btc_password = btc.get_prop("rpc_password") seq_addr = seq.get_prop("address") tx = bytes(drain_wallet(seq_addr, btc_url, btc_user, btc_password)).hex() @@ -122,8 +125,8 @@ def test_deposit( rethrpc = reth.create_rpc() btc_url = btcrpc.base_url - btc_user = btc.props["rpc_user"] - btc_password = btc.props["rpc_password"] + btc_user = btc.get_prop("rpc_user") + btc_password = btc.get_prop("rpc_password") self.logger.debug(f"BTC URL: {btc_url}") self.logger.debug(f"BTC user: {btc_user}") diff --git a/functional-tests/utils.py b/functional-tests/utils.py index b18a082ff..9169cf87a 100644 --- a/functional-tests/utils.py +++ b/functional-tests/utils.py @@ -102,6 +102,19 @@ def wait_until_with_value( raise AssertionError(error_with) +def wait_until_checkpoint(seqrpc, timeout: int = 5, step: float = 2): + """Waits until the current checkpoint index increases.""" + first_ckpt_idx = seqrpc.strata_getLatestCheckpointIndex() + + def _f(): + status = seqrpc.strata_syncStatus() + print("waiting for epoch, at chain tip slot", status) + cur_ckpt_index = seqrpc.strata_getLatestCheckpointIndex() + return cur_ckpt_idx > first_ckpt_idx + + wait_until_with_value(_f, lambda v: v, "Epoch never finalized", timeout, step) + + @dataclass class ManualGenBlocksConfig: btcrpc: BitcoindClient