Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into trielog-disk-freed-…
Browse files Browse the repository at this point in the history
…report

Signed-off-by: Simon Dudley <[email protected]>
  • Loading branch information
siladu committed Jan 31, 2024
2 parents 4ec3089 + 1537e96 commit 9a5afe2
Show file tree
Hide file tree
Showing 21 changed files with 129 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.condition.PrivateCondition;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivacyTransactions;

Expand Down Expand Up @@ -112,4 +113,8 @@ public Condition multiTenancyValidationFail(
final Transaction<?> transaction, final RpcErrorType error) {
return new ExpectJsonRpcError(transaction, error);
}

public PrivateCondition syncingStatus(final boolean isSyncing) {
return new PrivateSyncingStatusCondition(transactions.syncing(), isSyncing);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.condition.priv;

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

import org.hyperledger.besu.tests.acceptance.dsl.WaitUtils;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.PrivacyNode;
import org.hyperledger.besu.tests.acceptance.dsl.privacy.condition.PrivateCondition;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy.PrivSyncingTransactions;

public class PrivateSyncingStatusCondition implements PrivateCondition {

private final PrivSyncingTransactions transaction;
private final boolean syncingMiningStatus;

public PrivateSyncingStatusCondition(
final PrivSyncingTransactions transaction, final boolean syncingStatus) {
this.transaction = transaction;
this.syncingMiningStatus = syncingStatus;
}

@Override
public void verify(final PrivacyNode node) {
WaitUtils.waitFor(
10, () -> assertThat(node.execute(transaction)).isEqualTo(syncingMiningStatus));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.transaction.privacy;

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

import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction;

import java.io.IOException;

import org.web3j.protocol.core.methods.response.EthSyncing;

public class PrivSyncingTransactions implements Transaction<Boolean> {

PrivSyncingTransactions() {}

@Override
public Boolean execute(final NodeRequests node) {
try {
EthSyncing response = node.eth().ethSyncing().send();
assertThat(response).isNotNull();
return response.isSyncing();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ public PrivGetEeaTransactionCountTransaction getEeaTransactionCount(
public PrivGetTransactionReceiptTransaction getTransactionReceipt(final Hash transactionHash) {
return new PrivGetTransactionReceiptTransaction(transactionHash);
}

public PrivSyncingTransactions syncing() {
return new PrivSyncingTransactions();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public void setUp() throws Exception {
charlie = createNode(containerNetwork, "node3", 2);

privacyCluster.start(alice, bob, charlie);
alice.verify(priv.syncingStatus(false));
bob.verify(priv.syncingStatus(false));
charlie.verify(priv.syncingStatus(false));
}

private PrivacyNode createNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public DeployPrivateSmartContractAcceptanceTest(
restriction == UNRESTRICTED);

privacyCluster.start(minerNode);
minerNode.verify(priv.syncingStatus(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public EnclaveErrorAcceptanceTest(
"0xBB");
privacyCluster.start(alice, bob);

alice.verify(priv.syncingStatus(false));
bob.verify(priv.syncingStatus(false));

final byte[] wrongPublicKeyBytes =
EnclaveEncryptorType.EC.equals(enclaveEncryptorType)
? getSECP256r1PublicKeyByteArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ public void setUp() throws Exception {
enclaveType,
Optional.of(containerNetwork));
privacyCluster.start(alice, bob, charlie);

alice.verify(priv.syncingStatus(false));
bob.verify(priv.syncingStatus(false));
charlie.verify(priv.syncingStatus(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public void setup() throws IOException {
Optional.empty());

privacyCluster.start(minerNode);

minerNode.verify(priv.syncingStatus(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public PrivCallAcceptanceTest(
restriction == UNRESTRICTED);

privacyCluster.start(minerNode);
minerNode.verify(priv.syncingStatus(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public void setUp() throws IOException, URISyntaxException {
Optional.of(containerNetwork));

privacyCluster.start(aliceNode, bobNode);

aliceNode.verify(priv.syncingStatus(false));
bobNode.verify(priv.syncingStatus(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public PrivDebugGetStateRootOffchainGroupAcceptanceTest(
"0xBB");

privacyCluster.start(aliceNode, bobNode);

aliceNode.verify(priv.syncingStatus(false));
bobNode.verify(priv.syncingStatus(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public PrivGetCodeAcceptanceTest(
restriction == UNRESTRICTED);

privacyCluster.start(alice);
alice.verify(priv.syncingStatus(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public PrivGetLogsAcceptanceTest(
restriction == UNRESTRICTED);

privacyCluster.start(node);
node.verify(priv.syncingStatus(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public PrivGetPrivateTransactionAcceptanceTest(
"0xBB");

privacyCluster.start(alice, bob);

alice.verify(priv.syncingStatus(false));
bob.verify(priv.syncingStatus(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ public PrivacyClusterAcceptanceTest(
false,
false);
privacyCluster.start(alice, bob, charlie);

alice.verify(priv.syncingStatus(false));
bob.verify(priv.syncingStatus(false));
charlie.verify(priv.syncingStatus(false));
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public PrivacyGroupAcceptanceTest(
false,
false);
privacyCluster.start(alice, bob, charlie);

alice.verify(priv.syncingStatus(false));
bob.verify(priv.syncingStatus(false));
charlie.verify(priv.syncingStatus(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public PrivacyReceiptAcceptanceTest(
restriction == UNRESTRICTED,
"0xAA");
privacyCluster.start(alice);

alice.verify(priv.syncingStatus(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public PrivateContractPublicStateAcceptanceTest(
restriction == UNRESTRICTED);

privacyCluster.start(minerNode, transactionNode);

minerNode.verify(priv.syncingStatus(false));
transactionNode.verify(priv.syncingStatus(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public PrivateGenesisAcceptanceTest(
"AA");

privacyCluster.start(alice);
alice.verify(priv.syncingStatus(false));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public PrivateLogFilterAcceptanceTest(
restriction == UNRESTRICTED);

privacyCluster.start(node);
node.verify(priv.syncingStatus(false));
}

@Test
Expand Down

0 comments on commit 9a5afe2

Please sign in to comment.