Skip to content

Commit

Permalink
fntest: shortened epoch length, added new wait_until_checkpoint uti…
Browse files Browse the repository at this point in the history
…l fn
  • Loading branch information
delbonis committed Dec 3, 2024
1 parent 63d6362 commit 6d8d186
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion functional-tests/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 11 additions & 8 deletions functional-tests/fn_bridge_deposit_happy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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):
"""
Expand All @@ -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()
Expand Down Expand Up @@ -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}")
Expand Down
13 changes: 13 additions & 0 deletions functional-tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6d8d186

Please sign in to comment.