Skip to content
Permalink
Browse files

Checkstyle

  • Loading branch information...
iikirilov committed Apr 29, 2019
1 parent 574946c commit 878b404896aa8c1803ebb3279874eb0db1e99960
Showing with 0 additions and 44 deletions.
  1. +0 −44 eea/src/test/java/org/web3j/protocol/eea/RequestTest.java
@@ -1,32 +1,9 @@
package org.web3j.protocol.eea;

import ch.qos.logback.core.encoder.ByteArrayUtil;
import org.bouncycastle.util.encoders.Hex;
import org.junit.Test;

import org.web3j.abi.TypeEncoder;
import org.web3j.abi.datatypes.DynamicArray;
import org.web3j.abi.datatypes.generated.Bytes32;
import org.web3j.crypto.Hash;
import org.web3j.protocol.RequestTester;
import org.web3j.protocol.core.DefaultBlockParameterName;
import org.web3j.protocol.http.HttpService;
import org.web3j.rlp.RlpEncoder;
import org.web3j.rlp.RlpList;
import org.web3j.rlp.RlpString;
import org.web3j.rlp.RlpType;
import org.web3j.utils.Numeric;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;


public class RequestTest extends RequestTester {
@@ -66,25 +43,4 @@ public void testEthGetTransactionCount() throws Exception {
+ "\"id\":1}");
}

@Test
public void test() {
final String privacyGroupId = generatePrivacyGroupId("A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=", Collections.singletonList("Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs="));
assertThat(privacyGroupId, is("0x4479414f69462f796e70632b4a586132594147423062436974536c4f4d4e6d2b53686d422f374d364334773d"));
}

private String generatePrivacyGroupId(final String privateFrom, final List<String> privateFor) {
final List<byte[]> stringList = new ArrayList<>();
stringList.add(Base64.getDecoder().decode(privateFrom));
privateFor.forEach(item -> stringList.add(Base64.getDecoder().decode(item)));

final List<RlpType> rlpList = stringList.stream().distinct()
.sorted(Comparator.comparing(Arrays::hashCode))
.map(RlpString::create).collect(Collectors.toList());

return Numeric.toHexString(
Base64.getEncoder().encode(
Hash.sha3(
RlpEncoder.encode(new RlpList(rlpList)))));
}

}

0 comments on commit 878b404

Please sign in to comment.
You can’t perform that action at this time.