use of tech.pegasys.teku.storage.storageSystem.StorageSystem in project teku by ConsenSys.
the class ForkChoiceTestExecutor method runTest.
@Override
public void runTest(final TestDefinition testDefinition) throws Throwable {
if (testsToSkip.contains(testDefinition.getTestName())) {
throw new TestAbortedException("Test " + testDefinition.getDisplayName() + " has been ignored");
}
// Note: The fork choice spec says there may be settings in a meta.yaml file but currently no
// tests actually have one, so we currently don't bother trying to load it.
final BeaconState anchorState = TestDataUtils.loadStateFromSsz(testDefinition, "anchor_state.ssz_snappy");
final Spec spec = testDefinition.getSpec();
final SignedBeaconBlock anchorBlock = loadAnchorBlock(testDefinition);
final StorageSystem storageSystem = InMemoryStorageSystemBuilder.create().specProvider(spec).build();
final RecentChainData recentChainData = storageSystem.recentChainData();
recentChainData.initializeFromAnchorPoint(AnchorPoint.fromInitialBlockAndState(spec, new SignedBlockAndState(anchorBlock, anchorState)), spec.getSlotStartTime(anchorBlock.getSlot(), anchorState.getGenesis_time()));
final MergeTransitionBlockValidator transitionBlockValidator = new MergeTransitionBlockValidator(spec, recentChainData, ExecutionEngineChannel.NOOP);
final ForkChoice forkChoice = new ForkChoice(spec, new InlineEventThread(), recentChainData, new StubForkChoiceNotifier(), transitionBlockValidator, true);
final StubExecutionEngineChannel executionEngine = new StubExecutionEngineChannel(spec);
runSteps(testDefinition, spec, recentChainData, forkChoice, executionEngine);
}
use of tech.pegasys.teku.storage.storageSystem.StorageSystem in project teku by ConsenSys.
the class ForkChoiceStrategyTest method getAncestor_headIsUnknown.
@Test
void getAncestor_headIsUnknown() {
final StorageSystem storageSystem = initStorageSystem();
final ForkChoiceStrategy protoArrayStrategy = getProtoArray(storageSystem);
assertThat(protoArrayStrategy.getAncestor(dataStructureUtil.randomBytes32(), ZERO)).isEmpty();
}
use of tech.pegasys.teku.storage.storageSystem.StorageSystem in project teku by ConsenSys.
the class ForkChoiceStrategyTest method executionBlockHash_shouldBeEmptyForUnknownBlock.
@Test
void executionBlockHash_shouldBeEmptyForUnknownBlock() {
final StorageSystem storageSystem = initStorageSystem(TestSpecFactory.createMinimalBellatrix());
final ForkChoiceStrategy strategy = getProtoArray(storageSystem);
assertThat(strategy.executionBlockHash(Bytes32.ZERO)).isEmpty();
}
use of tech.pegasys.teku.storage.storageSystem.StorageSystem in project teku by ConsenSys.
the class ForkChoiceStrategyTest method initStorageSystem.
private StorageSystem initStorageSystem(final Spec spec) {
final StorageSystem storageSystem = InMemoryStorageSystemBuilder.buildDefault(spec);
storageSystem.chainUpdater().initializeGenesis();
return storageSystem;
}
use of tech.pegasys.teku.storage.storageSystem.StorageSystem in project teku by ConsenSys.
the class ForkChoiceStrategyTest method getAncestor_ancestorIsFound.
@Test
void getAncestor_ancestorIsFound() {
final StorageSystem storageSystem = initStorageSystem();
storageSystem.chainUpdater().advanceChain(1);
final SignedBlockAndState ancestor = storageSystem.chainUpdater().advanceChain(2);
storageSystem.chainUpdater().advanceChain(3);
final SignedBlockAndState head = storageSystem.chainUpdater().advanceChain(5);
final ForkChoiceStrategy protoArrayStrategy = getProtoArray(storageSystem);
assertThat(protoArrayStrategy.getAncestor(head.getRoot(), ancestor.getSlot())).contains(ancestor.getRoot());
}
Aggregations