Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Sep 20, 2023
1 parent 014f3db commit 0e3b652
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,6 @@ void onBlock_shouldUpdateVotesBasedOnAttestationsInBlocks() {

@Test
void onBlock_shouldUpdateVotesBasedOnAttesterSlashingEquivocationsInBlocks() {
final SignedBlockAndState commonBlock = chainBuilder.generateNextBlock();
importBlock(commonBlock);
final ChainBuilder forkChain = chainBuilder.fork();
final SignedBlockAndState forkBlock =
forkChain.generateNextBlock(
Expand Down Expand Up @@ -717,6 +715,27 @@ void onBlock_shouldNotifyOptimisticSyncChangeOnlyWhenImportingOnCanonicalHead()
verifyNoMoreInteractions(optimisticSyncStateTracker);
}

@Test
void onBlock_shouldApplyProposerBoostToFirstBlock() {
final ChainBuilder forkChain = chainBuilder.fork();

final SignedBlockAndState block = chainBuilder.generateNextBlock();
final SignedBlockAndState forkBlock = forkChain.generateNextBlock();

final BlockOptions forkBlockOptions = BlockOptions.create();
final List<Attestation> forkAttestations =
forkChain.streamValidAttestationsWithTargetBlock(forkBlock).limit(2).toList();
forkAttestations.forEach(forkBlockOptions::addAttestation);
final SignedBlockAndState forkBlock1 = forkChain.generateNextBlock(forkBlockOptions);

importBlock(block);
importBlock(forkBlock);
importBlock(forkBlock1);

// proposer boost is given to the first block despite the fork chain having bigger weight
assertThat(recentChainData.getStore().getProposerBoostRoot()).hasValue(block.getRoot());
}

@Test
void applyHead_shouldSendForkChoiceUpdatedNotification() {
final SignedBlockAndState blockAndState = storageSystem.chainUpdater().advanceChainUntil(1);
Expand Down

0 comments on commit 0e3b652

Please sign in to comment.