tech.pegasys.pantheon.ethereum.core.Address.fromHexString()方法的使用及代码示例

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

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

Address.fromHexString介绍

暂无

代码示例

代码示例来源: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

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

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

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

@Test
public void multivariateAddressMismatchReturnsFalse() {
 final Address address1 = Address.fromHexString("0x1111111111111111111111111111111111111111");
 final Address address2 = Address.fromHexString("0x2222222222222222222222222222222222222222");
 final LogsQuery query = new LogsQuery.Builder().addresses(address1, address2).build();
 final Address address3 = Address.fromHexString("0x3333333333333333333333333333333333333333");
 final BytesValue data = BytesValue.fromHexString("0x0102");
 final List<LogTopic> topics = new ArrayList<>();
 final Log log = new Log(address3, data, topics);
 assertThat(query.matches(log)).isFalse();
}

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

@Test
public void shouldNotSendLogMessageWhenLogsDoNotMatchAnySubscription() {
 createSubscription(Address.fromHexString("0x0"));
 final Transaction transaction = createTransaction();
 final Log log = createLog(Address.fromHexString("0x1"));
 createLogResult(transaction, log, false);
 logsSubscriptionService.onBlockAdded(createBlockAddedEvent(transaction, null), blockchain);
 verify(subscriptionManager).subscriptionsOfType(any(), any());
 verify(subscriptionManager, times(0)).sendMessage(any(), any());
}

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

@Test
public void univariateAddressMismatchReturnsFalse() {
 final Address address1 = Address.fromHexString("0x1111111111111111111111111111111111111111");
 final LogsQuery query = new LogsQuery.Builder().address(address1).build();
 final Address address2 = Address.fromHexString("0x2222222222222222222222222222222222222222");
 final BytesValue data = BytesValue.fromHexString("0x0102");
 final List<LogTopic> topics = new ArrayList<>();
 final Log log = new Log(address2, data, topics);
 assertThat(query.matches(log)).isFalse();
}

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

@Test
public void revokesAuthVotesInTallyWhenValidatorIsInValidatorList() {
 final VoteProposer proposer = new VoteProposer();
 final Address a1 = Address.fromHexString("1");
 final Address a2 = Address.fromHexString("2");
 final Address a3 = Address.fromHexString("3");
 final VoteTally tally = new VoteTally(Arrays.asList(a1, a2, a3));
 tally.addVote(new ValidatorVote(ADD, localAddress, a1));
 proposer.drop(a1);
 assertThat(proposer.getVote(localAddress, tally))
   .contains(new ValidatorVote(DROP, localAddress, a1));
}

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

@Test
public void revokesDropVotesInTally() {
 final VoteProposer proposer = new VoteProposer();
 final Address a1 = Address.fromHexString("1");
 final Address a2 = Address.fromHexString("2");
 final Address a3 = Address.fromHexString("3");
 proposer.auth(a1);
 final VoteTally tally = new VoteTally(Arrays.asList(a2, a3));
 tally.addVote(new ValidatorVote(DROP, localAddress, a1));
 assertThat(proposer.getVote(localAddress, tally))
   .contains(new ValidatorVote(ADD, localAddress, a1));
}

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

@Test
public void univariateAddressMatchReturnsTrue() {
 final Address address = Address.fromHexString("0x1111111111111111111111111111111111111111");
 final LogsQuery query = new LogsQuery.Builder().address(address).build();
 final List<LogTopic> topics = new ArrayList<>();
 final Log log = new Log(address, BytesValue.fromHexString("0x0102"), topics);
 assertThat(query.matches(log)).isTrue();
}

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

@Test
public void testAuth() {
 final VoteProposer proposer = new VoteProposer();
 final Propose propose = new Propose(proposer, new JsonRpcParameter());
 final Address a0 = Address.fromHexString("0");
 final JsonRpcResponse response = propose.response(requestWithParams(a0, true));
 assertThat(proposer.get(a0)).isEqualTo(Optional.of(VoteType.ADD));
 assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS);
 final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response;
 assertThat(successResponse.getResult()).isEqualTo(true);
}

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

@Test
public void shouldSendLogMessageToAllMatchingSubscriptions() {
 final Address address = Address.fromHexString("0x0");
 final List<LogsSubscription> subscriptions = createSubscriptions(address);
 final Transaction transaction = createTransaction();
 final Log log = createLog(address);
 final LogResult expectedLogResult = createLogResult(transaction, log, false);
 logsSubscriptionService.onBlockAdded(createBlockAddedEvent(transaction, null), blockchain);
 verify(subscriptionManager, times(subscriptions.size()))
   .sendMessage(any(), refEq(expectedLogResult));
}

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

