Search in sources :

Example 1 with SignedBeaconBlockHeader

use of tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockHeader in project teku by ConsenSys.

the class ProposerSlashingTest method equalsReturnsFalseWhenProposalData1IsDifferent.

@Test
void equalsReturnsFalseWhenProposalData1IsDifferent() {
    // Proposal is rather involved to create. Just create a random one until it is not the
    // same as the original.
    SignedBeaconBlockHeader otherProposal1 = dataStructureUtil.randomSignedBeaconBlockHeader();
    while (Objects.equals(otherProposal1, proposal1)) {
        otherProposal1 = dataStructureUtil.randomSignedBeaconBlockHeader();
    }
    ProposerSlashing testProposerSlashing = new ProposerSlashing(otherProposal1, proposal2);
    assertNotEquals(proposerSlashing, testProposerSlashing);
}
Also used : SignedBeaconBlockHeader(tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockHeader) Test(org.junit.jupiter.api.Test)

Example 2 with SignedBeaconBlockHeader

use of tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockHeader in project teku by ConsenSys.

the class ProposerSlashingTest method equalsReturnsFalseWhenProposalData2IsDifferent.

@Test
void equalsReturnsFalseWhenProposalData2IsDifferent() {
    // Proposal is rather involved to create. Just create a random one until it is not the
    // same as the original.
    SignedBeaconBlockHeader otherProposal2 = dataStructureUtil.randomSignedBeaconBlockHeader();
    while (Objects.equals(otherProposal2, proposal2)) {
        otherProposal2 = dataStructureUtil.randomSignedBeaconBlockHeader();
    }
    ProposerSlashing testProposerSlashing = new ProposerSlashing(proposal1, otherProposal2);
    assertNotEquals(proposerSlashing, testProposerSlashing);
}
Also used : SignedBeaconBlockHeader(tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockHeader) Test(org.junit.jupiter.api.Test)

Example 3 with SignedBeaconBlockHeader

use of tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockHeader in project teku by ConsenSys.

the class ProposerSlashingValidatorTest method shouldRejectProposerSlashingForTwoSignedHeadersWithSameMessageButDifferentSignature.

@Test
public void shouldRejectProposerSlashingForTwoSignedHeadersWithSameMessageButDifferentSignature() throws Exception {
    beaconChainUtil.initializeStorage();
    beaconChainUtil.createAndImportBlockAtSlot(6);
    SignedBeaconBlockHeader header1 = dataStructureUtil.randomSignedBeaconBlockHeader();
    SignedBeaconBlockHeader header2 = new SignedBeaconBlockHeader(header1.getMessage(), BLSTestUtil.randomSignature(100));
    assertThat(header2).isNotEqualTo(header1);
    ProposerSlashing slashing = new ProposerSlashing(header1, header2);
    assertThat(spec.validateProposerSlashing(getBestState(), slashing)).isEqualTo(Optional.of(ProposerSlashingInvalidReason.SAME_HEADER));
}
Also used : ProposerSlashing(tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing) SignedBeaconBlockHeader(tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockHeader) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 SignedBeaconBlockHeader (tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlockHeader)3 ProposerSlashing (tech.pegasys.teku.spec.datastructures.operations.ProposerSlashing)1