use of tech.pegasys.teku.ethereum.pow.api.DepositsFromBlockEvent in project teku by ConsenSys.
the class DepositProviderTest method shouldNotifyEth1DataCacheOfDepositBlocks.
@Test
void shouldNotifyEth1DataCacheOfDepositBlocks() {
setup(16);
final tech.pegasys.teku.ethereum.pow.api.Deposit deposit = dataStructureUtil.randomDepositEvent(UInt64.ZERO);
final DepositsFromBlockEvent event = DepositsFromBlockEvent.create(dataStructureUtil.randomUInt64(), dataStructureUtil.randomBytes32(), dataStructureUtil.randomUInt64(), Stream.of(deposit));
depositProvider.onDepositsFromBlock(event);
depositMerkleTree.add(depositUtil.convertDepositEventToOperationDeposit(deposit).getData().hashTreeRoot());
verify(eth1DataCache).onBlockWithDeposit(event.getBlockTimestamp(), new Eth1Data(depositMerkleTree.getRoot(), UInt64.ONE, event.getBlockHash()));
}
use of tech.pegasys.teku.ethereum.pow.api.DepositsFromBlockEvent in project teku by ConsenSys.
the class DepositProviderTest method mockDepositsFromEth1Block.
private void mockDepositsFromEth1Block(int startIndex, int n) {
allSeenDepositsList.subList(startIndex, n).stream().map(depositUtil::convertDepositEventToOperationDeposit).map(Deposit::getData).map(DepositData::hashTreeRoot).forEachOrdered(depositMerkleTree::add);
DepositsFromBlockEvent depositsFromBlockEvent = mock(DepositsFromBlockEvent.class);
when(depositsFromBlockEvent.getDeposits()).thenReturn(allSeenDepositsList.subList(startIndex, startIndex + n));
when(depositsFromBlockEvent.getBlockHash()).thenReturn(Bytes32.ZERO);
depositProvider.onDepositsFromBlock(depositsFromBlockEvent);
}
use of tech.pegasys.teku.ethereum.pow.api.DepositsFromBlockEvent in project teku by ConsenSys.
the class GenesisHandlerTest method onDepositsFromBlock_shouldInitializeGenesis.
@Test
public void onDepositsFromBlock_shouldInitializeGenesis() {
final UInt64 genesisTime = specConfig.getMinGenesisTime();
final int batchSize = initialDepositData.size() / 2;
final DepositsFromBlockEvent event1 = DepositsFromBlockEvent.create(UInt64.valueOf(100), dataStructureUtil.randomBytes32(), UInt64.ZERO, initialDeposits.stream().limit(batchSize));
final DepositsFromBlockEvent event2 = DepositsFromBlockEvent.create(UInt64.valueOf(100), dataStructureUtil.randomBytes32(), genesisTime, initialDeposits.stream().skip(batchSize));
assertThat(storageSystem.recentChainData().isPreGenesis()).isTrue();
genesisHandler.onDepositsFromBlock(event1);
assertThat(storageSystem.recentChainData().isPreGenesis()).isTrue();
genesisHandler.onDepositsFromBlock(event2);
assertThat(storageSystem.recentChainData().isPreGenesis()).isFalse();
}
use of tech.pegasys.teku.ethereum.pow.api.DepositsFromBlockEvent in project teku by ConsenSys.
the class ValidatingEth1EventsPublisherTest method onDepositsFromBlock_latestIndexSetConsistently.
@Test
public void onDepositsFromBlock_latestIndexSetConsistently() {
final DepositsFromBlockEvent event2 = dataStructureUtil.randomDepositsFromBlockEvent(2, 10, 11);
final DepositsFromBlockEvent event3 = dataStructureUtil.randomDepositsFromBlockEvent(3, 11, 15);
publisher.setLatestPublishedDeposit(UInt64.valueOf(9));
publisher.onDepositsFromBlock(event2);
verify(delegate).onDepositsFromBlock(event2);
publisher.onDepositsFromBlock(event3);
verify(delegate).onDepositsFromBlock(event3);
}
use of tech.pegasys.teku.ethereum.pow.api.DepositsFromBlockEvent in project teku by ConsenSys.
the class ValidatingEth1EventsPublisherTest method onDepositsFromBlock_missingDeposit.
@Test
public void onDepositsFromBlock_missingDeposit() {
final DepositsFromBlockEvent event1 = dataStructureUtil.randomDepositsFromBlockEvent(1, 0, 10);
final DepositsFromBlockEvent event3 = dataStructureUtil.randomDepositsFromBlockEvent(3, 11, 15);
publisher.onDepositsFromBlock(event1);
assertThatThrownBy(() -> publisher.onDepositsFromBlock(event3)).isInstanceOf(InvalidDepositEventsException.class).hasMessageContaining("Expected next deposit at index 10, but got 11");
}
Aggregations