Skip to content

Commit

Permalink
fntest: updated all tests to at least init properly with new params s…
Browse files Browse the repository at this point in the history
…etup
  • Loading branch information
delbonis committed Oct 5, 2024
1 parent 3d04d61 commit f057b71
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 34 deletions.
14 changes: 2 additions & 12 deletions functional-tests/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,6 @@ class RethConfig(TypedDict):
reth_secret_path: str


def gen_simple_params(initdir: str) -> dict:
return utils.generate_simple_params(
initdir,
DEFAULT_BLOCK_TIME_SEC,
DEFAULT_EPOCH_SLOTS,
DEFAULT_GENESIS_TRIGGER,
DEFAULT_OPERATOR_CNT,
)


class StrataFactory(flexitest.Factory):
def __init__(self, port_range: list[int]):
super().__init__(port_range)
Expand Down Expand Up @@ -336,7 +326,7 @@ def init(self, ctx: flexitest.EnvContext) -> flexitest.LiveEnv:
# set up network params
initdir = ctx.make_service_dir("_init")
settings = self.rollup_settings or RollupParamsSettings.new_default()
params_gen_data = utils.generate_simple_params(initdir, settings, self.n_operators)
params_gen_data = generate_simple_params(initdir, settings, self.n_operators)
params = params_gen_data["params"]
# TODO also grab operator keys and launch operators

Expand Down Expand Up @@ -441,7 +431,7 @@ def init(self, ctx: flexitest.EnvContext) -> flexitest.LiveEnv:
# set up network params
initdir = ctx.make_service_dir("_init")
settings = self.rollup_settings or RollupParamsSettings.new_default()
params_gen_data = utils.generate_simple_params(initdir, settings, self.n_operators)
params_gen_data = generate_simple_params(initdir, settings, self.n_operators)
params = params_gen_data["params"]
# TODO also grab operator keys and launch operators

Expand Down
6 changes: 4 additions & 2 deletions functional-tests/fn_bitcoin_reorg_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from bitcoinlib.services.bitcoind import BitcoindClient
from flexitest.service import Service

