88import static com .hedera .services .bdd .junit .TestTags .MATS ;
99import static com .hedera .services .bdd .junit .TestTags .ONLY_SUBPROCESS ;
1010import static com .hedera .services .bdd .junit .hedera .utils .AddressBookUtils .CLASSIC_FIRST_NODE_ACCOUNT_NUM ;
11+ import static com .hedera .services .bdd .spec .HapiPropertySource .asAccountString ;
1112import static com .hedera .services .bdd .spec .HapiSpec .hapiTest ;
1213import static com .hedera .services .bdd .spec .keys .TrieSigMapGenerator .uniqueWithFullPrefixesFor ;
14+ import static com .hedera .services .bdd .spec .queries .QueryVerbs .getAccountInfo ;
1315import static com .hedera .services .bdd .spec .queries .QueryVerbs .getTxnRecord ;
1416import static com .hedera .services .bdd .spec .transactions .TxnVerbs .cryptoCreate ;
1517import static com .hedera .services .bdd .spec .transactions .TxnVerbs .cryptoDelete ;
3638import static com .hederahashgraph .api .proto .java .ResponseCodeEnum .NODE_ACCOUNT_HAS_ZERO_BALANCE ;
3739import static com .hederahashgraph .api .proto .java .ResponseCodeEnum .RECORD_NOT_FOUND ;
3840import static org .junit .jupiter .api .Assertions .assertEquals ;
41+ import static org .junit .jupiter .api .Assertions .assertFalse ;
3942import static org .junit .jupiter .api .Assertions .assertNotNull ;
43+ import static org .junit .jupiter .api .Assertions .assertTrue ;
4044
4145import com .hedera .services .bdd .junit .EmbeddedHapiTest ;
4246import com .hedera .services .bdd .junit .HapiTest ;
4549import com .hedera .services .bdd .junit .support .TestLifecycle ;
4650import com .hederahashgraph .api .proto .java .AccountID ;
4751import edu .umd .cs .findbugs .annotations .NonNull ;
52+ import java .nio .file .Paths ;
4853import java .security .cert .CertificateEncodingException ;
4954import java .security .cert .X509Certificate ;
5055import 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