tech.pegasys.pantheon.ethereum.core.Address类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中tech.pegasys.pantheon.ethereum.core.Address类的一些代码示例,展示了Address类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address类的具体详情如下:
包路径:tech.pegasys.pantheon.ethereum.core.Address
类名称:Address

Address介绍

暂无

代码示例

代码示例来源:origin: PegaSysEng/pantheon

/**
  * Public constructor.
  *
  * @param value The value the AccountAddress represents.
  */
 @JsonCreator
 public AddressMock(final String value) {
  super(Address.fromHexString(value));
 }
}

代码示例来源:origin: PegaSysEng/pantheon

private FilterParameter filterParamWithAddressAndTopics(
  final Address address, final List<List<String>> topics) {
 final List<String> addresses = address != null ? Arrays.asList(address.toString()) : null;
 return new FilterParameter("latest", "latest", addresses, topics, null);
}

代码示例来源:origin: PegaSysEng/pantheon

public String getAddress() {
 return Address.extract(Hash.hash(keyPair.getPublicKey().getEncodedBytes())).toString();
}

代码示例来源:origin: PegaSysEng/pantheon

@Test
public void accountAddresHashCode() {
 final Address addr =
   Address.wrap(BytesValue.fromHexString("0x0000000000000000000000000000000000101010"));
 final Address addr2 =
   Address.wrap(BytesValue.fromHexString("0x0000000000000000000000000000000000101010"));
 Assert.assertEquals(addr.hashCode(), addr2.hashCode());
}

代码示例来源:origin: PegaSysEng/pantheon

@Test
public void accountAddressToString() {
 final Address addr =
   Address.wrap(BytesValue.fromHexString("0x0000000000000000000000000000000000101010"));
 Assert.assertEquals("0x0000000000000000000000000000000000101010", addr.toString());
}

代码示例来源:origin: PegaSysEng/pantheon

@Test
public void miningOptionsRequiresServiceToBeEnabled() {
 final Address requestedCoinbase = Address.fromHexString("0000011111222223333344444");
 parseCommand(
   "--miner-coinbase",
   requestedCoinbase.toString(),
   "--min-gas-price",
   "42",
   "--miner-extra-data",
   "0x1122334455667788990011223344556677889900112233445566778899001122");
 verifyOptionsConstraintLoggerCall(
   "--miner-coinbase, --min-gas-price and --miner-extra-data", "--miner-enabled");
 assertThat(commandOutput.toString()).isEmpty();
 assertThat(commandErrorOutput.toString()).isEmpty();
}

代码示例来源:origin: PegaSysEng/pantheon

final Address localAddr = Address.extract(Hash.hash(nodeKeys.getPublicKey().getEncodedBytes()));
final List<Address> initialValidatorList =
  Arrays.asList(
    Address.fromHexString(String.format("%020d", 1)),
    Address.fromHexString(String.format("%020d", 2)),
    Address.fromHexString(String.format("%020d", 3)),
    Address.fromHexString(String.format("%020d", 4)),
    localAddr);
    Address.fromHexString(String.format("%020d", 0)),
    parent ->
      new IbftExtraData(

代码示例来源:origin: PegaSysEng/pantheon

@Test
public void insufficientCommitSealsFailsValidation() {
 final KeyPair committerKeyPair = KeyPair.generate();
 final Address committerAddress =
   Address.extract(Hash.hash(committerKeyPair.getPublicKey().getEncodedBytes()));
 final List<Address> validators = singletonList(committerAddress);
 final VoteTally voteTally = new VoteTally(validators);
 final ProtocolContext<IbftContext> context =
   new ProtocolContext<>(null, null, new IbftContext(voteTally, null));
 final BlockHeader header = createProposedBlockHeader(validators, emptyList(), false);
 // Note that no committer seals are in the header's IBFT extra data.
 final IbftExtraData headerExtraData = IbftExtraData.decode(header.getExtraData());
 assertThat(headerExtraData.getSeals().size()).isEqualTo(0);
 assertThat(commitSealsValidationRule.validate(header, null, context)).isFalse();
}

代码示例来源:origin: PegaSysEng/pantheon

@Test(expected = IllegalArgumentException.class)
 public void invalidAccountAddress() {
  Address.wrap(BytesValue.fromHexString("0x00101010"));
 }
}

代码示例来源:origin: PegaSysEng/pantheon

@Test
public void miningParametersAreCaptured() throws Exception {
 final Address requestedCoinbase = Address.fromHexString("0000011111222223333344444");
 final String extraDataString =
   "0x1122334455667788990011223344556677889900112233445566778899001122";
 parseCommand(
   "--miner-enabled",
   "--miner-coinbase=" + requestedCoinbase.toString(),
   "--min-gas-price=15",
   "--miner-extra-data=" + extraDataString);
 final ArgumentCaptor<MiningParameters> miningArg =
   ArgumentCaptor.forClass(MiningParameters.class);
 verify(mockControllerBuilder).miningParameters(miningArg.capture());
 verify(mockControllerBuilder).build();
 assertThat(commandOutput.toString()).isEmpty();
 assertThat(commandErrorOutput.toString()).isEmpty();
 assertThat(miningArg.getValue().getCoinbase()).isEqualTo(Optional.of(requestedCoinbase));
 assertThat(miningArg.getValue().getMinTransactionGasPrice()).isEqualTo(Wei.of(15));
 assertThat(miningArg.getValue().getExtraData())
   .isEqualTo(BytesValue.fromHexString(extraDataString));
}

代码示例来源:origin: PegaSysEng/pantheon

