Java Code Examples for org.apache.tuweni.bytes.Bytes#fromHexStringLenient()

The following examples show how to use org.apache.tuweni.bytes.Bytes#fromHexStringLenient() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrieRefTestCaseSpec.java    From besu with Apache License 2.0 6 votes vote down vote up
/**
 * Public constructor.
 *
 * @param inAsObj The set of inputs to insert into the Trie.
 * @param root The expected root hash of the Trie after all inputs have been entered.
 */
@JsonCreator
public TrieRefTestCaseSpec(
    @JsonProperty("in") final Object inAsObj, @JsonProperty("root") final String root) {
  if (inAsObj instanceof ArrayList) {
    @SuppressWarnings("unchecked")
    final ArrayList<ArrayList<String>> in = (ArrayList<ArrayList<String>>) inAsObj;

    this.in = new Bytes[in.size()][2];

    for (int i = 0; i < in.size(); ++i) {
      final String key = in.get(i).get(0);
      final String value = in.get(i).get(1);

      this.in[i][0] = stringParamToBytes(key);
      this.in[i][1] = stringParamToBytes(value);
    }
  } else {
    throw new RuntimeException("in has unknown structure.");
  }

  this.root = Bytes.fromHexStringLenient(root);
}
 
Example 2
Source File: Scalars.java    From besu with Apache License 2.0 5 votes vote down vote up
@Override
public Bytes parseLiteral(final Object input) throws CoercingParseLiteralException {
  if (!(input instanceof StringValue)) {
    throw new CoercingParseLiteralException("Value is not any Bytes : '" + input + "'");
  }
  try {
    return Bytes.fromHexStringLenient(((StringValue) input).getValue());
  } catch (final IllegalArgumentException e) {
    throw new CoercingParseLiteralException("Value is not any Bytes : '" + input + "'");
  }
}
 
Example 3
Source File: InvalidRLPRefTestCaseSpec.java    From besu with Apache License 2.0 4 votes vote down vote up
@JsonCreator
public InvalidRLPRefTestCaseSpec(@JsonProperty("out") final String out) {
  this.rlp = Bytes.fromHexStringLenient(out);
}
 
Example 4
Source File: IbftMiningCoordinatorTest.java    From besu with Apache License 2.0 4 votes vote down vote up
@Test
public void setsTheExtraData() {
  final Bytes extraData = Bytes.fromHexStringLenient("0x1234");
  ibftMiningCoordinator.setExtraData(extraData);
  verify(ibftBlockCreatorFactory).setExtraData(extraData);
}
 
Example 5
Source File: FutureMessageBufferTest.java    From besu with Apache License 2.0 4 votes vote down vote up
private DefaultMessage createMessage(final int i) {
  final MessageData messageData = new RawMessage(0, Bytes.fromHexStringLenient("0x" + i));
  return new DefaultMessage(peerConnection, messageData);
}