Skip to content

Commit

Permalink
[PAN-2996] Remove enclave public key from parameter (PegaSysEng#1789)
Browse files Browse the repository at this point in the history
  • Loading branch information
iikirilov authored and lucassaldanha committed Jul 31, 2019
1 parent fc6afda commit 09c1da9
Show file tree
Hide file tree
Showing 14 changed files with 400 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.miner.MinerRequestFactory;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.CustomRequestFactory;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm.PermissioningJsonRpcRequestFactory;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv.PrivRequestFactory;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -293,6 +294,7 @@ private NodeRequests nodeRequests() {
new PermissioningJsonRpcRequestFactory(web3jService),
new AdminRequestFactory(web3jService),
new EeaRequestFactory(web3jService),
new PrivRequestFactory(web3jService),
new CustomRequestFactory(web3jService),
new MinerRequestFactory(web3jService),
websocketService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
package tech.pegasys.pantheon.tests.acceptance.dsl.privacy;

import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eea.EeaSendRawTransactionTransaction;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv.PrivCreatePrivacyGroupTransaction;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv.PrivCreatePrivacyGroupWithoutOptionalParamsTransaction;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv.PrivFindPrivacyGroupTransaction;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv.PrivGetTransactionCountTransaction;

import java.util.List;

public class PrivateTransactions {

public PrivateTransactions() {}
Expand All @@ -33,4 +38,18 @@ public PrivGetTransactionCountTransaction getTransactionCount(
final String address, final String privacyGroupId) {
return new PrivGetTransactionCountTransaction(address, privacyGroupId);
}

public PrivCreatePrivacyGroupTransaction createPrivacyGroup(
final List<String> addresses, final String name, final String description) {
return new PrivCreatePrivacyGroupTransaction(addresses, name, description);
}

public PrivCreatePrivacyGroupWithoutOptionalParamsTransaction
createPrivacyGroupWithoutOptionalParams(final List<String> addresses) {
return new PrivCreatePrivacyGroupWithoutOptionalParamsTransaction(addresses);
}

public PrivFindPrivacyGroupTransaction findPrivacyGroup(final List<String> addresses) {
return new PrivFindPrivacyGroupTransaction(addresses);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.miner.MinerRequestFactory;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.net.CustomRequestFactory;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.perm.PermissioningJsonRpcRequestFactory;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv.PrivRequestFactory;

import java.util.Optional;

Expand All @@ -34,6 +35,7 @@ public class NodeRequests {
private final PermissioningJsonRpcRequestFactory perm;
private final AdminRequestFactory admin;
private final EeaRequestFactory eea;
private final PrivRequestFactory priv;
private final CustomRequestFactory custom;
private final Optional<WebSocketService> websocketService;
private final LoginRequestFactory login;
Expand All @@ -46,6 +48,7 @@ public NodeRequests(
final PermissioningJsonRpcRequestFactory perm,
final AdminRequestFactory admin,
final EeaRequestFactory eea,
final PrivRequestFactory priv,
final CustomRequestFactory custom,
final MinerRequestFactory miner,
final Optional<WebSocketService> websocketService,
Expand All @@ -56,6 +59,7 @@ public NodeRequests(
this.perm = perm;
this.admin = admin;
this.eea = eea;
this.priv = priv;
this.custom = custom;
this.miner = miner;
this.websocketService = websocketService;
Expand Down Expand Up @@ -94,6 +98,10 @@ public EeaRequestFactory eea() {
return eea;
}

public PrivRequestFactory priv() {
return priv;
}

public LoginRequestFactory login() {
return login;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.web3j.protocol.Web3jService;
import org.web3j.protocol.core.Request;
import org.web3j.protocol.core.Response;
import org.web3j.protocol.core.methods.response.EthGetTransactionCount;
import org.web3j.protocol.core.methods.response.Log;

public class EeaRequestFactory {
Expand Down Expand Up @@ -99,13 +98,4 @@ Request<?, PrivateTransactionReceiptResponse> eeaGetTransactionReceipt(final Str
web3jService,
PrivateTransactionReceiptResponse.class);
}

public Request<?, EthGetTransactionCount> privGetTransactionCount(
final String accountAddress, final String privacyGroupId) {
return new Request<>(
"priv_getTransactionCount",
Lists.newArrayList(accountAddress, privacyGroupId),
web3jService,
EthGetTransactionCount.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2019 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv;

import static org.assertj.core.api.Assertions.assertThat;

import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.NodeRequests;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;

import java.io.IOException;
import java.util.List;

public class PrivCreatePrivacyGroupTransaction implements Transaction<String> {

private final List<String> addresses;
private final String name;
private final String description;

public PrivCreatePrivacyGroupTransaction(
final List<String> addresses, final String name, final String description) {

this.addresses = addresses;
this.name = name;
this.description = description;
}

@Override
public String execute(final NodeRequests node) {
try {
PrivRequestFactory.PrivCreatePrivacyGroupResponse result =
node.priv().privCreatePrivacyGroup(addresses, name, description).send();
assertThat(result).isNotNull();
return result.getResult();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright 2019 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv;

import static org.assertj.core.api.Assertions.assertThat;

import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.NodeRequests;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;

import java.io.IOException;
import java.util.List;

public class PrivCreatePrivacyGroupWithoutOptionalParamsTransaction implements Transaction<String> {

private final List<String> addresses;

public PrivCreatePrivacyGroupWithoutOptionalParamsTransaction(final List<String> addresses) {

this.addresses = addresses;
}

@Override
public String execute(final NodeRequests node) {
try {
PrivRequestFactory.PrivCreatePrivacyGroupResponse result =
node.priv().privCreatePrivacyGroupWithoutOptionalParams(addresses).send();
assertThat(result).isNotNull();
return result.getResult();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2019 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv;

import static org.assertj.core.api.Assertions.assertThat;

import tech.pegasys.pantheon.enclave.types.PrivacyGroup;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.NodeRequests;
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction;

import java.io.IOException;
import java.util.List;

public class PrivFindPrivacyGroupTransaction implements Transaction<List<PrivacyGroup>> {

private final List<String> addresses;

public PrivFindPrivacyGroupTransaction(final List<String> addresses) {

this.addresses = addresses;
}

@Override
public List<PrivacyGroup> execute(final NodeRequests node) {
try {
PrivRequestFactory.PrivFindPrivacyGroupResponse result =
node.priv().privFindPrivacyGroup(addresses).send();
assertThat(result).isNotNull();
return result.getResult();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public PrivGetTransactionCountTransaction(
public BigInteger execute(final NodeRequests node) {
try {
EthGetTransactionCount result =
node.eea().privGetTransactionCount(accountAddress, privacyGroupId).send();
node.priv().privGetTransactionCount(accountAddress, privacyGroupId).send();
assertThat(result).isNotNull();
return result.getTransactionCount();
} catch (final IOException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright 2019 ConsenSys AG.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package tech.pegasys.pantheon.tests.acceptance.dsl.transaction.priv;

import tech.pegasys.pantheon.enclave.types.PrivacyGroup;

import java.util.Collections;
import java.util.List;

import org.assertj.core.util.Lists;
import org.web3j.protocol.Web3jService;
import org.web3j.protocol.core.Request;
import org.web3j.protocol.core.Response;
import org.web3j.protocol.core.methods.response.EthGetTransactionCount;

public class PrivRequestFactory {

public static class PrivCreatePrivacyGroupResponse extends Response<String> {}

public static class PrivFindPrivacyGroupResponse extends Response<List<PrivacyGroup>> {}

private final Web3jService web3jService;

public PrivRequestFactory(final Web3jService web3jService) {
this.web3jService = web3jService;
}

public Request<?, EthGetTransactionCount> privGetTransactionCount(
final String accountAddress, final String privacyGroupId) {
return new Request<>(
"priv_getTransactionCount",
Lists.newArrayList(accountAddress, privacyGroupId),
web3jService,
EthGetTransactionCount.class);
}

public Request<?, PrivCreatePrivacyGroupResponse> privCreatePrivacyGroup(
final List<String> addresses, final String name, final String description) {
return new Request<>(
"priv_createPrivacyGroup",
Lists.newArrayList(addresses, name, description),
web3jService,
PrivCreatePrivacyGroupResponse.class);
}

public Request<?, PrivCreatePrivacyGroupResponse> privCreatePrivacyGroupWithoutOptionalParams(
final List<String> addresses) {
return new Request<>(
"priv_createPrivacyGroup",
Collections.singletonList(addresses),
web3jService,
PrivCreatePrivacyGroupResponse.class);
}

public Request<?, PrivFindPrivacyGroupResponse> privFindPrivacyGroup(
final List<String> addresses) {
return new Request<>(
"priv_findPrivacyGroup",
Collections.singletonList(addresses),
web3jService,
PrivFindPrivacyGroupResponse.class);
}
}
Loading

0 comments on commit 09c1da9

Please sign in to comment.