This repository has been archived by the owner on Apr 5, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The Azure keyvault can now be used to sign transactions sent to EthSigner. This includes a new commandline sub-command which creates the signing mechanism with appropriate credentials to connect to, and use Azure.
- Loading branch information
1 parent
910bf62
commit 763c992
Showing
27 changed files
with
926 additions
and
46 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
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
97 changes: 97 additions & 0 deletions
97
.../test/java/tech/pegasys/ethsigner/tests/signing/ValueTransferWithAzureAcceptanceTest.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,97 @@ | ||
/* | ||
* 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.ethsigner.tests.signing; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static tech.pegasys.ethsigner.tests.dsl.Gas.GAS_PRICE; | ||
import static tech.pegasys.ethsigner.tests.dsl.Gas.INTRINSIC_GAS; | ||
|
||
import tech.pegasys.ethsigner.tests.dsl.Account; | ||
import tech.pegasys.ethsigner.tests.dsl.DockerClientFactory; | ||
import tech.pegasys.ethsigner.tests.dsl.node.Node; | ||
import tech.pegasys.ethsigner.tests.dsl.node.NodeConfiguration; | ||
import tech.pegasys.ethsigner.tests.dsl.node.NodeConfigurationBuilder; | ||
import tech.pegasys.ethsigner.tests.dsl.node.PantheonNode; | ||
import tech.pegasys.ethsigner.tests.dsl.signer.Signer; | ||
import tech.pegasys.ethsigner.tests.dsl.signer.SignerConfiguration; | ||
import tech.pegasys.ethsigner.tests.dsl.signer.SignerConfigurationBuilder; | ||
|
||
import java.math.BigInteger; | ||
|
||
import com.github.dockerjava.api.DockerClient; | ||
import org.junit.BeforeClass; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
import org.web3j.protocol.core.methods.request.Transaction; | ||
import org.web3j.utils.Convert; | ||
|
||
@Ignore | ||
public class ValueTransferWithAzureAcceptanceTest { | ||
|
||
private static final String RECIPIENT = "0x1b00ba00ca00bb00aa00bc00be00ac00ca00da00"; | ||
|
||
private static Node ethNode; | ||
private static Signer ethSigner; | ||
|
||
@BeforeClass | ||
public static void setUpBase() { | ||
|
||
final DockerClient docker = new DockerClientFactory().create(); | ||
final NodeConfiguration nodeConfig = new NodeConfigurationBuilder().build(); | ||
|
||
ethNode = new PantheonNode(docker, nodeConfig); | ||
ethNode.start(); | ||
ethNode.awaitStartupCompletion(); | ||
|
||
final SignerConfiguration signerConfig = | ||
new SignerConfigurationBuilder().withAzureKeyVault("ethsignertestkey").build(); | ||
|
||
ethSigner = new Signer(signerConfig, nodeConfig, ethNode.ports()); | ||
ethSigner.start(); | ||
ethSigner.awaitStartupCompletion(); | ||
} | ||
|
||
private Account richBenefactor() { | ||
return ethSigner.accounts().richBenefactor(); | ||
} | ||
|
||
private Signer ethSigner() { | ||
return ethSigner; | ||
} | ||
|
||
private Node ethNode() { | ||
return ethNode; | ||
} | ||
|
||
@Test | ||
public void valueTransfer() { | ||
final BigInteger transferAmountWei = | ||
Convert.toWei("1.75", Convert.Unit.ETHER).toBigIntegerExact(); | ||
final BigInteger startBalance = ethNode().accounts().balance(RECIPIENT); | ||
final Transaction transaction = | ||
Transaction.createEtherTransaction( | ||
richBenefactor().address(), | ||
null, | ||
GAS_PRICE, | ||
INTRINSIC_GAS, | ||
RECIPIENT, | ||
transferAmountWei); | ||
|
||
final String hash = ethSigner().transactions().submit(transaction); | ||
ethNode().transactions().awaitBlockContaining(hash); | ||
|
||
final BigInteger expectedEndBalance = startBalance.add(transferAmountWei); | ||
final BigInteger actualEndBalance = ethNode().accounts().balance(RECIPIENT); | ||
assertThat(actualEndBalance).isEqualTo(expectedEndBalance); | ||
} | ||
} |
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
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
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
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.