Skip to content

Commit

Permalink
test: (cherry-pick) Added a test to submit DAB transactions for JRS t…
Browse files Browse the repository at this point in the history
…est (#15549) (#15616)

Signed-off-by: Neeharika-Sompalli <[email protected]>
  • Loading branch information
Neeharika-Sompalli authored Sep 30, 2024
1 parent 1619a5b commit 3166f30
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 22 deletions.
8 changes: 6 additions & 2 deletions hedera-node/configuration/mainnet/upgrade/throttles.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
"TokenGetNftInfos",
"CryptoApproveAllowance",
"CryptoDeleteAllowance",
"UtilPrng"
"UtilPrng",
"NodeCreate",
"NodeUpdate",
"NodeDelete"
]
},
{
Expand Down Expand Up @@ -146,7 +149,8 @@
"opsPerSec": 0,
"milliOpsPerSec": 2000,
"operations": [
"CryptoCreate"
"CryptoCreate",
"NodeCreate"
]
},
{
Expand Down
8 changes: 6 additions & 2 deletions hedera-node/configuration/testnet/upgrade/throttles.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
"TokenGetNftInfos",
"CryptoApproveAllowance",
"CryptoDeleteAllowance",
"UtilPrng"
"UtilPrng",
"NodeCreate",
"NodeUpdate",
"NodeDelete"
]
},
{
Expand Down Expand Up @@ -146,7 +149,8 @@
"opsPerSec": 0,
"milliOpsPerSec": 2000,
"operations": [
"CryptoCreate"
"CryptoCreate",
"NodeCreate"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ public final class Hedera implements SwirldMain, PlatformStatusChangeListener {
* <p>This registration is a critical side effect that must happen called before any Platform initialization
* steps that try to create or deserialize a {@link MerkleStateRoot}.
*
* @param constructableRegistry the registry to register {@link RuntimeConstructable} factories with
* @param registryFactory the factory to use for creating the services registry
* @param migrator the migrator to use with the services
* @param constructableRegistry the registry to register {@link RuntimeConstructable} factories with
* @param registryFactory the factory to use for creating the services registry
* @param migrator the migrator to use with the services
* @param tssBaseServiceSupplier the supplier for the TSS base service
*/
public Hedera(
Expand Down Expand Up @@ -531,9 +531,9 @@ public void onStateInitialized(
* <p>If the {@code deserializedVersion} is {@code null}, then this is the first time the node has been started,
* and thus all schemas will be executed.
*
* @param state current state
* @param state current state
* @param deserializedVersion version deserialized
* @param trigger trigger that is calling migration
* @param trigger trigger that is calling migration
* @return the state changes caused by the migration
*/
private List<StateChanges.Builder> onMigrate(
Expand Down Expand Up @@ -769,6 +769,7 @@ public void shutdownGrpcServer() {

/**
* Called to set the starting state hash after genesis or restart.
*
* @param stateHash the starting state hash
*/
public void setInitialStateHash(@NonNull final Hash stateHash) {
Expand Down Expand Up @@ -854,6 +855,10 @@ private void initializeDagger(
initialStateHashFuture = new CompletableFuture<>();
notifications.register(ReconnectCompleteListener.class, new ReadReconnectStartingStateHash(notifications));
}
if (initialStateHashFuture == null) {
logger.warn("Starting from Browser is deprecated. Setting initial start hash to empty hash.");
initialStateHashFuture = completedFuture(Bytes.wrap(new byte[48]));
}
// For other triggers the initial state hash must have been set already
requireNonNull(initialStateHashFuture);
final var roundNum = requireNonNull(state.getReadableStates(PlatformStateService.NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
"ContractGetRecords",
"ContractCallLocal",
"TransactionGetRecord",
"GetVersionInfo"
"GetVersionInfo",
"NodeCreate",
"NodeUpdate",
"NodeDelete"
]
},
{
Expand Down Expand Up @@ -104,7 +107,8 @@
{
"opsPerSec": 2000,
"operations": [
"CryptoCreate"
"CryptoCreate",
"NodeCreate"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
"TokenGetNftInfos",
"CryptoApproveAllowance",
"CryptoDeleteAllowance",
"UtilPrng"
"UtilPrng",
"NodeCreate",
"NodeUpdate",
"NodeDelete"
]
},
{
Expand Down Expand Up @@ -146,7 +149,8 @@
"opsPerSec": 0,
"milliOpsPerSec": 2000,
"operations": [
"CryptoCreate"
"CryptoCreate",
"NodeCreate"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.hedera.services.bdd.suites.freeze.PrepareUpgrade;
import com.hedera.services.bdd.suites.freeze.SimpleFreezeOnly;
import com.hedera.services.bdd.suites.freeze.UpdateFileForUpgrade;
import com.hedera.services.bdd.suites.jrs.NodeOpsForUpgrade;
import com.hedera.services.bdd.suites.meta.VersionInfoSpec;
import com.hedera.services.bdd.suites.perf.AdjustFeeScheduleSuite;
import com.hedera.services.bdd.suites.perf.crypto.*;
Expand Down Expand Up @@ -91,6 +92,7 @@ public class SuiteRunner {
put("CreateFilesBeforeReconnect", aof(CreateFilesBeforeReconnect::new));
put("SubmitMessageLoadTest", aof(SubmitMessageLoadTest::new));
put("AdjustFeeSchedule", aof(AdjustFeeScheduleSuite::new));
put("NodeOpsForUpgrade", aof(NodeOpsForUpgrade::new));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import static com.hedera.services.bdd.suites.HapiSuite.NONSENSE_KEY;
import static com.hedera.services.bdd.suites.HapiSuite.ONE_HBAR;
import static com.hedera.services.bdd.suites.HapiSuite.ONE_HUNDRED_HBARS;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.GOSSIP_ENDPOINTS_EXCEEDED_LIMIT;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.GOSSIP_ENDPOINT_CANNOT_HAVE_FQDN;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TX_FEE;
Expand Down Expand Up @@ -495,15 +494,16 @@ final Stream<DynamicTest> validateFeesInsufficientAmount() throws CertificateEnc
}

@HapiTest
final Stream<DynamicTest> failsAtIngestForUnAuthorizedTxns() {
final Stream<DynamicTest> failsAtIngestForUnAuthorizedTxns() throws CertificateEncodingException {
final String description = "His vorpal blade went snicker-snack!";
return hapiTest(
cryptoCreate("payer").balance(ONE_HUNDRED_HBARS),
nodeCreate("ntb")
.payingWith("payer")
.description(description)
.gossipCaCertificate(gossipCertificates.getFirst().getEncoded())
.fee(ONE_HBAR)
.hasPrecheck(BUSY)
.hasKnownStatus(UNAUTHORIZED)
.via("nodeCreation"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import static com.hedera.services.bdd.suites.HapiSuite.GENESIS;
import static com.hedera.services.bdd.suites.HapiSuite.ONE_HBAR;
import static com.hedera.services.bdd.suites.hip869.NodeCreateTest.generateX509Certificates;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TX_FEE;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_NODE_ID;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.NODE_DELETED;
Expand Down Expand Up @@ -159,7 +158,7 @@ final Stream<DynamicTest> failsAtIngestForUnAuthorizedTxns() throws CertificateE
nodeDelete("ntb")
.payingWith("payer")
.fee(ONE_HBAR)
.hasPrecheck(BUSY)
.hasKnownStatus(UNAUTHORIZED)
.via("failedDeletion"))
.when()
.then();
Expand Down Expand Up @@ -195,7 +194,7 @@ final Stream<DynamicTest> handleCanBeExecutedJustWithPrivilegedAccount() throws
nodeDelete(nodeName)
.payingWith("payer")
.signedBy("payer", "wrongKey")
.hasPrecheck(BUSY),
.hasKnownStatus(UNAUTHORIZED),
nodeDelete(nodeName));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import static com.hedera.services.bdd.suites.HapiSuite.NONSENSE_KEY;
import static com.hedera.services.bdd.suites.HapiSuite.ONE_HBAR;
import static com.hedera.services.bdd.suites.hip869.NodeCreateTest.generateX509Certificates;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.BUSY;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.GOSSIP_ENDPOINTS_EXCEEDED_LIMIT;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.GOSSIP_ENDPOINT_CANNOT_HAVE_FQDN;
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ADMIN_KEY;
Expand Down Expand Up @@ -271,7 +270,8 @@ final Stream<DynamicTest> updateAccountIdWork() throws CertificateEncodingExcept
"Node grpcCertificateHash should be updated");
assertEquals(toPbj(updateOp.getAdminKey()), node.adminKey(), "Node adminKey should be updated");
assertEquals(toPbj(asAccount("0.0.100")), node.accountId());
}));
}),
overriding("nodes.updateAccountIdAllowed", "false"));
}

@HapiTest
Expand All @@ -291,7 +291,7 @@ final Stream<DynamicTest> failsAtIngestForUnAuthorizedTxns() throws CertificateE
nodeUpdate("ntb")
.payingWith("payer")
.accountId("0.0.1000")
.hasPrecheck(BUSY)
.hasPrecheck(UPDATE_NODE_ACCOUNT_NOT_ALLOWED)
.fee(ONE_HBAR)
.via("updateNode"))
.when()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
*
* 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 com.hedera.services.bdd.suites.jrs;

import static com.hedera.services.bdd.spec.HapiSpec.defaultHapiSpec;
import static com.hedera.services.bdd.spec.transactions.TxnVerbs.nodeDelete;
import static com.hedera.services.bdd.spec.transactions.TxnVerbs.nodeUpdate;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.overridingTwo;
import static com.hedera.services.bdd.suites.crypto.CryptoCreateSuite.ED_25519_KEY;
import static com.hedera.services.bdd.suites.freeze.CommonUpgradeResources.initializeSettings;

import com.hedera.services.bdd.spec.keys.KeyShape;
import com.hedera.services.bdd.suites.HapiSuite;
import java.util.List;
import java.util.stream.Stream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.DynamicTest;

public class NodeOpsForUpgrade extends HapiSuite {
private static final Logger log = LogManager.getLogger(NodeOpsForUpgrade.class);

public static void main(String... args) {
new NodeOpsForUpgrade().runSuiteSync();
}

@Override
public List<Stream<DynamicTest>> getSpecsInSuite() {
return List.of(doDelete());
}

final Stream<DynamicTest> doDelete() {
return defaultHapiSpec("NodeOpsForUpgrade")
.given(initializeSettings())
.when(
overridingTwo("nodes.enableDAB", "true", "nodes.updateAccountIdAllowed", "true"),
newKeyNamed(ED_25519_KEY).shape(KeyShape.ED25519),
nodeDelete("3").payingWith(GENESIS).signedBy(GENESIS),
nodeUpdate("2")
.description("UpdatedNode0")
.accountId("0.0.100")
.payingWith(GENESIS)
.signedBy(GENESIS))
.then(overridingTwo("nodes.enableDAB", "true", "nodes.updateAccountIdAllowed", "false"));
}

@Override
protected Logger getResultsLogger() {
return log;
}
}

0 comments on commit 3166f30

Please sign in to comment.