Java Code Examples for org.apache.tuweni.bytes.Bytes32#fromHexString()

The following examples show how to use org.apache.tuweni.bytes.Bytes32#fromHexString() . 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: RLPxConnectionFactoryTest.java    From incubator-tuweni with Apache License 2.0 6 votes vote down vote up
@Test
void invalidHeaderMAC() {
  RLPxConnection conn = new RLPxConnection(
      Bytes32.fromHexString("0x401EED08125776F3A23201D09847EEBEC539FD18E9CB793A53B21F7A23CEFED4"),
      Bytes32.fromHexString("0x82808970451A460E89DBA968ADAA99B56BC4C6270C4285DA1CB0D40116BB02B7"),
      Bytes32.fromHexString("0xEDC55BCCD06BAA6A2D593D3836D7580407FB0C01A96544C63EAA05D863E05744"),
      Bytes
          .fromHexString(
              "0x2B72DAFCF28E915725B511BC0A73C760C785B5704EB303E961D1954D21BCC9B801F90474C2A4769AC420A0C26387A2C963264B2596CE626C679588EA733600EC4091BC7B06157E24E0CC741DDBA1E5C6645D83E1149B2CB95AF3915DC52B9485E0122EE6B4AD0B1A80D53D2CBD50BF67E22C4FCB80059CBC3EA672681350765F360F58FB934F0165B50AE928A4D8CB37F68A9B5FC845960E1D37E0869AA593E6C63ABFEB384E6512E511075F7C5D8EB16067A0C59F4882CC4F7EB415F231CDC6A0D78FC38629E38FA0A5741535378680D7E5426ED397304B83AEAEBC43F812C8172E48497DA5E52CE087267A1FEAD8221BA34398B68C3A54E9F0D18B4CECA4472C177E5BE45D631C9D5DC525E0B8D31BD926AB15465922DFD01EE9AE50D67BF78B0CCCB415D034FD89A8A1F3C4E58F1F0DC2FA87AA4E4A956CDB459102571DBB67637CE05927806D09E218EC66ADB2B6A1702C6CBC40CF33DD5FCA373E9C63570C4F4CEC523881199579447B4B557674D9428BEB035FD9807D36AF304CB05C680F8BD9752E9F347C5B9EB02DCB9E09177B5ECE2CA65E7693932B932A98798DE4B428A7D5420173BC2F5BB5AEC985D565A4BD1B7F987906D7F2D4BF51726D279850C46CF65FAF1D1EF81565630618705FF673FB8BC714991796382A07294E1100D51E5321123DB87B248CED97EEB65C3274685CF9C791114756C9B8F0B1824C4A3CFA4EB172A238025EC20973992945ACC886D593DD91555C"),
      Bytes
          .fromHexString(
              "0xE23AC9D32A1BAD577821EB0858615BFED01C5030A5A39342DC992802679C3C1F0189049E5A5FD009FF4BE044146296CFA5AF029BF1CE5F0913D4DB477D89360E484363C8DFC8E96C6398B20440639323591C8F6337DF2A1DFE7B56DB9B2447401771FEF89700CCB6DDDCF7BA0AC80AE57374449E34F82F65FD0280306E9F62C808690390946CDFF9E9C8A5243ED7BA88E29AA7AC128DD9AE4E79497237B75B4F6D5511FDDD2E1916057ED7CC95B512299C20E90EC2134E2DDA87B7F73F3BFBFD4D68417976AA0F7C74E39BFECF677982E9EE3ED15BDEEC31D7867FA80A18A331AD0BC1C1687F9DB5AD3AB9C81B948E1EE11C1F5CFFE86B5A931CEFD2266D112458B80AA1AD6E9C7814B76CEA4B4C57B360132BFF81ACA35B9620D065F24E0000B4EB27D7B3B126DE353C6C265B391084E3CF27086FCBDF11DA364A480DD61F0899E41539F0D8DD958C95D3D09F0EB4C11136686B5EBB9D89ADFB81FAC83C5895874860F0F75CBDA479EF461CA4B75C2EE0F30FF7E0BD259E31DFE4579E334688303AB29EEAC11DBB963A34F2C09D18242F00BCF5CB5340FB7E03DE02ADEE1F3042246B0E21EF4BAF"),
      publicKey,
      peerPublicKey);
  assertThrows(
      InvalidMACException.class,
      () -> conn
          .readFrame(
              Bytes
                  .fromHexString(
                      "0x5B5B56E71CE97B8DEA5F469808441FD10675F244B062222245F5831747924934841D86A431AD89EB3C825C867F0A9820E8E4134C8438A529BE15445073C2C2C33729E6ED374BF2EEC1CA5F3D60972892")));
}
 
