Search in sources :

Example 16 with NodeKey

use of org.hyperledger.besu.crypto.NodeKey in project besu by hyperledger.

the class SpuriousBehaviourTest method nonValidatorsCannotTriggerResponses.

@Test
public void nonValidatorsCannotTriggerResponses() {
    final NodeKey nonValidatorNodeKey = NodeKeyUtils.generate();
    final NodeParams nonValidatorParams = new NodeParams(Util.publicKeyToAddress(nonValidatorNodeKey.getPublicKey()), nonValidatorNodeKey);
    final ValidatorPeer nonvalidator = new ValidatorPeer(nonValidatorParams, new MessageFactory(nonValidatorParams.getNodeKey()), context.getEventMultiplexer());
    nonvalidator.injectProposal(new ConsensusRoundIdentifier(1, 0), proposedBlock);
    peers.verifyNoMessagesReceived();
}
Also used : ValidatorPeer(org.hyperledger.besu.consensus.qbft.support.ValidatorPeer) ConsensusRoundIdentifier(org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier) MessageFactory(org.hyperledger.besu.consensus.qbft.payload.MessageFactory) NodeKey(org.hyperledger.besu.crypto.NodeKey) NodeParams(org.hyperledger.besu.consensus.common.bft.inttest.NodeParams) Test(org.junit.jupiter.api.Test)

Example 17 with NodeKey

use of org.hyperledger.besu.crypto.NodeKey in project besu by hyperledger.

the class PublicKeySubCommandTest method callingPublicKeyExportAddressSubCommandWithoutPathMustWriteAddressToStandardOutput.

@Test
public void callingPublicKeyExportAddressSubCommandWithoutPathMustWriteAddressToStandardOutput() {
    final NodeKey nodeKey = getNodeKey();
    parseCommand(PUBLIC_KEY_SUBCOMMAND_NAME, PUBLIC_KEY_EXPORT_ADDRESS_SUBCOMMAND_NAME);
    final String expectedOutputStart = Util.publicKeyToAddress(nodeKey.getPublicKey()).toString();
    assertThat(commandOutput.toString(UTF_8)).startsWith(expectedOutputStart);
    assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
Also used : NodeKey(org.hyperledger.besu.crypto.NodeKey) Test(org.junit.Test)

Example 18 with NodeKey

use of org.hyperledger.besu.crypto.NodeKey in project besu by hyperledger.

the class PublicKeySubCommandTest method callingPublicKeyExportAddressSubCommandWithFilePathMustWriteAddressInThisFile.

@Test
public void callingPublicKeyExportAddressSubCommandWithFilePathMustWriteAddressInThisFile() throws Exception {
    final NodeKey nodeKey = getNodeKey();
    final File file = File.createTempFile("public", "address");
    parseCommand(PUBLIC_KEY_SUBCOMMAND_NAME, PUBLIC_KEY_EXPORT_ADDRESS_SUBCOMMAND_NAME, "--to", file.getPath());
    assertThat(contentOf(file)).startsWith(Util.publicKeyToAddress(nodeKey.getPublicKey()).toString()).endsWith(Util.publicKeyToAddress(nodeKey.getPublicKey()).toString());
    assertThat(commandOutput.toString(UTF_8)).isEmpty();
    assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
Also used : NodeKey(org.hyperledger.besu.crypto.NodeKey) File(java.io.File) Test(org.junit.Test)

Example 19 with NodeKey

use of org.hyperledger.besu.crypto.NodeKey in project besu by hyperledger.

the class PublicKeySubCommandTest method callingPublicKeyExportSubCommandWithoutPathMustWriteKeyToStandardOutput.

@Test
public void callingPublicKeyExportSubCommandWithoutPathMustWriteKeyToStandardOutput() {
    final NodeKey nodeKey = getNodeKey();
    parseCommand(PUBLIC_KEY_SUBCOMMAND_NAME, PUBLIC_KEY_EXPORT_SUBCOMMAND_NAME);
    final String expectedOutputStart = nodeKey.getPublicKey().toString();
    assertThat(commandOutput.toString(UTF_8)).startsWith(expectedOutputStart);
    assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
Also used : NodeKey(org.hyperledger.besu.crypto.NodeKey) Test(org.junit.Test)

Example 20 with NodeKey

use of org.hyperledger.besu.crypto.NodeKey in project besu by hyperledger.

the class PublicKeySubCommandTest method callingPublicKeyExportSubCommandWithFilePathMustWritePublicKeyInThisFile.

@Test
public void callingPublicKeyExportSubCommandWithFilePathMustWritePublicKeyInThisFile() throws Exception {
    final NodeKey nodeKey = getNodeKey();
    final File file = File.createTempFile("public", "key");
    parseCommand(PUBLIC_KEY_SUBCOMMAND_NAME, PUBLIC_KEY_EXPORT_SUBCOMMAND_NAME, "--to", file.getPath());
    assertThat(contentOf(file)).startsWith(nodeKey.getPublicKey().toString()).endsWith(nodeKey.getPublicKey().toString());
    assertThat(commandOutput.toString(UTF_8)).isEmpty();
    assertThat(commandErrorOutput.toString(UTF_8)).isEmpty();
}
Also used : NodeKey(org.hyperledger.besu.crypto.NodeKey) File(java.io.File) Test(org.junit.Test)

Aggregations

NodeKey (org.hyperledger.besu.crypto.NodeKey)94 Test (org.junit.Test)78 Address (org.hyperledger.besu.datatypes.Address)43 BlockHeader (org.hyperledger.besu.ethereum.core.BlockHeader)31 BlockHeaderValidator (org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator)24 Bytes (org.apache.tuweni.bytes.Bytes)18 DiscoveryPeer (org.hyperledger.besu.ethereum.p2p.discovery.DiscoveryPeer)17 Endpoint (org.hyperledger.besu.ethereum.p2p.discovery.Endpoint)16 ProtocolContext (org.hyperledger.besu.ethereum.ProtocolContext)14 List (java.util.List)13 ConsensusRoundIdentifier (org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier)13 EnodeURL (org.hyperledger.besu.plugin.data.EnodeURL)13 Optional (java.util.Optional)12 NodeKeyUtils (org.hyperledger.besu.crypto.NodeKeyUtils)11 Collectors (java.util.stream.Collectors)10 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)10 Util (org.hyperledger.besu.ethereum.core.Util)9 PeerPermissionsDenylist (org.hyperledger.besu.ethereum.p2p.permissions.PeerPermissionsDenylist)9 Before (org.junit.Before)9 MessageFactory (org.hyperledger.besu.consensus.ibft.payload.MessageFactory)8