Skip to content

Commit

Permalink
Revert jrs test changes
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Hess <matt.hess@swirldslabs.com>
  • Loading branch information
mhess-swl committed Dec 18, 2024
1 parent e9e237c commit 97c8b9b
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 85 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (C) 2020-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.freeze;

import static com.hedera.services.bdd.spec.HapiSpec.hapiTest;
import static com.hedera.services.bdd.spec.HapiSpec.defaultHapiSpec;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing;
import static com.hedera.services.bdd.suites.freeze.CommonUpgradeResources.initializeSettings;
import static com.hedera.services.bdd.suites.freeze.CommonUpgradeResources.upgradeDelay;
Expand Down Expand Up @@ -33,12 +48,15 @@ public List<Stream<DynamicTest>> getSpecsInSuite() {
return List.of(freezeUpgrade());
}

Stream<DynamicTest> freezeUpgrade() {
return hapiTest(flattened(initializeSettings(), sourcing(() -> UtilVerbs.freezeUpgrade()
.startingIn(upgradeDelay())
.minutes()
.withUpdateFile(upgradeFileId())
.payingWith(GENESIS)
.havingHash(upgradeFileHash()))));
final Stream<DynamicTest> freezeUpgrade() {
return defaultHapiSpec("FreezeUpgrade")
.given(initializeSettings())
.when(sourcing(() -> UtilVerbs.freezeUpgrade()
.startingIn(upgradeDelay())
.minutes()
.withUpdateFile(upgradeFileId())
.payingWith(GENESIS)
.havingHash(upgradeFileHash())))
.then();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (C) 2020-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.freeze;

import static com.hedera.services.bdd.spec.HapiSpec.hapiTest;
import static com.hedera.services.bdd.spec.HapiSpec.defaultHapiSpec;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing;
import static com.hedera.services.bdd.suites.freeze.CommonUpgradeResources.initializeSettings;
import static com.hedera.services.bdd.suites.freeze.CommonUpgradeResources.upgradeFileHash;
Expand Down Expand Up @@ -32,11 +47,14 @@ public List<Stream<DynamicTest>> getSpecsInSuite() {
return List.of(prepareUpgrade());
}

Stream<DynamicTest> prepareUpgrade() {
return hapiTest(flattened(initializeSettings(), sourcing(() -> UtilVerbs.prepareUpgrade()
.withUpdateFile(upgradeFileId())
.signedBy(GENESIS)
.payingWith(GENESIS)
.havingHash(upgradeFileHash()))));
final Stream<DynamicTest> prepareUpgrade() {
return defaultHapiSpec("PrepareUpgrade")
.given(initializeSettings())
.when(sourcing(() -> UtilVerbs.prepareUpgrade()
.withUpdateFile(upgradeFileId())
.signedBy(GENESIS)
.payingWith(GENESIS)
.havingHash(upgradeFileHash())))
.then();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (C) 2020-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.freeze;

import static com.hedera.services.bdd.spec.HapiSpec.hapiTest;
import static com.hedera.services.bdd.spec.HapiSpec.defaultHapiSpec;
import static com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing;
import static com.hedera.services.bdd.suites.freeze.CommonUpgradeResources.initializeSettings;
import static com.hedera.services.bdd.suites.freeze.CommonUpgradeResources.upgradeFileAppendsPerBurst;
Expand Down Expand Up @@ -39,18 +54,21 @@ public List<Stream<DynamicTest>> getSpecsInSuite() {
}

final Stream<DynamicTest> updateFileForUpgrade() {
return hapiTest(flattened(initializeSettings(), sourcing(() -> {
try {
return UtilVerbs.updateSpecialFile(
GENESIS,
upgradeFileId(),
ByteString.copyFrom(Files.readAllBytes(Paths.get(upgradeFilePath()))),
TxnUtils.BYTES_4K,
upgradeFileAppendsPerBurst());
} catch (IOException e) {
e.printStackTrace();
return null;
}
})));
return defaultHapiSpec("UpdateFileForUpgrade")
.given(initializeSettings())
.when(sourcing(() -> {
try {
return UtilVerbs.updateSpecialFile(
GENESIS,
upgradeFileId(),
ByteString.copyFrom(Files.readAllBytes(Paths.get(upgradeFilePath()))),
TxnUtils.BYTES_4K,
upgradeFileAppendsPerBurst());
} catch (IOException e) {
e.printStackTrace();
return null;
}
}))
.then();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
// SPDX-License-Identifier: Apache-2.0
/*
* 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.hapiTest;
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;
Expand Down Expand Up @@ -30,17 +45,18 @@ public List<Stream<DynamicTest>> getSpecsInSuite() {
}

final Stream<DynamicTest> doDelete() {
return hapiTest(flattened(
initializeSettings(),
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),
overridingTwo("nodes.enableDAB", "true", "nodes.updateAccountIdAllowed", "false")));
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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (C) 2020-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.perf.crypto;

import static com.hedera.services.bdd.spec.HapiSpec.hapiTest;
import static com.hedera.services.bdd.spec.HapiSpec.defaultHapiSpec;
import static com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance;
import static com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate;
import static com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer;
Expand Down Expand Up @@ -53,7 +68,7 @@ final Stream<DynamicTest> runCryptoTransfers() {
String receiver = "receiver";
if (settings.getTotalAccounts() > 2) {
int s = r.nextInt(settings.getTotalAccounts());
int re;
int re = 0;
do {
re = r.nextInt(settings.getTotalAccounts());
} while (re == s);
Expand All @@ -79,43 +94,48 @@ final Stream<DynamicTest> runCryptoTransfers() {
};
};

return hapiTest(
withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())),
logIt(ignore -> settings.toString()),
cryptoCreate("sender")
.balance(ignore -> settings.getInitialBalance())
.payingWith(GENESIS)
.withRecharging()
.key(GENESIS)
.rechargeWindow(3)
.stakedNodeId(settings.getNodeToStake())
.logging()
.hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED),
cryptoCreate("receiver")
.payingWith(GENESIS)
.stakedNodeId(settings.getNodeToStake())
.hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED)
.key(GENESIS)
.logging(),
withOpContext((spec, opLog) -> {
List<SpecOperation> ops = new ArrayList<>();
var stakedNodeId = settings.getNodeToStake();
for (int i = 0; i < STAKED_CREATIONS; i++) {
var stakedAccount = "stakedAccount" + i;
if (settings.getExtraNodesToStake().length != 0) {
stakedNodeId = settings.getExtraNodesToStake()[i % settings.getExtraNodesToStake().length];
}
ops.add(cryptoCreate(stakedAccount)
.payingWith("sender")
.stakedNodeId(stakedNodeId)
.fee(ONE_HBAR)
.deferStatusResolution()
.signedBy("sender", DEFAULT_PAYER));
}
allRunFor(spec, ops);
}),
defaultLoadTest(transferBurst, settings),
getAccountBalance("sender").payingWith(GENESIS).logged());
return defaultHapiSpec("RunCryptoTransfers-StakedAccount")
.given(
withOpContext(
(spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())),
logIt(ignore -> settings.toString()))
.when(
cryptoCreate("sender")
.balance(ignore -> settings.getInitialBalance())
.payingWith(GENESIS)
.withRecharging()
.key(GENESIS)
.rechargeWindow(3)
.stakedNodeId(settings.getNodeToStake())
.logging()
.hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED),
cryptoCreate("receiver")
.payingWith(GENESIS)
.stakedNodeId(settings.getNodeToStake())
.hasRetryPrecheckFrom(BUSY, DUPLICATE_TRANSACTION, PLATFORM_TRANSACTION_NOT_CREATED)
.key(GENESIS)
.logging(),
withOpContext((spec, opLog) -> {
List<SpecOperation> ops = new ArrayList<>();
var stakedNodeId = settings.getNodeToStake();
for (int i = 0; i < STAKED_CREATIONS; i++) {
var stakedAccount = "stakedAccount" + i;
if (settings.getExtraNodesToStake().length != 0) {
stakedNodeId =
settings.getExtraNodesToStake()[i % settings.getExtraNodesToStake().length];
}
ops.add(cryptoCreate(stakedAccount)
.payingWith("sender")
.stakedNodeId(stakedNodeId)
.fee(ONE_HBAR)
.deferStatusResolution()
.signedBy("sender", DEFAULT_PAYER));
}
allRunFor(spec, ops);
}))
.then(
defaultLoadTest(transferBurst, settings),
getAccountBalance("sender").payingWith(GENESIS).logged());
}

@Override
Expand Down

0 comments on commit 97c8b9b

Please sign in to comment.