Example 2
Source File: AttestationTest.java    From teku with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldBeDependentOnTargetBlockAndBeaconBlockRoot() {
  final Bytes32 targetRoot = Bytes32.fromHexString("0x01");
  final Bytes32 beaconBlockRoot = Bytes32.fromHexString("0x02");

  final Attestation attestation =
      new Attestation(
          aggregationBitfield,
          new AttestationData(
              UnsignedLong.valueOf(1),
              UnsignedLong.ZERO,
              beaconBlockRoot,
              new Checkpoint(UnsignedLong.ONE, Bytes32.ZERO),
              new Checkpoint(UnsignedLong.valueOf(10), targetRoot)),
          BLSSignature.empty());

  assertThat(attestation.getDependentBlockRoots())
      .containsExactlyInAnyOrder(targetRoot, beaconBlockRoot);
}
 
Example 3
Source File: PeerChainValidatorTest.java    From teku with Apache License 2.0 6 votes vote down vote up
private void setupRemoteStatusAndValidator(final Checkpoint remoteFinalizedCheckpoint) {

    final Bytes32 headRoot = Bytes32.fromHexString("0xeeee");
    // Set a head slot some distance beyond the finalized epoch
    final UnsignedLong headSlot =
        remoteFinalizedCheckpoint
            .getEpoch()
            .times(UnsignedLong.valueOf(Constants.SLOTS_PER_EPOCH))
            .plus(UnsignedLong.valueOf(10L));

    final PeerStatus status =
        new PeerStatus(
            remoteFork,
            remoteFinalizedCheckpoint.getRoot(),
            remoteFinalizedCheckpoint.getEpoch(),
            headRoot,
            headSlot);
    when(peer.getStatus()).thenReturn(status);

    remoteStatus = status;
    peerChainValidator =
        PeerChainValidator.create(recentChainData, historicalChainData, peer, status);
  }
 
Example 4
Source File: DebugOperationTracerTest.java    From besu with Apache License 2.0 6 votes vote down vote up
private Map<UInt256, UInt256> setupStorageForCapture(final MessageFrame frame) {
  final DefaultEvmAccount account = mock(DefaultEvmAccount.class);
  final MutableAccount mutableAccount = mock(MutableAccount.class);
  when(account.getMutable()).thenReturn(mutableAccount);
  when(worldUpdater.getAccount(frame.getRecipientAddress())).thenReturn(account);

  final Map<UInt256, UInt256> updatedStorage = new TreeMap<>();
  updatedStorage.put(UInt256.ZERO, UInt256.valueOf(233));
  updatedStorage.put(UInt256.ONE, UInt256.valueOf(2424));
  when(mutableAccount.getUpdatedStorage()).thenReturn(updatedStorage);
  final Bytes32 word1 = Bytes32.fromHexString("0x01");
  final Bytes32 word2 = Bytes32.fromHexString("0x02");
  final Bytes32 word3 = Bytes32.fromHexString("0x03");
  frame.writeMemory(UInt256.ZERO, UInt256.valueOf(32), word1);
  frame.writeMemory(UInt256.valueOf(32), UInt256.valueOf(32), word2);
  frame.writeMemory(UInt256.valueOf(64), UInt256.valueOf(32), word3);
  return updatedStorage;
}
 
