This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PRIV-55] Allow private contract invocations in multiple privacy grou…
…ps (#1318) * Allow private contract invocations in multiple privacy groups
- Loading branch information
Showing
23 changed files
with
720 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...st/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/PrivateAcceptanceTestBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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.privacy; | ||
|
||
import tech.pegasys.orion.testutil.OrionTestHarness; | ||
import tech.pegasys.orion.testutil.OrionTestHarnessFactory; | ||
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters; | ||
import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; | ||
import tech.pegasys.pantheon.tests.acceptance.dsl.jsonrpc.Eea; | ||
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eea.EeaTransactions; | ||
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eea.PrivateTransactionBuilder; | ||
|
||
import java.io.IOException; | ||
|
||
import org.junit.ClassRule; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
public class PrivateAcceptanceTestBase extends AcceptanceTestBase { | ||
@ClassRule public static final TemporaryFolder privacy = new TemporaryFolder(); | ||
|
||
protected final Eea eea; | ||
protected final PrivateTransactions privateTransactions; | ||
protected static PrivateTransactionBuilder.Builder privateTransactionBuilder; | ||
protected final PrivateTransactionVerifier privateTransactionVerifier; | ||
|
||
public PrivateAcceptanceTestBase() { | ||
final EeaTransactions eeaTransactions = new EeaTransactions(); | ||
|
||
privateTransactions = new PrivateTransactions(); | ||
eea = new Eea(eeaTransactions); | ||
privateTransactionBuilder = PrivateTransactionBuilder.builder(); | ||
privateTransactionVerifier = new PrivateTransactionVerifier(eea, transactions); | ||
} | ||
|
||
protected static OrionTestHarness createEnclave( | ||
final String pubKey, final String privKey, final String... othernode) throws Exception { | ||
return OrionTestHarnessFactory.create(privacy.newFolder().toPath(), pubKey, privKey, othernode); | ||
} | ||
|
||
protected static PrivacyParameters getPrivacyParameters(final OrionTestHarness testHarness) | ||
throws IOException { | ||
return new PrivacyParameters.Builder() | ||
.setEnabled(true) | ||
.setEnclaveUrl(testHarness.clientUrl()) | ||
.setEnclavePublicKeyUsingFile(testHarness.getConfig().publicKeys().get(0).toFile()) | ||
.setDataDir(privacy.newFolder().toPath()) | ||
.build(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/privacy/PrivateTransactions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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.privacy; | ||
|
||
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eea.EeaGetTransactionCountTransaction; | ||
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.eea.EeaSendRawTransactionTransaction; | ||
|
||
public class PrivateTransactions { | ||
|
||
public PrivateTransactions() {} | ||
|
||
public EeaSendRawTransactionTransaction deployPrivateSmartContract( | ||
final String signedRawPrivateTransaction) { | ||
return new EeaSendRawTransactionTransaction(signedRawPrivateTransaction); | ||
} | ||
|
||
public EeaSendRawTransactionTransaction createPrivateRawTransaction( | ||
final String signedRawPrivateTransaction) { | ||
return new EeaSendRawTransactionTransaction(signedRawPrivateTransaction); | ||
} | ||
|
||
public EeaGetTransactionCountTransaction getTransactionCount( | ||
final String address, final String privacyGroupId) { | ||
return new EeaGetTransactionCountTransaction(address, privacyGroupId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...asys/pantheon/tests/acceptance/dsl/transaction/eea/EeaGetTransactionCountTransaction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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.eea; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.JsonRequestFactories; | ||
import tech.pegasys.pantheon.tests.acceptance.dsl.transaction.Transaction; | ||
|
||
import java.io.IOException; | ||
import java.math.BigInteger; | ||
|
||
import org.web3j.protocol.core.methods.response.EthGetTransactionCount; | ||
|
||
public class EeaGetTransactionCountTransaction implements Transaction<BigInteger> { | ||
|
||
private final String accountAddress; | ||
private String privacyGroupId; | ||
|
||
public EeaGetTransactionCountTransaction( | ||
final String accountAddress, final String privacyGroupId) { | ||
this.accountAddress = accountAddress; | ||
this.privacyGroupId = privacyGroupId; | ||
} | ||
|
||
@Override | ||
public BigInteger execute(final JsonRequestFactories node) { | ||
try { | ||
EthGetTransactionCount result = | ||
node.eea().eeaGetTransactionCount(accountAddress, privacyGroupId).send(); | ||
assertThat(result).isNotNull(); | ||
return result.getTransactionCount(); | ||
} catch (final IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.