|
|
|
@ -33,32 +33,34 @@ public class PrivateContractPublicStateAcceptanceTest extends PrivacyAcceptanceT |
|
|
|
|
private static final long POW_CHAIN_ID = 2018; |
|
|
|
|
|
|
|
|
|
private PrivacyNode minerNode; |
|
|
|
|
private PrivacyNode transactionNode; |
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
|
public void setUp() throws Exception { |
|
|
|
|
minerNode = |
|
|
|
|
privacyBesu.createPrivateTransactionEnabledMinerNode( |
|
|
|
|
"miner-node", privacyAccountResolver.resolve(0)); |
|
|
|
|
privacyCluster.start(minerNode); |
|
|
|
|
transactionNode = |
|
|
|
|
privacyBesu.createPrivateTransactionEnabledNode( |
|
|
|
|
"transaction-node", privacyAccountResolver.resolve(1)); |
|
|
|
|
privacyCluster.start(minerNode, transactionNode); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void mustAllowAccessToPublicStateFromPrivateTx() throws Exception { |
|
|
|
|
final EventEmitter publicEventEmitter = |
|
|
|
|
minerNode.getBesu().execute((contractTransactions.createSmartContract(EventEmitter.class))); |
|
|
|
|
transactionNode.execute((contractTransactions.createSmartContract(EventEmitter.class))); |
|
|
|
|
|
|
|
|
|
final TransactionReceipt receipt = publicEventEmitter.store(BigInteger.valueOf(12)).send(); |
|
|
|
|
assertThat(receipt).isNotNull(); |
|
|
|
|
|
|
|
|
|
final CrossContractReader reader = |
|
|
|
|
minerNode |
|
|
|
|
.getBesu() |
|
|
|
|
.execute( |
|
|
|
|
privateContractTransactions.createSmartContract( |
|
|
|
|
CrossContractReader.class, |
|
|
|
|
minerNode.getTransactionSigningKey(), |
|
|
|
|
POW_CHAIN_ID, |
|
|
|
|
minerNode.getEnclaveKey())); |
|
|
|
|
transactionNode.execute( |
|
|
|
|
privateContractTransactions.createSmartContract( |
|
|
|
|
CrossContractReader.class, |
|
|
|
|
transactionNode.getTransactionSigningKey(), |
|
|
|
|
POW_CHAIN_ID, |
|
|
|
|
transactionNode.getEnclaveKey())); |
|
|
|
|
|
|
|
|
|
assertThat(reader.read(publicEventEmitter.getContractAddress()).send()) |
|
|
|
|
.isEqualTo(BigInteger.valueOf(12)); |
|
|
|
@ -67,22 +69,19 @@ public class PrivateContractPublicStateAcceptanceTest extends PrivacyAcceptanceT |
|
|
|
|
@Test(expected = ContractCallException.class) |
|
|
|
|
public void mustNotAllowAccessToPrivateStateFromPublicTx() throws Exception { |
|
|
|
|
final EventEmitter privateEventEmitter = |
|
|
|
|
minerNode |
|
|
|
|
.getBesu() |
|
|
|
|
.execute( |
|
|
|
|
(privateContractTransactions.createSmartContract( |
|
|
|
|
EventEmitter.class, |
|
|
|
|
minerNode.getTransactionSigningKey(), |
|
|
|
|
POW_CHAIN_ID, |
|
|
|
|
minerNode.getEnclaveKey()))); |
|
|
|
|
transactionNode.execute( |
|
|
|
|
(privateContractTransactions.createSmartContract( |
|
|
|
|
EventEmitter.class, |
|
|
|
|
transactionNode.getTransactionSigningKey(), |
|
|
|
|
POW_CHAIN_ID, |
|
|
|
|
transactionNode.getEnclaveKey()))); |
|
|
|
|
|
|
|
|
|
final TransactionReceipt receipt = privateEventEmitter.store(BigInteger.valueOf(12)).send(); |
|
|
|
|
assertThat(receipt).isNotNull(); |
|
|
|
|
|
|
|
|
|
final CrossContractReader publicReader = |
|
|
|
|
minerNode |
|
|
|
|
.getBesu() |
|
|
|
|
.execute(contractTransactions.createSmartContract(CrossContractReader.class)); |
|
|
|
|
transactionNode.execute( |
|
|
|
|
contractTransactions.createSmartContract(CrossContractReader.class)); |
|
|
|
|
|
|
|
|
|
publicReader.read(privateEventEmitter.getContractAddress()).send(); |
|
|
|
|
} |
|
|
|
@ -90,19 +89,16 @@ public class PrivateContractPublicStateAcceptanceTest extends PrivacyAcceptanceT |
|
|
|
|
@Test |
|
|
|
|
public void privateContractMustNotBeAbleToCallPublicContractWhichChangesState() throws Exception { |
|
|
|
|
final CrossContractReader privateReader = |
|
|
|
|
minerNode |
|
|
|
|
.getBesu() |
|
|
|
|
.execute( |
|
|
|
|
privateContractTransactions.createSmartContract( |
|
|
|
|
CrossContractReader.class, |
|
|
|
|
minerNode.getTransactionSigningKey(), |
|
|
|
|
POW_CHAIN_ID, |
|
|
|
|
minerNode.getEnclaveKey())); |
|
|
|
|
transactionNode.execute( |
|
|
|
|
privateContractTransactions.createSmartContract( |
|
|
|
|
CrossContractReader.class, |
|
|
|
|
transactionNode.getTransactionSigningKey(), |
|
|
|
|
POW_CHAIN_ID, |
|
|
|
|
transactionNode.getEnclaveKey())); |
|
|
|
|
|
|
|
|
|
final CrossContractReader publicReader = |
|
|
|
|
minerNode |
|
|
|
|
.getBesu() |
|
|
|
|
.execute(contractTransactions.createSmartContract(CrossContractReader.class)); |
|
|
|
|
transactionNode.execute( |
|
|
|
|
contractTransactions.createSmartContract(CrossContractReader.class)); |
|
|
|
|
|
|
|
|
|
final PrivateTransactionReceipt transactionReceipt = |
|
|
|
|
(PrivateTransactionReceipt) |
|
|
|
@ -115,19 +111,16 @@ public class PrivateContractPublicStateAcceptanceTest extends PrivacyAcceptanceT |
|
|
|
|
public void privateContractMustNotBeAbleToCallPublicContractWhichInstantiatesContract() |
|
|
|
|
throws Exception { |
|
|
|
|
final CrossContractReader privateReader = |
|
|
|
|
minerNode |
|
|
|
|
.getBesu() |
|
|
|
|
.execute( |
|
|
|
|
privateContractTransactions.createSmartContract( |
|
|
|
|
CrossContractReader.class, |
|
|
|
|
minerNode.getTransactionSigningKey(), |
|
|
|
|
POW_CHAIN_ID, |
|
|
|
|
minerNode.getEnclaveKey())); |
|
|
|
|
transactionNode.execute( |
|
|
|
|
privateContractTransactions.createSmartContract( |
|
|
|
|
CrossContractReader.class, |
|
|
|
|
transactionNode.getTransactionSigningKey(), |
|
|
|
|
POW_CHAIN_ID, |
|
|
|
|
transactionNode.getEnclaveKey())); |
|
|
|
|
|
|
|
|
|
final CrossContractReader publicReader = |
|
|
|
|
minerNode |
|
|
|
|
.getBesu() |
|
|
|
|
.execute(contractTransactions.createSmartContract(CrossContractReader.class)); |
|
|
|
|
transactionNode.execute( |
|
|
|
|
contractTransactions.createSmartContract(CrossContractReader.class)); |
|
|
|
|
|
|
|
|
|
final PrivateTransactionReceipt transactionReceipt = |
|
|
|
|
(PrivateTransactionReceipt) |
|
|
|
@ -137,19 +130,17 @@ public class PrivateContractPublicStateAcceptanceTest extends PrivacyAcceptanceT |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void privateContractMustNotBeAbleToCallSelfDetructOfPublicContract() throws Exception { |
|
|
|
|
public void privateContractMustNotBeAbleToCallSelfDestructOnPublicContract() throws Exception { |
|
|
|
|
final CrossContractReader privateReader = |
|
|
|
|
minerNode |
|
|
|
|
.getBesu() |
|
|
|
|
.execute( |
|
|
|
|
privateContractTransactions.createSmartContract( |
|
|
|
|
CrossContractReader.class, |
|
|
|
|
minerNode.getTransactionSigningKey(), |
|
|
|
|
POW_CHAIN_ID, |
|
|
|
|
minerNode.getEnclaveKey())); |
|
|
|
|
transactionNode.execute( |
|
|
|
|
privateContractTransactions.createSmartContract( |
|
|
|
|
CrossContractReader.class, |
|
|
|
|
transactionNode.getTransactionSigningKey(), |
|
|
|
|
POW_CHAIN_ID, |
|
|
|
|
transactionNode.getEnclaveKey())); |
|
|
|
|
|
|
|
|
|
final CrossContractReader publicReader = |
|
|
|
|
minerNode |
|
|
|
|
transactionNode |
|
|
|
|
.getBesu() |
|
|
|
|
.execute(contractTransactions.createSmartContract(CrossContractReader.class)); |
|
|
|
|
|
|
|
|
|