@Test
public void testRepeatDrop() {
 final VoteProposer proposer = new VoteProposer();
 final Propose propose = new Propose(proposer, new JsonRpcParameter());
 final Address a0 = Address.fromHexString("0");
 proposer.drop(a0);
 final JsonRpcResponse response = propose.response(requestWithParams(a0, false));
 assertThat(proposer.get(a0)).isEqualTo(Optional.of(VoteType.DROP));
 assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS);
 final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response;
 assertThat(successResponse.getResult()).isEqualTo(true);
}

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

@Test
public void discardAuth() {
 final VoteProposer proposer = new VoteProposer();
 final Discard discard = new Discard(proposer, new JsonRpcParameter());
 final Address a0 = Address.fromHexString("0");
 proposer.auth(a0);
 final JsonRpcResponse response = discard.response(requestWithParams(a0));
 assertThat(proposer.get(a0)).isEqualTo(Optional.empty());
 assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS);
 final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response;
 assertThat(successResponse.getResult()).isEqualTo(true);
}

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

@Test
public void testChangeToAuth() {
 final VoteProposer proposer = new VoteProposer();
 final Propose propose = new Propose(proposer, new JsonRpcParameter());
 final Address a0 = Address.fromHexString("0");
 proposer.drop(a0);
 final JsonRpcResponse response = propose.response(requestWithParams(a0, true));
 assertThat(proposer.get(a0)).isEqualTo(Optional.of(VoteType.ADD));
 assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS);
 final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response;
 assertThat(successResponse.getResult()).isEqualTo(true);
}

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

@Test
public void discardDrop() {
 final VoteProposer proposer = new VoteProposer();
 final Discard discard = new Discard(proposer, new JsonRpcParameter());
 final Address a0 = Address.fromHexString("0");
 proposer.drop(a0);
 final JsonRpcResponse response = discard.response(requestWithParams(a0));
 assertThat(proposer.get(a0)).isEqualTo(Optional.empty());
 assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS);
 final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response;
 assertThat(successResponse.getResult()).isEqualTo(true);
}

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

@Test
public void discardValidator() {
 final Address parameterAddress = Address.fromHexString("1");
 final JsonRpcRequest request = requestWithParams(parameterAddress);
 final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getId(), true);
 final JsonRpcResponse response = method.response(request);
 assertThat(response).isEqualToComparingFieldByField(expectedResponse);
 verify(voteProposer).discard(parameterAddress);
}

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

@Test
public void addValidator() {
 final Address parameterAddress = Address.fromHexString("1");
 final JsonRpcRequest request = requestWithParams(parameterAddress, "true");
 final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(request.getId(), true);
 final JsonRpcResponse response = method.response(request);
 assertThat(response).isEqualToComparingFieldByField(expectedResponse);
 verify(voteProposer).auth(parameterAddress);
}

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

@Test
public void exceptionWhenNoAuthSupplied() {
 final JsonRpcRequest request = requestWithParams(Address.fromHexString("1"));
 expectedException.expect(InvalidJsonRpcParameters.class);
 expectedException.expectMessage("Missing required json rpc parameter at index 1");
 method.response(request);
}

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

@Test
public void shouldSendLogMessageWhenBlockAddedEventHasRemovedTransactionsMatchingSubscription() {
 final Address address = Address.fromHexString("0x0");
 final LogsSubscription subscription = createSubscription(address);
 final Transaction transaction = createTransaction();
 final Log log = createLog(address);
 final LogResult expectedLogResult = createLogResult(transaction, log, true);
 logsSubscriptionService.onBlockAdded(createBlockAddedEvent(null, transaction), blockchain);
 verify(subscriptionManager).sendMessage(eq(subscription.getId()), refEq(expectedLogResult));
}

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

@Test
public void shouldSendLogMessageWhenBlockAddedEventHasAddedTransactionsMatchingSubscription() {
 final Address address = Address.fromHexString("0x0");
 final LogsSubscription subscription = createSubscription(address);
 final Transaction transaction = createTransaction();
 final Log log = createLog(address);
 final LogResult expectedLogResult = createLogResult(transaction, log, false);
 logsSubscriptionService.onBlockAdded(createBlockAddedEvent(transaction, null), blockchain);
 verify(subscriptionManager).sendMessage(eq(subscription.getId()), refEq(expectedLogResult));
}

相关文章