use of tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing in project teku by ConsenSys.
the class BlockOperationSelectorFactoryTest method shouldIncludeValidOperations.
@Test
void shouldIncludeValidOperations() {
final UInt64 slot = UInt64.valueOf(2);
final BeaconState blockSlotState = dataStructureUtil.randomBeaconState(slot);
final SignedVoluntaryExit voluntaryExit = dataStructureUtil.randomSignedVoluntaryExit();
final ProposerSlashing proposerSlashing = dataStructureUtil.randomProposerSlashing();
final AttesterSlashing attesterSlashing = dataStructureUtil.randomAttesterSlashing();
final SignedContributionAndProof contribution = dataStructureUtil.randomSignedContributionAndProof(1, parentRoot);
addToPool(voluntaryExitPool, voluntaryExit);
addToPool(proposerSlashingPool, proposerSlashing);
addToPool(attesterSlashingPool, attesterSlashing);
assertThat(contributionPool.add(contribution)).isCompletedWithValue(ACCEPT);
factory.createSelector(parentRoot, blockSlotState, randaoReveal, Optional.empty()).accept(bodyBuilder);
assertThat(bodyBuilder.randaoReveal).isEqualTo(randaoReveal);
assertThat(bodyBuilder.graffiti).isEqualTo(defaultGraffiti);
assertThat(bodyBuilder.proposerSlashings).containsOnly(proposerSlashing);
assertThat(bodyBuilder.attesterSlashings).containsOnly(attesterSlashing);
assertThat(bodyBuilder.voluntaryExits).containsOnly(voluntaryExit);
assertThat(bodyBuilder.syncAggregate).isEqualTo(spec.getSyncCommitteeUtilRequired(slot).createSyncAggregate(List.of(contribution.getMessage().getContribution())));
}
use of tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing in project teku by ConsenSys.
the class FuzzRegressionTest method shouldRejectAttesterSlashingWithInvalidValidatorIndex.
@Test
void shouldRejectAttesterSlashingWithInvalidValidatorIndex() throws Exception {
final BeaconState state = load("issue2345/state.ssz", spec.getGenesisSchemaDefinitions().getBeaconStateSchema());
final AttesterSlashing slashing = load("issue2345/attester_slashing.ssz", spec.getGenesisSchemaDefinitions().getAttesterSlashingSchema());
SszList<AttesterSlashing> slashings = BeaconBlockBodyLists.ofSpec(spec).createAttesterSlashings(slashing);
assertThatThrownBy(() -> state.updated(mutableState -> spec.getBlockProcessor(mutableState.getSlot()).processAttesterSlashings(mutableState, slashings))).isInstanceOf(BlockProcessingException.class);
}
use of tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing in project teku by ConsenSys.
the class AttesterSlashingValidatorTest method shouldRejectInvalidAttesterSlashing.
@Test
public void shouldRejectInvalidAttesterSlashing() {
AttesterSlashing slashing = dataStructureUtil.randomAttesterSlashing();
when(mockSpec.validateAttesterSlashing(bestState, slashing)).thenReturn(Optional.of(AttesterSlashingInvalidReason.ATTESTATIONS_NOT_SLASHABLE));
assertThat(attesterSlashingValidator.validateFully(slashing)).isCompletedWithValueMatching(InternalValidationResult::isReject);
}
use of tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing in project teku by ConsenSys.
the class AttesterSlashingTopicHandlerTest method handleMessage_validSlashing.
@Test
public void handleMessage_validSlashing() {
final AttesterSlashing slashing = dataStructureUtil.randomAttesterSlashing();
when(processor.process(slashing)).thenReturn(SafeFuture.completedFuture(InternalValidationResult.ACCEPT));
Bytes serialized = gossipEncoding.encode(slashing);
final SafeFuture<ValidationResult> result = topicHandler.handleMessage(topicHandler.prepareMessage(serialized));
asyncRunner.executeQueuedActions();
assertThat(result).isCompletedWithValue(ValidationResult.Valid);
}
use of tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing in project teku by ConsenSys.
the class AttesterSlashingFuzzInputTest method createInput.
@Override
protected AttesterSlashingFuzzInput createInput() {
final BeaconState state = dataStructureUtil.randomBeaconState();
final AttesterSlashing slashing = dataStructureUtil.randomAttesterSlashing();
return new AttesterSlashingFuzzInput(spec, state, slashing);
}
Aggregations