Example 5
Source File: RLPxConnectionFactoryTest.java    From incubator-tuweni with Apache License 2.0 6 votes vote down vote up
@Test
void fixedMessage() {
  RLPxConnection conn = new RLPxConnection(
      Bytes32.fromHexString("0x401EED08125776F3A23201D09847EEBEC539FD18E9CB793A53B21F7A23CEFED4"),
      Bytes32.fromHexString("0x82808970451A460E89DBA968ADAA99B56BC4C6270C4285DA1CB0D40116BB02B7"),
      Bytes32.fromHexString("0xEDC55BCCD06BAA6A2D593D3836D7580407FB0C01A96544C63EAA05D863E05744"),
      Bytes
          .fromHexString(
              "0x2B72DAFCF28E915725B511BC0A73C760C785B5704EB303E961D1954D21BCC9B801F90474C2A4769AC420A0C26387A2C963264B2596CE626C679588EA733600EC4091BC7B06157E24E0CC741DDBA1E5C6645D83E1149B2CB95AF3915DC52B9485E0122EE6B4AD0B1A80D53D2CBD50BF67E22C4FCB80059CBC3EA672681350765F360F58FB934F0165B50AE928A4D8CB37F68A9B5FC845960E1D37E0869AA593E6C63ABFEB384E6512E511075F7C5D8EB16067A0C59F4882CC4F7EB415F231CDC6A0D78FC38629E38FA0A5741535378680D7E5426ED397304B83AEAEBC43F812C8172E48497DA5E52CE087267A1FEAD8221BA34398B68C3A54E9F0D18B4CECA4472C177E5BE45D631C9D5DC525E0B8D31BD926AB15465922DFD01EE9AE50D67BF78B0CCCB415D034FD89A8A1F3C4E58F1F0DC2FA87AA4E4A956CDB459102571DBB67637CE05927806D09E218EC66ADB2B6A1702C6CBC40CF33DD5FCA373E9C63570C4F4CEC523881199579447B4B557674D9428BEB035FD9807D36AF304CB05C680F8BD9752E9F347C5B9EB02DCB9E09177B5ECE2CA65E7693932B932A98798DE4B428A7D5420173BC2F5BB5AEC985D565A4BD1B7F987906D7F2D4BF51726D279850C46CF65FAF1D1EF81565630618705FF673FB8BC714991796382A07294E1100D51E5321123DB87B248CED97EEB65C3274685CF9C791114756C9B8F0B1824C4A3CFA4EB172A238025EC20973992945ACC886D593DD91555C"),
      Bytes
          .fromHexString(
              "0xE23AC9D32A1BAD577821EB0858615BFED01C5030A5A39342DC992802679C3C1F0189049E5A5FD009FF4BE044146296CFA5AF029BF1CE5F0913D4DB477D89360E484363C8DFC8E96C6398B20440639323591C8F6337DF2A1DFE7B56DB9B2447401771FEF89700CCB6DDDCF7BA0AC80AE57374449E34F82F65FD0280306E9F62C808690390946CDFF9E9C8A5243ED7BA88E29AA7AC128DD9AE4E79497237B75B4F6D5511FDDD2E1916057ED7CC95B512299C20E90EC2134E2DDA87B7F73F3BFBFD4D68417976AA0F7C74E39BFECF677982E9EE3ED15BDEEC31D7867FA80A18A331AD0BC1C1687F9DB5AD3AB9C81B948E1EE11C1F5CFFE86B5A931CEFD2266D112458B80AA1AD6E9C7814B76CEA4B4C57B360132BFF81ACA35B9620D065F24E0000B4EB27D7B3B126DE353C6C265B391084E3CF27086FCBDF11DA364A480DD61F0899E41539F0D8DD958C95D3D09F0EB4C11136686B5EBB9D89ADFB81FAC83C5895874860F0F75CBDA479EF461CA4B75C2EE0F30FF7E0BD259E31DFE4579E334688303AB29EEAC11DBB963A34F2C09D18242F00BCF5CB5340FB7E03DE02ADEE1F3042246B0E21EF4BAF"),
      publicKey,
      peerPublicKey);
  RLPxMessage message = conn
      .readFrame(
          Bytes
              .fromHexString(
                  "0x5B5B56F71CE97B8DEA5F469808441FD10675F244B062222245F5831747924934841D86A431AD89EB3C825C867F0A9820E8E4134C8438A529BE15445073C2C2C33729E6ED374BF2EEC1CA5F3D60972892"));
}
 
Example 6
Source File: BytesSerializerTest.java    From teku with Apache License 2.0 5 votes vote down vote up
@Test
public void roundTrip_other() {
  final Bytes32 value = Bytes32.fromHexString("0x123456");
  final byte[] bytes = serializer.serialize(value);
  final Bytes32 deserialized = serializer.deserialize(bytes);
  assertThat(deserialized).isEqualTo(value);
}
 
