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

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

本文整理了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

  1. /**
  2. * Public constructor.
  3. *
  4. * @param value The value the AccountAddress represents.
  5. */
  6. @JsonCreator
  7. public AddressMock(final String value) {
  8. super(Address.fromHexString(value));
  9. }
  10. }

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

  1. Expectation(
  2. @JsonProperty("hash") final String hash, @JsonProperty("sender") final String sender) {
  3. this.succeeds = hash != null && sender != null;
  4. if (succeeds) {
  5. this.hash = Hash.fromHexString(hash);
  6. this.sender = Address.fromHexString(sender);
  7. } else {
  8. this.hash = null;
  9. this.sender = null;
  10. }
  11. }

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

  1. private LogWithMetadata logWithMetadata() {
  2. return LogWithMetadata.create(
  3. 0,
  4. 100L,
  5. Hash.ZERO,
  6. Hash.ZERO,
  7. 0,
  8. Address.fromHexString("0x0"),
  9. BytesValue.EMPTY,
  10. Lists.newArrayList(),
  11. false);
  12. }

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. @Test
  2. public void testAuth() {
  3. final VoteProposer proposer = new VoteProposer();
  4. final Propose propose = new Propose(proposer, new JsonRpcParameter());
  5. final Address a0 = Address.fromHexString("0");
  6. final JsonRpcResponse response = propose.response(requestWithParams(a0, true));
  7. assertThat(proposer.get(a0)).isEqualTo(Optional.of(VoteType.ADD));
  8. assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS);
  9. final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response;
  10. assertThat(successResponse.getResult()).isEqualTo(true);
  11. }

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

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

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

  1. @Test
  2. public void testRepeatDrop() {
  3. final VoteProposer proposer = new VoteProposer();
  4. final Propose propose = new Propose(proposer, new JsonRpcParameter());
  5. final Address a0 = Address.fromHexString("0");
  6. proposer.drop(a0);
  7. final JsonRpcResponse response = propose.response(requestWithParams(a0, false));
  8. assertThat(proposer.get(a0)).isEqualTo(Optional.of(VoteType.DROP));
  9. assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS);
  10. final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response;
  11. assertThat(successResponse.getResult()).isEqualTo(true);
  12. }

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

  1. @Test
  2. public void discardAuth() {
  3. final VoteProposer proposer = new VoteProposer();
  4. final Discard discard = new Discard(proposer, new JsonRpcParameter());
  5. final Address a0 = Address.fromHexString("0");
  6. proposer.auth(a0);
  7. final JsonRpcResponse response = discard.response(requestWithParams(a0));
  8. assertThat(proposer.get(a0)).isEqualTo(Optional.empty());
  9. assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS);
  10. final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response;
  11. assertThat(successResponse.getResult()).isEqualTo(true);
  12. }

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

  1. @Test
  2. public void testChangeToAuth() {
  3. final VoteProposer proposer = new VoteProposer();
  4. final Propose propose = new Propose(proposer, new JsonRpcParameter());
  5. final Address a0 = Address.fromHexString("0");
  6. proposer.drop(a0);
  7. final JsonRpcResponse response = propose.response(requestWithParams(a0, true));
  8. assertThat(proposer.get(a0)).isEqualTo(Optional.of(VoteType.ADD));
  9. assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS);
  10. final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response;
  11. assertThat(successResponse.getResult()).isEqualTo(true);
  12. }

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

  1. @Test
  2. public void discardDrop() {
  3. final VoteProposer proposer = new VoteProposer();
  4. final Discard discard = new Discard(proposer, new JsonRpcParameter());
  5. final Address a0 = Address.fromHexString("0");
  6. proposer.drop(a0);
  7. final JsonRpcResponse response = discard.response(requestWithParams(a0));
  8. assertThat(proposer.get(a0)).isEqualTo(Optional.empty());
  9. assertThat(response.getType()).isEqualTo(JsonRpcResponseType.SUCCESS);
  10. final JsonRpcSuccessResponse successResponse = (JsonRpcSuccessResponse) response;
  11. assertThat(successResponse.getResult()).isEqualTo(true);
  12. }

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

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

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

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

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

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

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

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

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

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

相关文章