Skip to content

Commit

Permalink
fixe tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouziel committed Jan 16, 2025
1 parent a3a2bdf commit c43fa92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion counterparty-core/counterpartycore/lib/cli/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from counterpartycore.lib.api import apiserver as api_v2
from counterpartycore.lib.api import apiv1, dbbuilder
from counterpartycore.lib.cli import bootstrap, log
from counterpartycore.lib.ledger.currentstate import CurrentState
from counterpartycore.lib.parser import blocks, check, follow
from counterpartycore.lib.utils import database, helpers

Expand Down Expand Up @@ -54,7 +55,9 @@ def initialise(*args, **kwargs):
max_log_file_rotations=kwargs.get("max_log_file_rotations", None),
)
initialise_config(*args, **kwargs)
return database.initialise_db()
db = database.initialise_db()
CurrentState().set_current_block_index(ledger.ledger.last_db_index(db))
return db


def initialise_log_config(
Expand Down Expand Up @@ -673,6 +676,7 @@ def start_all(args):

# Initialise database
db = database.initialise_db()
CurrentState().set_current_block_index(ledger.ledger.last_db_index(db))
blocks.initialise(db)
blocks.check_database_version(db)
database.optimize(db)
Expand Down Expand Up @@ -771,6 +775,7 @@ def start_all(args):

def reparse(block_index):
ledger_db = database.initialise_db()
CurrentState().set_current_block_index(ledger.ledger.last_db_index(ledger_db))

last_block = ledger.ledger.get_last_block(ledger_db)
if last_block is None or block_index > last_block["block_index"]:
Expand All @@ -791,6 +796,7 @@ def reparse(block_index):

def rollback(block_index=None):
ledger_db = database.initialise_db()
CurrentState().set_current_block_index(ledger.ledger.last_db_index(ledger_db))

last_block = ledger.ledger.get_last_block(ledger_db)
if last_block is None or block_index > last_block["block_index"]:
Expand Down Expand Up @@ -820,6 +826,7 @@ def vacuum():

def check_database():
db = database.initialise_db()
CurrentState().set_current_block_index(ledger.ledger.last_db_index(db))

start_all_time = time.time()

Expand Down
1 change: 1 addition & 0 deletions counterparty-core/counterpartycore/test/util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ def initialise_db(db):
"""Initialise blockchain in the db and insert first block."""
blocks.initialise(db)
insert_block(db, config.BLOCK_FIRST - 1, parse_block=True)
CurrentState().set_current_block_index(ledger.ledger.last_db_index(db))


def run_scenario(scenario):
Expand Down

0 comments on commit c43fa92

Please sign in to comment.