27
27
import org .web3j .crypto .TransactionEncoder ;
28
28
import org .web3j .protocol .besu .response .privacy .PrivateTransactionReceipt ;
29
29
import org .web3j .protocol .besu .response .privacy .PrivateTransactionWithPrivacyGroup ;
30
+ import org .web3j .protocol .core .methods .response .EthSendTransaction ;
30
31
import org .web3j .protocol .eea .crypto .PrivateTransactionEncoder ;
31
32
import org .web3j .protocol .eea .crypto .RawPrivateTransaction ;
32
33
import org .web3j .protocol .http .HttpService ;
@@ -86,7 +87,7 @@ public static void setUpOnce() throws InterruptedException, IOException {
86
87
87
88
int blockNumber = 0 ;
88
89
do {
89
- TimeUnit .MINUTES .sleep (1 );
90
+ TimeUnit .SECONDS .sleep (30 );
90
91
blockNumber = rpcNode .ethBlockNumber ().send ().getBlockNumber ().intValue ();
91
92
} while (blockNumber <= 100 );
92
93
}
@@ -113,14 +114,11 @@ public void testConnection() throws IOException {
113
114
public void simplePrivateTransactions () throws Exception {
114
115
115
116
// Build new privacy group using the create API
116
- final Base64String privacyGroupId =
117
- nodeBob .privCreatePrivacyGroup (
118
- Arrays .asList (
119
- ENCLAVE_KEY_ALICE , ENCLAVE_KEY_BOB , ENCLAVE_KEY_CHARLIE ),
120
- "AliceBobCharlie" ,
121
- "AliceBobCharlie group" )
122
- .send ()
123
- .getPrivacyGroupId ();
117
+ Base64String privacyGroupId ;
118
+ do {
119
+ privacyGroupId = getPrivacyGroupId ();
120
+ TimeUnit .SECONDS .sleep (30 );
121
+ } while (privacyGroupId == null );
124
122
125
123
final BigInteger nonce =
126
124
nodeCharlie
@@ -142,9 +140,13 @@ public void simplePrivateTransactions() throws Exception {
142
140
PrivateTransactionEncoder .signMessage (
143
141
rawPrivateTransaction , CHAIN_ID , ALICE ));
144
142
145
- final String transactionHash =
146
- nodeAlice .eeaSendRawTransaction (signedTransactionData ).send ().getTransactionHash ();
143
+ EthSendTransaction eeaTransaction ;
144
+ do {
145
+ eeaTransaction = nodeAlice .eeaSendRawTransaction (signedTransactionData ).send ();
146
+ TimeUnit .SECONDS .sleep (30 );
147
+ } while (eeaTransaction .hasError ());
147
148
149
+ final String transactionHash = eeaTransaction .getTransactionHash ();
148
150
final PollingPrivateTransactionReceiptProcessor receiptProcessor =
149
151
new PollingPrivateTransactionReceiptProcessor (nodeAlice , 1 * 1000 , 120 );
150
152
final PrivateTransactionReceipt receipt =
@@ -304,6 +306,15 @@ public void privacyGroupContract() throws Exception {
304
306
testBalances (tokenAlice , tokenBob , BigInteger .ZERO , BigInteger .TEN );
305
307
}
306
308
309
+ public Base64String getPrivacyGroupId () throws IOException {
310
+ return nodeBob .privCreatePrivacyGroup (
311
+ Arrays .asList (ENCLAVE_KEY_ALICE , ENCLAVE_KEY_BOB , ENCLAVE_KEY_CHARLIE ),
312
+ "AliceBobCharlie" ,
313
+ "AliceBobCharlie group" )
314
+ .send ()
315
+ .getPrivacyGroupId ();
316
+ }
317
+
307
318
private void testBalances (
308
319
final HumanStandardToken tokenAlice ,
309
320
final HumanStandardToken tokenBob ,
0 commit comments