Example 7
Source File: BitvectorTest.java    From teku with Apache License 2.0 5 votes vote down vote up
@Test
void bitlistHashTest() {
  Bitlist bitlist = new Bitlist(2048, 2048);
  for (int i = 0; i < 44; i++) {
    bitlist.setBit(i);
  }
  Bytes32 hashOld =
      Bytes32.fromHexString("0x447ac4def72d4aa09ded8e1130cbe013511d4881c3393903ada630f034e985d7");

  ListViewRead<BitView> bitlistView = ViewUtils.createBitlistView(bitlist);
  Bytes32 hashNew = bitlistView.hashTreeRoot();

  Assertions.assertEquals(hashOld, hashNew);
}
 
Example 8
Source File: DebugOperationTracerTest.java    From besu with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldRecordMemoryWhenEnabled() throws Exception {
  final MessageFrame frame = validMessageFrame();
  final Bytes32 word1 = Bytes32.fromHexString("0x01");
  final Bytes32 word2 = Bytes32.fromHexString("0x02");
  final Bytes32 word3 = Bytes32.fromHexString("0x03");
  frame.writeMemory(UInt256.ZERO, UInt256.valueOf(32), word1);
  frame.writeMemory(UInt256.valueOf(32), UInt256.valueOf(32), word2);
  frame.writeMemory(UInt256.valueOf(64), UInt256.valueOf(32), word3);
  final TraceFrame traceFrame = traceFrame(frame, Gas.ZERO, new TraceOptions(false, true, false));
  assertThat(traceFrame.getMemory()).isPresent();
  assertThat(traceFrame.getMemory().get()).containsExactly(word1, word2, word3);
}
 
