use of tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem in project teku by ConsenSys.
the class DepositProviderTest method setup.
void setup(final int maxDeposits) {
when(state.getSlot()).thenReturn(UInt64.valueOf(1234));
SpecConfig specConfig = SpecConfigLoader.loadConfig("minimal", b -> b.maxDeposits(maxDeposits));
spec = TestSpecFactory.createPhase0(specConfig);
depositUtil = new DepositUtil(spec);
dataStructureUtil = new DataStructureUtil(spec);
depositProvider = new DepositProvider(new StubMetricsSystem(), recentChainData, eth1DataCache, spec);
depositMerkleTree = new OptimizedMerkleTree(spec.getGenesisSpecConfig().getDepositContractTreeDepth());
mockStateEth1DataVotes();
createDepositEvents(40);
randomEth1Data = dataStructureUtil.randomEth1Data();
}
use of tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem in project teku by ConsenSys.
the class AbstractStoreTest method createGenesisStore.
protected UpdatableStore createGenesisStore(final StoreConfig pruningOptions) {
final SignedBlockAndState genesis = chainBuilder.generateGenesis();
final Checkpoint genesisCheckpoint = chainBuilder.getCurrentCheckpointForEpoch(0);
return StoreBuilder.create().asyncRunner(SYNC_RUNNER).metricsSystem(new StubMetricsSystem()).specProvider(spec).blockProvider(blockProviderFromChainBuilder()).stateProvider(StateAndBlockSummaryProvider.NOOP).anchor(Optional.empty()).genesisTime(genesis.getState().getGenesis_time()).time(genesis.getState().getGenesis_time()).latestFinalized(AnchorPoint.create(spec, genesisCheckpoint, genesis)).justifiedCheckpoint(genesisCheckpoint).bestJustifiedCheckpoint(genesisCheckpoint).blockInformation(Map.of(genesis.getRoot(), new StoredBlockMetadata(genesis.getSlot(), genesis.getRoot(), genesis.getParentRoot(), genesis.getStateRoot(), genesis.getExecutionBlockHash(), Optional.of(new CheckpointEpochs(UInt64.ZERO, UInt64.ZERO))))).storeConfig(pruningOptions).votes(emptyMap()).build();
}
use of tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem in project teku by ConsenSys.
the class StoreTest method create_timeLessThanGenesisTime.
@Test
public void create_timeLessThanGenesisTime() {
final UInt64 genesisTime = UInt64.valueOf(100);
final SignedBlockAndState genesis = chainBuilder.generateGenesis(genesisTime, false);
final Checkpoint genesisCheckpoint = chainBuilder.getCurrentCheckpointForEpoch(0);
assertThatThrownBy(() -> Store.create(SYNC_RUNNER, new StubMetricsSystem(), spec, blockProviderFromChainBuilder(), StateAndBlockSummaryProvider.NOOP, Optional.empty(), genesisTime.minus(1), genesisTime, AnchorPoint.create(spec, genesisCheckpoint, genesis), Optional.empty(), genesisCheckpoint, genesisCheckpoint, Collections.emptyMap(), Collections.emptyMap(), StoreConfig.createDefault())).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Time must be greater than or equal to genesisTime");
}
use of tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem in project teku by ConsenSys.
the class AggregatingSignatureVerificationServiceTest method testRealServiceWithThreads.
@Test
public void testRealServiceWithThreads() throws Exception {
final MetricsSystem metrics = new StubMetricsSystem();
final AsyncRunnerFactory realRunnerFactory = AsyncRunnerFactory.createDefault(new MetricTrackingExecutorFactory(metrics));
service = new AggregatingSignatureVerificationService(metrics, realRunnerFactory, realRunnerFactory.create("completion", 1), 1, queueCapacity, batchSize, minBatchSizeToSplit, strictThreadLimitEnabled);
startService();
final Random random = new Random(1);
for (int i = 0; i < 3; i++) {
final List<SafeFuture<Boolean>> validFutures = new ArrayList<>();
final List<SafeFuture<Boolean>> invalidFutures = new ArrayList<>();
for (int j = 0; j < queueCapacity - i; j++) {
if (random.nextFloat() < .5) {
validFutures.add(executeValidVerify(j, j));
} else {
invalidFutures.add(executeInvalidVerify(j, j));
}
}
final List<SafeFuture<Boolean>> allFutures = new ArrayList<>();
allFutures.addAll(validFutures);
allFutures.addAll(invalidFutures);
Waiter.waitFor(SafeFuture.allOf(allFutures.toArray(SafeFuture<?>[]::new)), Duration.ofSeconds(5));
validFutures.forEach(f -> assertThat(f).isCompletedWithValue(true));
invalidFutures.forEach(f -> assertThat(f).isCompletedWithValue(false));
}
}
use of tech.pegasys.teku.infrastructure.metrics.StubMetricsSystem in project teku by ConsenSys.
the class StorageBackedRecentChainDataTest method storageBackedClient_storeInitializeViaGetStoreRequestAfterIOException.
@Test
public void storageBackedClient_storeInitializeViaGetStoreRequestAfterIOException() {
SafeFuture<Optional<StoreBuilder>> storeRequestFuture = new SafeFuture<>();
when(storageQueryChannel.onStoreRequest()).thenReturn(SafeFuture.failedFuture(new IOException())).thenReturn(storeRequestFuture);
final SafeFuture<RecentChainData> client = StorageBackedRecentChainData.create(new StubMetricsSystem(), StoreConfig.createDefault(), asyncRunner, storageQueryChannel, storageUpdateChannel, voteUpdateChannel, finalizedCheckpointChannel, chainHeadChannel, spec);
// We should have posted a request to get the store from storage
verify(storageQueryChannel).onStoreRequest();
assertThat(client).isCompletedExceptionally();
}
Aggregations