Skip to content

Commit 5a6c52e

Browse files
committed
Fix Eth1DepositManagerTest
1 parent f1f52fe commit 5a6c52e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: beacon/pow/src/test/java/tech/pegasys/teku/beacon/pow/Eth1DepositManagerTest.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -383,22 +383,23 @@ void shouldStartWithStoredDepositsChainReorgedToBeShorter() {
383383
}
384384

385385
@Test
386-
void shouldStartFromSnapshotFileWhenProvided() {
386+
void shouldIgnoreSnapshotFileWhenDBSavedVersionProvided() {
387387
final UInt64 deposits = UInt64.valueOf(100);
388388
final BigInteger lastBlockNumber = BigInteger.valueOf(1000);
389389

390-
// DepositTreeSnapshot from file will be used to start from
390+
// This one will be ignored as DB already has a saved version
391391
final DepositTreeSnapshot depositTreeSnapshotFromFile =
392392
dataStructureUtil.randomDepositTreeSnapshot(
393393
deposits.longValue(), UInt64.valueOf(lastBlockNumber));
394394
when(depositSnapshotFileLoader.loadDepositSnapshot())
395395
.thenReturn(LoadDepositSnapshotResult.create(Optional.of(depositTreeSnapshotFromFile)));
396396
when(depositProcessingController.fetchDepositsInRange(any(), any())).thenReturn(COMPLETE);
397397

398-
// This one will be ignored
398+
// DepositTreeSnapshot from DB will be used to start from
399+
final UInt64 dbDepositCount = deposits.plus(50);
400+
final UInt64 dbBlockHeight = UInt64.valueOf(lastBlockNumber).plus(500);
399401
final DepositTreeSnapshot depositTreeSnapshotFromDb =
400-
dataStructureUtil.randomDepositTreeSnapshot(
401-
deposits.plus(50).longValue(), UInt64.valueOf(lastBlockNumber).plus(500));
402+
dataStructureUtil.randomDepositTreeSnapshot(dbDepositCount.longValue(), dbBlockHeight);
402403
when(depositSnapshotStorageLoader.loadDepositSnapshot())
403404
.thenReturn(
404405
SafeFuture.completedFuture(
@@ -407,10 +408,10 @@ void shouldStartFromSnapshotFileWhenProvided() {
407408
manager.start();
408409
notifyHeadBlock(lastBlockNumber, MIN_GENESIS_BLOCK_TIMESTAMP + 1000);
409410
verify(eth1DepositStorageChannel, never()).replayDepositEvents();
410-
verify(eth1EventsChannel).setLatestPublishedDeposit(deposits.decrement());
411+
verify(eth1EventsChannel).setLatestPublishedDeposit(dbDepositCount.decrement());
411412
inOrder
412413
.verify(depositProcessingController)
413-
.startSubscription(lastBlockNumber.add(BigInteger.ONE));
414+
.startSubscription(dbBlockHeight.bigIntegerValue().add(BigInteger.ONE));
414415
inOrder.verifyNoMoreInteractions();
415416
assertNoUncaughtExceptions();
416417
}

0 commit comments

Comments
 (0)