Example 9
Source File: BytesSerializerTest.java    From teku with Apache License 2.0 5 votes vote down vote up
@Test
public void roundTrip_maxValue() {
  final Bytes32 value =
      Bytes32.fromHexString("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
  final byte[] bytes = serializer.serialize(value);
  final Bytes32 deserialized = serializer.deserialize(bytes);
  assertThat(deserialized).isEqualTo(value);
}
 
Example 10
Source File: ECRECPrecompiledContractTest.java    From besu with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldRecoverAddress() {
  final Bytes input = Bytes.fromHexString(this.input);
  final Bytes expected =
      expectedResult == null ? Bytes.EMPTY : Bytes32.fromHexString(expectedResult);
  assertThat(contract.compute(input, messageFrame)).isEqualTo(expected);
}
 
Example 11
Source File: DepositProviderTest.java    From teku with Apache License 2.0 5 votes vote down vote up
@Test
void depositsWithFinalizedIndicesGetPrunedFromMap() {
  Bytes32 finalizedBlockRoot = Bytes32.fromHexString("0x01");
  mockStateEth1DepositIndex(10);
  mockDepositsFromEth1Block(0, 20);
  when(recentChainData.getBlockState(eq(finalizedBlockRoot)))
      .thenReturn(Optional.ofNullable(state));

  assertThat(depositProvider.getDepositMapSize()).isEqualTo(20);

  depositProvider.onNewFinalizedCheckpoint(new Checkpoint(UnsignedLong.ONE, finalizedBlockRoot));

  assertThat(depositProvider.getDepositMapSize()).isEqualTo(10);
}
 
Example 12
Source File: DepositFetcher.java    From teku with Apache License 2.0 5 votes vote down vote up
private DepositsFromBlockEvent createDepositFromBlockEvent(
    final EthBlock.Block block,
    final List<DepositContract.DepositEventEventResponse> groupedDepositEventResponse) {
  return new DepositsFromBlockEvent(
      UnsignedLong.valueOf(block.getNumber()),
      Bytes32.fromHexString(block.getHash()),
      UnsignedLong.valueOf(block.getTimestamp()),
      groupedDepositEventResponse.stream()
          .map(Deposit::new)
          .sorted(Comparator.comparing(Deposit::getMerkle_tree_index))
          .collect(toList()));
}
 
Example 13
Source File: MinimumGenesisTimeBlockFinder.java    From teku with Apache License 2.0 5 votes vote down vote up
static void notifyMinGenesisTimeBlockReached(
    Eth1EventsChannel eth1EventsChannel, EthBlock.Block block) {
  MinGenesisTimeBlockEvent event =
      new MinGenesisTimeBlockEvent(
          UnsignedLong.valueOf(block.getTimestamp()),
          UnsignedLong.valueOf(block.getNumber()),
          Bytes32.fromHexString(block.getHash()));
  eth1EventsChannel.onMinGenesisTimeBlock(event);
  LOG.debug("Notifying BeaconChainService of MinGenesisTimeBlock: {}", event);
}
 
Example 14
Source File: DebugTraceTransactionTest.java    From besu with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldTraceTheTransactionUsingTheTransactionTracer() {
  final TransactionWithMetadata transactionWithMetadata =
      new TransactionWithMetadata(transaction, 12L, blockHash, 2);
  final Map<String, Boolean> map = new HashMap<>();
  map.put("disableStorage", true);
  final Object[] params = new Object[] {transactionHash, map};
  final JsonRpcRequestContext request =
      new JsonRpcRequestContext(new JsonRpcRequest("2.0", "debug_traceTransaction", params));
  final Result result = mock(Result.class);

  final Bytes32[] stackBytes =
      new Bytes32[] {
        Bytes32.fromHexString(
            "0x0000000000000000000000000000000000000000000000000000000000000001")
      };
  final Bytes[] memoryBytes =
      new Bytes[] {
        Bytes.fromHexString("0x0000000000000000000000000000000000000000000000000000000000000002")
      };
  final TraceFrame traceFrame =
      new TraceFrame(
          12,
          "NONE",
          Gas.of(45),
          Optional.of(Gas.of(56)),
          Gas.ZERO,
          2,
          Optional.empty(),
          null,
          Wei.ZERO,
          Bytes.EMPTY,
          Bytes.EMPTY,
          Optional.of(stackBytes),
          Optional.of(memoryBytes),
          Optional.empty(),
          null,
          Optional.of(Bytes.fromHexString("0x1122334455667788")),
          Optional.empty(),
          Optional.empty(),
          0,
          Optional.empty(),
          false,
          Optional.empty(),
          Optional.empty());
  final List<TraceFrame> traceFrames = Collections.singletonList(traceFrame);
  final TransactionTrace transactionTrace =
      new TransactionTrace(transaction, result, traceFrames);
  when(transaction.getGasLimit()).thenReturn(100L);
  when(result.getGasRemaining()).thenReturn(27L);
  when(result.getOutput()).thenReturn(Bytes.fromHexString("1234"));
  when(blockHeader.getNumber()).thenReturn(12L);
  when(blockchain.headBlockNumber()).thenReturn(12L);
  when(blockchain.transactionByHash(transactionHash))
      .thenReturn(Optional.of(transactionWithMetadata));
  when(transactionTracer.traceTransaction(eq(blockHash), eq(transactionHash), any()))
      .thenReturn(Optional.of(transactionTrace));
  final JsonRpcSuccessResponse response =
      (JsonRpcSuccessResponse) debugTraceTransaction.response(request);
  final DebugTraceTransactionResult transactionResult =
      (DebugTraceTransactionResult) response.getResult();

  assertThat(transactionResult.getGas()).isEqualTo(73);
  assertThat(transactionResult.getReturnValue()).isEqualTo("1234");
  final List<StructLog> expectedStructLogs = Collections.singletonList(new StructLog(traceFrame));
  assertThat(transactionResult.getStructLogs()).isEqualTo(expectedStructLogs);
  assertThat(transactionResult.getStructLogs().size()).isEqualTo(1);
  assertThat(transactionResult.getStructLogs().get(0).stack().length).isEqualTo(1);
  assertThat(transactionResult.getStructLogs().get(0).stack()[0])
      .isEqualTo(stackBytes[0].toUnprefixedHexString());
  assertThat(transactionResult.getStructLogs().get(0).memory().length).isEqualTo(1);
  assertThat(transactionResult.getStructLogs().get(0).memory()[0])
      .isEqualTo(memoryBytes[0].toUnprefixedHexString());
}
 
Example 15
Source File: GraffitiConverterTest.java    From teku with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldAcceptShortStrings() {
  final Bytes32 bytes =
      Bytes32.fromHexString("0x5468650000000000000000000000000000000000000000000000000000000000");
  assertThat(converter.convert(data.substring(0, 3))).isEqualTo(bytes);
}
 
Example 16
Source File: SszTestExecutor.java    From teku with Apache License 2.0 4 votes vote down vote up
public Bytes32 getRoot() {
  return Bytes32.fromHexString(root);
}
 
Example 17
Source File: ChainIdOperationTest.java    From besu with Apache License 2.0 4 votes vote down vote up
public ChainIdOperationTest(final String chainIdString, final int expectedGas) {
  chainId = Bytes32.fromHexString(chainIdString);
  this.expectedGas = expectedGas;
  operation = new ChainIdOperation(new ConstantinopleGasCalculator(), chainId);
}
 
Example 18
Source File: MemoryTest.java    From besu with Apache License 2.0 4 votes vote down vote up
private static Bytes32 fillBytes32(final long value) {
  return Bytes32.fromHexString(Strings.repeat(Long.toString(value), 64));
}
 
Example 19
Source File: CommandTestAbstract.java    From besu with Apache License 2.0 4 votes vote down vote up
@Before
public void initMocks() throws Exception {
  // doReturn used because of generic BesuController
  doReturn(mockControllerBuilder)
      .when(mockControllerBuilderFactory)
      .fromEthNetworkConfig(any(), any());
  when(mockControllerBuilder.synchronizerConfiguration(any())).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.ethProtocolConfiguration(any())).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.transactionPoolConfiguration(any()))
      .thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.dataDirectory(any())).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.miningParameters(any())).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.nodeKey(any())).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.metricsSystem(any())).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.privacyParameters(any())).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.clock(any())).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.isRevertReasonEnabled(false)).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.storageProvider(any())).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.isPruningEnabled(anyBoolean())).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.pruningConfiguration(any())).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.genesisConfigOverrides(any())).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.targetGasLimit(any())).thenReturn(mockControllerBuilder);
  when(mockControllerBuilder.requiredBlocks(any())).thenReturn(mockControllerBuilder);

  // doReturn used because of generic BesuController
  doReturn(mockController).when(mockControllerBuilder).build();
  lenient().when(mockController.getProtocolManager()).thenReturn(mockEthProtocolManager);
  lenient().when(mockController.getProtocolSchedule()).thenReturn(mockProtocolSchedule);
  lenient().when(mockController.getProtocolContext()).thenReturn(mockProtocolContext);
  lenient()
      .when(mockController.getAdditionalPluginServices())
      .thenReturn(new NoopPluginServiceFactory());
  lenient().when(mockController.getNodeKey()).thenReturn(nodeKey);

  when(mockEthProtocolManager.getBlockBroadcaster()).thenReturn(mockBlockBroadcaster);

  when(mockRunnerBuilder.vertx(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.besuController(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.discovery(anyBoolean())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.ethNetworkConfig(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.networkingConfiguration(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.p2pAdvertisedHost(anyString())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.p2pListenPort(anyInt())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.p2pListenInterface(anyString())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.maxPeers(anyInt())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.limitRemoteWireConnectionsEnabled(anyBoolean()))
      .thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.fractionRemoteConnectionsAllowed(anyFloat()))
      .thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.p2pEnabled(anyBoolean())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.natMethod(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.natManagerPodName(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.jsonRpcConfiguration(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.graphQLConfiguration(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.webSocketConfiguration(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.dataDir(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.bannedNodeIds(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.metricsSystem(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.metricsConfiguration(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.staticNodes(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.identityString(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.besuPluginContext(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.autoLogBloomCaching(anyBoolean())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.pidPath(any())).thenReturn(mockRunnerBuilder);
  when(mockRunnerBuilder.build()).thenReturn(mockRunner);

  final Bytes32 keyPairPrvKey =
      Bytes32.fromHexString("0xf7a58d5e755d51fa2f6206e91dd574597c73248aaf946ec1964b8c6268d6207b");
  keyPair = SECP256K1.KeyPair.create(SECP256K1.PrivateKey.create(keyPairPrvKey));

  lenient().when(nodeKey.getPublicKey()).thenReturn(keyPair.getPublicKey());

  lenient()
      .when(storageService.getByName(eq("rocksdb")))
      .thenReturn(Optional.of(rocksDBStorageFactory));
  lenient()
      .when(storageService.getByName(eq("rocksdb-privacy")))
      .thenReturn(Optional.of(rocksDBSPrivacyStorageFactory));
  lenient()
      .when(rocksDBSPrivacyStorageFactory.create(any(), any(), any()))
      .thenReturn(new InMemoryKeyValueStorage());

  lenient()
      .when(mockBesuPluginContext.getService(PicoCLIOptions.class))
      .thenReturn(Optional.of(cliOptions));
  lenient()
      .when(mockBesuPluginContext.getService(StorageService.class))
      .thenReturn(Optional.of(storageService));
}
 
Example 20
Source File: BytesModule.java    From teku with Apache License 2.0 4 votes vote down vote up
@Override
public Bytes32 deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
  return Bytes32.fromHexString(p.getValueAsString());
}