private boolean subExecution(
   final int validatorCount,
   final int committerCount,
   final boolean useDifferentRoundNumbersForCommittedSeals) {

  final List<Address> validators = Lists.newArrayList();
  final List<KeyPair> committerKeys = Lists.newArrayList();

  for (int i = 0; i < validatorCount; i++) { // need -1 to account for proposer
   final KeyPair committerKeyPair = KeyPair.generate();
   committerKeys.add(committerKeyPair);
   validators.add(Address.extract(Hash.hash(committerKeyPair.getPublicKey().getEncodedBytes())));
  }

  Collections.sort(validators);
  final VoteTally voteTally = new VoteTally(validators);
  BlockHeader header =
    createProposedBlockHeader(
      validators,
      committerKeys.subList(0, committerCount),
      useDifferentRoundNumbersForCommittedSeals);

  final ProtocolContext<IbftContext> context =
    new ProtocolContext<>(null, null, new IbftContext(voteTally, null));

  return commitSealsValidationRule.validate(header, null, context);
 }
}

代码示例来源:origin: PegaSysEng/pantheon

@Test
public void accountAddressEquals() {
 final Address addr =
   Address.wrap(BytesValue.fromHexString("0x0000000000000000000000000000000000101010"));
 final Address addr2 =
   Address.wrap(BytesValue.fromHexString("0x0000000000000000000000000000000000101010"));
 Assert.assertEquals(addr, addr2);
}

代码示例来源:origin: PegaSysEng/pantheon

Expectation(
  @JsonProperty("hash") final String hash, @JsonProperty("sender") final String sender) {
 this.succeeds = hash != null && sender != null;
 if (succeeds) {
  this.hash = Hash.fromHexString(hash);
  this.sender = Address.fromHexString(sender);
 } else {
  this.hash = null;
  this.sender = null;
 }
}

代码示例来源:origin: PegaSysEng/pantheon

public ExpectBeneficiary(final EthTransactions eth, final PantheonNode node) {
 this.eth = eth;
 this.beneficiary = node.getAddress().toString();
}

代码示例来源:origin: PegaSysEng/pantheon

@Test
public void proposerInValidatorListPassesValidation() {
 final KeyPair proposerKeyPair = KeyPair.generate();
 final Address proposerAddress =
   Address.extract(Hash.hash(proposerKeyPair.getPublicKey().getEncodedBytes()));
 final List<Address> validators = Lists.newArrayList(proposerAddress);
 final List<KeyPair> committers = Lists.newArrayList(proposerKeyPair);
 final VoteTally voteTally = new VoteTally(validators);
 final ProtocolContext<IbftContext> context =
   new ProtocolContext<>(null, null, new IbftContext(voteTally, null));
 final IbftCoinbaseValidationRule coinbaseValidationRule = new IbftCoinbaseValidationRule();
 BlockHeader header = createProposedBlockHeader(proposerKeyPair, validators, committers);
 assertThat(coinbaseValidationRule.validate(header, null, context)).isTrue();
}

代码示例来源:origin: PegaSysEng/pantheon

private LogWithMetadata logWithMetadata() {
 return LogWithMetadata.create(
   0,
   100L,
   Hash.ZERO,
   Hash.ZERO,
   0,
   Address.fromHexString("0x0"),
   BytesValue.EMPTY,
   Lists.newArrayList(),
   false);
}

代码示例来源:origin: PegaSysEng/pantheon

private List<LogsSubscription> createSubscriptions(final Address address) {
 final List<LogsSubscription> subscriptions = new ArrayList<>();
 for (int i = 0; i < 3; i++) {
  final FilterParameter filterParameter =
    new FilterParameter(null, null, Lists.newArrayList(address.toString()), null, null);
  subscriptions.add(new LogsSubscription((long) i, filterParameter));
 }
 when(subscriptionManager.subscriptionsOfType(any(), any()))
   .thenReturn(Lists.newArrayList(subscriptions));
 return subscriptions;
}

代码示例来源:origin: PegaSysEng/pantheon

@Test
public void ibftValidateHeaderFails() {
 final KeyPair proposerKeyPair = KeyPair.generate();
 final Address proposerAddress =
   Address.extract(Hash.hash(proposerKeyPair.getPublicKey().getEncodedBytes()));
 final List<Address> validators = singletonList(proposerAddress);
 final BlockHeader parentHeader = buildBlockHeader(1, proposerKeyPair, validators, null);
 final BlockHeader blockHeader = buildBlockHeader(2, proposerKeyPair, validators, null);
 final BlockHeaderValidator<IbftContext> validator =
   IbftBlockHeaderValidationRulesetFactory.ibftBlockHeaderValidator(5);
 assertThat(
     validator.validateHeader(
       blockHeader,
       parentHeader,
       IbftProtocolContextFixture.protocolContext(validators),
       HeaderValidationMode.FULL))
   .isFalse();
}

代码示例来源:origin: PegaSysEng/pantheon

private LogWithMetadata logWithMetadata() {
  return LogWithMetadata.create(
    0,
    100L,
    Hash.ZERO,
    Hash.ZERO,
    0,
    Address.fromHexString("0x0"),
    BytesValue.EMPTY,
    Lists.newArrayList(),
    false);
 }
}

代码示例来源:origin: PegaSysEng/pantheon

private LogsSubscription createSubscription(final Address address) {
 final FilterParameter filterParameter =
   new FilterParameter(null, null, Lists.newArrayList(address.toString()), null, null);
 final LogsSubscription logsSubscription = new LogsSubscription(1L, filterParameter);
 when(subscriptionManager.subscriptionsOfType(any(), any()))
   .thenReturn(Lists.newArrayList(logsSubscription));
 return logsSubscription;
}

相关文章