Skip to content

Commit 661de14

Browse files
committed
add record path hapi test
Signed-off-by: ibankov <[email protected]>
1 parent ff52a27 commit 661de14

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

hedera-node/test-clients/src/main/java/com/hedera/services/bdd/spec/transactions/node/HapiNodeUpdate.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public class HapiNodeUpdate extends HapiTxnOp<HapiNodeUpdate> {
4848

4949
private final String nodeName;
5050
private Optional<String> newAccountId = Optional.empty();
51-
private Optional<AccountID> fullNewAccountId = Optional.empty();
5251

5352
private Optional<AccountID> newAccountAlias = Optional.empty();
5453
private Optional<String> newDescription = Optional.empty();
@@ -76,11 +75,6 @@ public HapiNodeUpdate accountId(@NonNull final String accountId) {
7675
return this;
7776
}
7877

79-
public HapiNodeUpdate fullAccountId(@NonNull final AccountID accountId) {
80-
this.fullNewAccountId = Optional.of(accountId);
81-
return this;
82-
}
83-
8478
public HapiNodeUpdate aliasAccountId(@NonNull final String alias) {
8579
this.newAccountAlias = Optional.of(
8680
AccountID.newBuilder().setAlias(ByteString.copyFromUtf8(alias)).build());
@@ -185,11 +179,7 @@ protected Consumer<TransactionBody.Builder> opBodyDef(@NonNull final HapiSpec sp
185179
.<NodeUpdateTransactionBody, NodeUpdateTransactionBody.Builder>body(
186180
NodeUpdateTransactionBody.class, builder -> {
187181
builder.setNodeId(asPosNodeId(nodeName, spec));
188-
if (fullNewAccountId.isPresent()) {
189-
builder.setAccountId(fullNewAccountId.get());
190-
} else {
191-
newAccountId.ifPresent(id -> setNewAccountId(id, spec, builder));
192-
}
182+
newAccountId.ifPresent(id -> setNewAccountId(id, spec, builder));
193183
newAccountAlias.ifPresent(builder::setAccountId);
194184
newDescription.ifPresent(s -> builder.setDescription(StringValue.of(s)));
195185
newAdminKey.ifPresent(builder::setAdminKey);

hedera-node/test-clients/src/main/java/com/hedera/services/bdd/suites/hip869/UpdateAccountEnabledTest.java

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
import static com.hedera.services.bdd.junit.TestTags.MATS;
99
import static com.hedera.services.bdd.junit.TestTags.ONLY_SUBPROCESS;
1010
import static com.hedera.services.bdd.junit.hedera.utils.AddressBookUtils.CLASSIC_FIRST_NODE_ACCOUNT_NUM;
11+
import static com.hedera.services.bdd.spec.HapiPropertySource.asAccountString;
1112
import static com.hedera.services.bdd.spec.HapiSpec.hapiTest;
1213
import static com.hedera.services.bdd.spec.keys.TrieSigMapGenerator.uniqueWithFullPrefixesFor;
14+
import static com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo;
1315
import static com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord;
1416
import static com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate;
1517
import static com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoDelete;
@@ -36,7 +38,9 @@
3638
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.NODE_ACCOUNT_HAS_ZERO_BALANCE;
3739
import static com.hederahashgraph.api.proto.java.ResponseCodeEnum.RECORD_NOT_FOUND;
3840
import static org.junit.jupiter.api.Assertions.assertEquals;
41+
import static org.junit.jupiter.api.Assertions.assertFalse;
3942
import static org.junit.jupiter.api.Assertions.assertNotNull;
43+
import static org.junit.jupiter.api.Assertions.assertTrue;
4044

4145
import com.hedera.services.bdd.junit.EmbeddedHapiTest;
4246
import com.hedera.services.bdd.junit.HapiTest;
@@ -45,6 +49,7 @@
4549
import com.hedera.services.bdd.junit.support.TestLifecycle;
4650
import com.hederahashgraph.api.proto.java.AccountID;
4751
import edu.umd.cs.findbugs.annotations.NonNull;
52+
import java.nio.file.Paths;
4853
import java.security.cert.CertificateEncodingException;
4954
import java.security.cert.X509Certificate;
5055
import java.util.List;
@@ -169,7 +174,7 @@ final Stream<DynamicTest> updateAccountIdWork() throws CertificateEncodingExcept
169174
"testNode",
170175
node -> assertEquals(
171176
newAccountNum.get(),
172-
node.accountId().accountNum(),
177+
node.accountIdOrThrow().accountNum(),
173178
"Node accountId should be updated")))));
174179
}
175180

@@ -225,11 +230,6 @@ final Stream<DynamicTest> accountIdGetsUpdatedCorrectly() {
225230

226231
@EmbeddedHapiTest(NEEDS_STATE_ACCESS)
227232
final Stream<DynamicTest> updateAccountIdRequiredSignatures() {
228-
final AccountID sentinelValue = AccountID.newBuilder()
229-
.setShardNum(0)
230-
.setRealmNum(0)
231-
.setAccountNum(0)
232-
.build();
233233
final AtomicReference<AccountID> initialNodeAccountId = new AtomicReference<>();
234234
final AtomicReference<AccountID> newAccountId = new AtomicReference<>();
235235
return hapiTest(
@@ -248,7 +248,7 @@ final Stream<DynamicTest> updateAccountIdRequiredSignatures() {
248248
}),
249249
// signed with correct sig fails if account is sentinel
250250
nodeUpdate("testNode")
251-
.fullAccountId(sentinelValue)
251+
.accountId("0.0.0")
252252
.payingWith(DEFAULT_PAYER)
253253
.signedByPayerAnd("initialNodeAccount")
254254
.hasPrecheck(INVALID_NODE_ACCOUNT_ID),
@@ -411,4 +411,28 @@ final Stream<DynamicTest> nodeUpdateWithDeletedAccount() throws CertificateEncod
411411
.signedByPayerAnd(deletedAccount, adminKey)
412412
.hasKnownStatus(ACCOUNT_DELETED));
413413
}
414+
415+
@Tag(ONLY_SUBPROCESS)
416+
@HapiTest
417+
final Stream<DynamicTest> accountUpdateBuildsProperRecordPath() {
418+
final AtomicReference<AccountID> newAccountId = new AtomicReference<>();
419+
final AtomicReference<AccountID> oldNodeAccountId = new AtomicReference<>();
420+
final String nodeToUpdate = "3";
421+
final String baseDir = "build/hapi-test/node" + nodeToUpdate + "/data/recordStreams/";
422+
423+
return hapiTest(
424+
cryptoCreate("newAccount").exposingCreatedIdTo(newAccountId::set),
425+
// account 6 is the node account of node 3
426+
getAccountInfo("6").exposingIdTo(oldNodeAccountId::set),
427+
nodeUpdate(nodeToUpdate).accountId("newAccount").signedByPayerAnd("newAccount"),
428+
// create a transaction after the update so record files are generated
429+
cryptoCreate("foo"),
430+
// assert record paths
431+
withOpContext((spec, log) -> {
432+
final var oldRecordPath = Paths.get(baseDir + "record" + asAccountString(oldNodeAccountId.get()));
433+
final var newRecordPath = Paths.get(baseDir + "record" + asAccountString(newAccountId.get()));
434+
assertTrue(oldRecordPath.toFile().exists());
435+
assertFalse(newRecordPath.toFile().exists());
436+
}));
437+
}
414438
}

0 commit comments

Comments
 (0)