@Test public void fuzzAttesterSlashing_minimal() { final FuzzUtil fuzzUtil = new FuzzUtil(false, true); final Path testCaseDir = Path.of("minimal/operations/attester_slashing/pyspec_tests/success_surround"); final AttesterSlashing data = loadSsz(testCaseDir.resolve("attester_slashing.ssz"), AttesterSlashing.class); final BeaconState preState = loadSsz(testCaseDir.resolve("pre.ssz"), BeaconStateImpl.class); final BeaconState postState = loadSsz(testCaseDir.resolve("post.ssz"), BeaconStateImpl.class); AttesterSlashingFuzzInput input = new AttesterSlashingFuzzInput((BeaconStateImpl) preState, data); byte[] rawInput = SimpleOffsetSerializer.serialize(input).toArrayUnsafe(); Optional<Bytes> result = fuzzUtil.fuzzAttesterSlashing(rawInput).map(Bytes::wrap); Bytes expected = SimpleOffsetSerializer.serialize(postState); assertThat(result).isNotEmpty(); assertThat(result.get()).isEqualTo(expected); }
public Optional<byte[]> fuzzAttesterSlashing(final byte[] input) { AttesterSlashingFuzzInput structuredInput = deserialize(input, AttesterSlashingFuzzInput.class); try { BeaconState postState = structuredInput .getState() .updated( state -> { BlockProcessorUtil.process_attester_slashings( state, SSZList.singleton(structuredInput.getAttester_slashing())); }); Bytes output = SimpleOffsetSerializer.serialize(postState); return Optional.of(output.toArrayUnsafe()); } catch (BlockProcessingException e) { return Optional.empty(); } }
FuzzUtil { public Optional<byte[]> fuzzAttesterSlashing(final byte[] input) { AttesterSlashingFuzzInput structuredInput = deserialize(input, AttesterSlashingFuzzInput.class); try { BeaconState postState = structuredInput .getState() .updated( state -> { BlockProcessorUtil.process_attester_slashings( state, SSZList.singleton(structuredInput.getAttester_slashing())); }); Bytes output = SimpleOffsetSerializer.serialize(postState); return Optional.of(output.toArrayUnsafe()); } catch (BlockProcessingException e) { return Optional.empty(); } } }
FuzzUtil { public Optional<byte[]> fuzzAttesterSlashing(final byte[] input) { AttesterSlashingFuzzInput structuredInput = deserialize(input, AttesterSlashingFuzzInput.class); try { BeaconState postState = structuredInput .getState() .updated( state -> { BlockProcessorUtil.process_attester_slashings( state, SSZList.singleton(structuredInput.getAttester_slashing())); }); Bytes output = SimpleOffsetSerializer.serialize(postState); return Optional.of(output.toArrayUnsafe()); } catch (BlockProcessingException e) { return Optional.empty(); } } FuzzUtil(final boolean useMainnetConfig, final boolean disable_bls); }
FuzzUtil { public Optional<byte[]> fuzzAttesterSlashing(final byte[] input) { AttesterSlashingFuzzInput structuredInput = deserialize(input, AttesterSlashingFuzzInput.class); try { BeaconState postState = structuredInput .getState() .updated( state -> { BlockProcessorUtil.process_attester_slashings( state, SSZList.singleton(structuredInput.getAttester_slashing())); }); Bytes output = SimpleOffsetSerializer.serialize(postState); return Optional.of(output.toArrayUnsafe()); } catch (BlockProcessingException e) { return Optional.empty(); } } FuzzUtil(final boolean useMainnetConfig, final boolean disable_bls); static void initialize(final boolean useMainnetConfig, final boolean disable_bls); Optional<byte[]> fuzzAttestation(final byte[] input); Optional<byte[]> fuzzAttesterSlashing(final byte[] input); Optional<byte[]> fuzzBlock(final byte[] input); Optional<byte[]> fuzzBlockHeader(final byte[] input); Optional<byte[]> fuzzDeposit(final byte[] input); Optional<byte[]> fuzzProposerSlashing(final byte[] input); Optional<byte[]> fuzzShuffle(final byte[] input); Optional<byte[]> fuzzVoluntaryExit(final byte[] input); }
FuzzUtil { public Optional<byte[]> fuzzAttesterSlashing(final byte[] input) { AttesterSlashingFuzzInput structuredInput = deserialize(input, AttesterSlashingFuzzInput.class); try { BeaconState postState = structuredInput .getState() .updated( state -> { BlockProcessorUtil.process_attester_slashings( state, SSZList.singleton(structuredInput.getAttester_slashing())); }); Bytes output = SimpleOffsetSerializer.serialize(postState); return Optional.of(output.toArrayUnsafe()); } catch (BlockProcessingException e) { return Optional.empty(); } } FuzzUtil(final boolean useMainnetConfig, final boolean disable_bls); static void initialize(final boolean useMainnetConfig, final boolean disable_bls); Optional<byte[]> fuzzAttestation(final byte[] input); Optional<byte[]> fuzzAttesterSlashing(final byte[] input); Optional<byte[]> fuzzBlock(final byte[] input); Optional<byte[]> fuzzBlockHeader(final byte[] input); Optional<byte[]> fuzzDeposit(final byte[] input); Optional<byte[]> fuzzProposerSlashing(final byte[] input); Optional<byte[]> fuzzShuffle(final byte[] input); Optional<byte[]> fuzzVoluntaryExit(final byte[] input);  }