Skip to content

Commit ccd744b

Browse files
backport: adapt assumeutxo hardening tests for Dash
1 parent eefcec0 commit ccd744b

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

test/functional/feature_assumeutxo.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,12 @@ def check_for_final_height():
518518

519519
for reindex_arg in ['-reindex=1', '-reindex-chainstate=1']:
520520
self.log.info(f"Check that restarting with {reindex_arg} will delete the snapshot chainstate")
521-
self.restart_node(2, extra_args=[reindex_arg, *self.extra_args[2]])
521+
reindex_args = [reindex_arg, *self.extra_args[2]]
522+
if reindex_arg == '-reindex-chainstate=1':
523+
# Dash forbids chainstate-only reindex while optional indexes
524+
# are enabled because they cannot be rebuilt out of order.
525+
reindex_args += ['-txindex=0', '-blockfilterindex=0', '-coinstatsindex=0']
526+
self.restart_node(2, extra_args=reindex_args)
522527
assert_equal(1, len(n2.getchainstates()["chainstates"]))
523528
for i in range(1, 300):
524529
block = n0.getblock(n0.getblockhash(i), 0)
@@ -527,6 +532,11 @@ def check_for_final_height():
527532
assert_equal(loaded['coins_loaded'], SNAPSHOT_BASE_HEIGHT)
528533
assert_equal(loaded['base_height'], SNAPSHOT_BASE_HEIGHT)
529534

535+
# The final -reindex-chainstate run disables optional indexes because
536+
# Dash cannot rebuild them out of order. Re-enable them for the
537+
# snapshot sync and index-completion checks below.
538+
self.restart_node(2, extra_args=self.extra_args[2])
539+
530540
normal, snapshot = n2.getchainstates()['chainstates']
531541
assert_equal(normal['blocks'], START_HEIGHT)
532542
assert_equal(normal.get('snapshot_blockhash'), None)

test/functional/feature_assumeutxo_dash.py

100644100755
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ def run_test(self):
247247
node0.invalidateblock(extra_hash)
248248
assert_equal(node0.getblockcount(), base_height)
249249
node0.setnetworkactive(True)
250+
for node_index in range(1, len(self.nodes)):
251+
self.connect_nodes(0, node_index)
250252
force_finish_mnsync(node0)
251253
self.sync_all()
252254
self.wait_for_sporks_same()
@@ -418,7 +420,13 @@ def assert_unfaked_snapshot_counts(background_height):
418420
self.disconnect_nodes(snapshot_index, 0)
419421

420422
completed, = snapshot_node.getchainstates()["chainstates"]
421-
assert_equal(completed["blocks"], base_height)
423+
# The rollback helper rolls the isolated block forward before writing.
424+
# Once its header is later announced to the reconnected network, the
425+
# quorum can ChainLock it and override the local invalidation used to
426+
# hold the fixture at the snapshot base.
427+
final_height = base_height + 1
428+
assert_equal(completed["blocks"], final_height)
429+
assert_equal(snapshot_node.getbestblockhash(), extra_hash)
422430
assert_equal(completed["validated"], True)
423431
assert_equal(completed["snapshot_blockhash"], base_hash)
424432
assert_equal(
@@ -438,7 +446,7 @@ def assert_unfaked_snapshot_counts(background_height):
438446
):
439447
self.restart_node(snapshot_index, extra_args=snapshot_args)
440448
cleaned, = snapshot_node.getchainstates()["chainstates"]
441-
assert_equal(cleaned["blocks"], base_height)
449+
assert_equal(cleaned["blocks"], final_height)
442450
assert_equal(cleaned["validated"], True)
443451
assert "snapshot_blockhash" not in cleaned
444452
assert not (snapshot_node.chain_path / "chainstate_snapshot").exists()
@@ -447,7 +455,7 @@ def assert_unfaked_snapshot_counts(background_height):
447455
self.log.info("Restart once more after cleanup")
448456
self.restart_node(snapshot_index, extra_args=snapshot_args)
449457
final_state, = snapshot_node.getchainstates()["chainstates"]
450-
assert_equal(final_state["blocks"], base_height)
458+
assert_equal(final_state["blocks"], final_height)
451459
assert_equal(final_state["validated"], True)
452460
assert "snapshot_blockhash" not in final_state
453461

test/lint/lint-shell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def main():
7070
reg = re.compile(r'src/[dashbls,immer,leveldb,secp256k1,minisketch]')
7171

7272
def should_exclude(fname: str) -> bool:
73-
return bool(reg.match(fname)) or 'test_utxo_snapshots.sh' in fname
73+
return bool(reg.match(fname))
7474

7575
# remove everything that doesn't match this regex
7676
files[:] = [file for file in files if not should_exclude(file)]

0 commit comments

Comments
 (0)