import net_settings
from constants import FAST_BATCH_ROLLUP_PARAMS
from entry import BasicEnvConfig
from utils import (
Expand All @@ -17,13 +18,13 @@

@flexitest.register
class BitcoinReorgChecksTest(flexitest.Test):
"""This tests finalization when there is reorg on l1"""
"""This tests finalization when there is reorg on L1"""

def __init__(self, ctx: flexitest.InitContext):
ctx.set_env(
BasicEnvConfig(
0,
rollup_params=FAST_BATCH_ROLLUP_PARAMS,
rollup_settings=net_settings.get_fast_batch_settings(),
auto_generate_blocks=False,
)
)
Expand All @@ -36,6 +37,7 @@ def main(self, ctx: flexitest.RunContext):
btcrpc: BitcoindClient = btc.create_rpc()
seq_addr = seq.get_prop("address")

# FIXME change this to fetch from the params
finality_depth = FAST_BATCH_ROLLUP_PARAMS["l1_reorg_safe_depth"]

# Wait for seq
Expand Down
5 changes: 3 additions & 2 deletions functional-tests/fn_bridge_deposit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import flexitest
from bitcoinlib.services.bitcoind import BitcoindClient

import net_settings
from constants import ROLLUP_PARAMS_FOR_DEPOSIT_TX, SEQ_PUBLISH_BATCH_INTERVAL_SECS
from entry import BasicEnvConfig
from utils import wait_until
Expand All @@ -11,16 +12,16 @@
@flexitest.register
class BridgeDepositTest(flexitest.Test):
def __init__(self, ctx: flexitest.InitContext):
ctx.set_env(BasicEnvConfig(101, rollup_params=ROLLUP_PARAMS_FOR_DEPOSIT_TX))
ctx.set_env(BasicEnvConfig(101, rollup_settings=net_settings.get_fast_batch_settings()))

def main(self, ctx: flexitest.RunContext):
btc = ctx.get_service("bitcoin")
seq = ctx.get_service("sequencer")
print(ROLLUP_PARAMS_FOR_DEPOSIT_TX)

seqrpc = seq.create_rpc()
btcrpc: BitcoindClient = btc.create_rpc()

# FIXME change this to fetch from the params
amount_to_send = ROLLUP_PARAMS_FOR_DEPOSIT_TX["deposit_amount"] / 10**8
print(amount_to_send)
name = ROLLUP_PARAMS_FOR_DEPOSIT_TX["rollup_name"].encode("utf-8").hex()
Expand Down
3 changes: 2 additions & 1 deletion functional-tests/fn_client_restart.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import flexitest

import net_settings
from constants import (
ERROR_PROOF_ALREADY_CREATED,
FAST_BATCH_ROLLUP_PARAMS,
Expand All @@ -17,7 +18,7 @@ class BlockFinalizationSeqRestartTest(flexitest.Test):
"""This tests finalization when sequencer client restarts"""

def __init__(self, ctx: flexitest.InitContext):
ctx.set_env(BasicEnvConfig(101, rollup_params=FAST_BATCH_ROLLUP_PARAMS))
ctx.set_env(BasicEnvConfig(101, rollup_settings=net_settings.get_fast_batch_settings()))

def main(self, ctx: flexitest.RunContext):
seq = ctx.get_service("sequencer")
Expand Down
20 changes: 13 additions & 7 deletions functional-tests/fn_sync_l1_finalization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import flexitest

import net_settings
from constants import (
ERROR_PROOF_ALREADY_CREATED,
FAST_BATCH_ROLLUP_PARAMS,
Expand All @@ -17,13 +18,18 @@ class BlockFinalizationTest(flexitest.Test):

def __init__(self, ctx: flexitest.InitContext):
premine_blocks = 101
rollup_params = {
**FAST_BATCH_ROLLUP_PARAMS,
# Setup reasonal horizon/genesis height
"horizon_l1_height": premine_blocks - 3,
"genesis_l1_height": premine_blocks + 5,
}
ctx.set_env(BasicEnvConfig(premine_blocks, rollup_params=rollup_params))
settings = net_settings.get_fast_batch_settings()
settings.genesis_trigger = premine_blocks + 5

# TODO apply the rest of these
# **FAST_BATCH_ROLLUP_PARAMS,
# # Setup reasonal horizon/genesis height
# "horizon_l1_height": premine_blocks - 3,
# "genesis_l1_height": premine_blocks + 5,
# "proof_publish_mode": {
# "timeout": self.timeout,

ctx.set_env(BasicEnvConfig(premine_blocks, rollup_settings=settings))

def main(self, ctx: flexitest.RunContext):
seq = ctx.get_service("sequencer")
Expand Down
23 changes: 13 additions & 10 deletions functional-tests/fn_sync_l1_finalization_timeout.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import flexitest

import net_settings
from constants import (
ERROR_PROOF_ALREADY_CREATED,
FAST_BATCH_ROLLUP_PARAMS,
Expand All @@ -20,16 +21,18 @@ class BlockFinalizationTimeoutTest(flexitest.Test):
def __init__(self, ctx: flexitest.InitContext):
premine_blocks = 101
self.timeout = 5
rollup_params = {
**FAST_BATCH_ROLLUP_PARAMS,
# Setup reasonal horizon/genesis height
"horizon_l1_height": premine_blocks - 3,
"genesis_l1_height": premine_blocks + 5,
"proof_publish_mode": {
"timeout": self.timeout,
},
}
ctx.set_env(BasicEnvConfig(premine_blocks, rollup_params=rollup_params))
settings = net_settings.get_fast_batch_settings()
settings.genesis_trigger = premine_blocks + 5

# TODO apply the rest of these
# **FAST_BATCH_ROLLUP_PARAMS,
# # Setup reasonal horizon/genesis height
# "horizon_l1_height": premine_blocks - 3,
# "genesis_l1_height": premine_blocks + 5,
# "proof_publish_mode": {
# "timeout": self.timeout,

ctx.set_env(BasicEnvConfig(premine_blocks, rollup_settings=settings))

def main(self, ctx: flexitest.RunContext):
seq = ctx.get_service("sequencer")
Expand Down
1 change: 1 addition & 0 deletions functional-tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging as log
import math
import os
import subprocess
import time
from dataclasses import dataclass
from threading import Thread
Expand Down

0 comments on commit f057b71

Please sign in to comment.