@@ -383,22 +383,23 @@ void shouldStartWithStoredDepositsChainReorgedToBeShorter() {
383
383
}
384
384
385
385
@ Test
386
- void shouldStartFromSnapshotFileWhenProvided () {
386
+ void shouldIgnoreSnapshotFileWhenDBSavedVersionProvided () {
387
387
final UInt64 deposits = UInt64 .valueOf (100 );
388
388
final BigInteger lastBlockNumber = BigInteger .valueOf (1000 );
389
389
390
- // DepositTreeSnapshot from file will be used to start from
390
+ // This one will be ignored as DB already has a saved version
391
391
final DepositTreeSnapshot depositTreeSnapshotFromFile =
392
392
dataStructureUtil .randomDepositTreeSnapshot (
393
393
deposits .longValue (), UInt64 .valueOf (lastBlockNumber ));
394
394
when (depositSnapshotFileLoader .loadDepositSnapshot ())
395
395
.thenReturn (LoadDepositSnapshotResult .create (Optional .of (depositTreeSnapshotFromFile )));
396
396
when (depositProcessingController .fetchDepositsInRange (any (), any ())).thenReturn (COMPLETE );
397
397
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 );
399
401
final DepositTreeSnapshot depositTreeSnapshotFromDb =
400
- dataStructureUtil .randomDepositTreeSnapshot (
401
- deposits .plus (50 ).longValue (), UInt64 .valueOf (lastBlockNumber ).plus (500 ));
402
+ dataStructureUtil .randomDepositTreeSnapshot (dbDepositCount .longValue (), dbBlockHeight );
402
403
when (depositSnapshotStorageLoader .loadDepositSnapshot ())
403
404
.thenReturn (
404
405
SafeFuture .completedFuture (
@@ -407,10 +408,10 @@ void shouldStartFromSnapshotFileWhenProvided() {
407
408
manager .start ();
408
409
notifyHeadBlock (lastBlockNumber , MIN_GENESIS_BLOCK_TIMESTAMP + 1000 );
409
410
verify (eth1DepositStorageChannel , never ()).replayDepositEvents ();
410
- verify (eth1EventsChannel ).setLatestPublishedDeposit (deposits .decrement ());
411
+ verify (eth1EventsChannel ).setLatestPublishedDeposit (dbDepositCount .decrement ());
411
412
inOrder
412
413
.verify (depositProcessingController )
413
- .startSubscription (lastBlockNumber .add (BigInteger .ONE ));
414
+ .startSubscription (dbBlockHeight . bigIntegerValue () .add (BigInteger .ONE ));
414
415
inOrder .verifyNoMoreInteractions ();
415
416
assertNoUncaughtExceptions ();
416
417
}
0 commit comments