use of com.hedera.services.ledger.backing.BackingAccounts in project hedera-services by hashgraph.
the class RenewalHelperTest method removesAutoAccountEntityWhenExpired.
@Test
void removesAutoAccountEntityWhenExpired() {
MerkleMap<EntityNum, MerkleAccount> accountsMap = new MerkleMap<>();
accountsMap.put(EntityNum.fromLong(nonExpiredAccountNum), nonExpiredAccount);
accountsMap.put(EntityNum.fromLong(brokeExpiredAccountNum), expiredAccountZeroBalance);
AliasManager liveAliasManager = new AliasManager();
linkWellKnownEntities(liveAliasManager);
final var backingAccounts = new BackingAccounts(() -> accountsMap);
backingAccounts.put(IdUtils.asAccount("0.0." + nonExpiredAccountNum), nonExpiredAccount);
backingAccounts.put(IdUtils.asAccount("0.0." + brokeExpiredAccountNum), expiredAccountZeroBalance);
subject = new RenewalHelper(tokenStore, sigImpactHistorian, dynamicProps, () -> tokens, () -> accountsMap, () -> tokenRels, backingAccounts, liveAliasManager);
final var expiredKey = EntityNum.fromLong(brokeExpiredAccountNum);
givenTokenPresent(deletedTokenId, deletedToken);
givenTokenPresent(survivedTokenId, longLivedToken);
givenRelPresent(expiredKey, deletedTokenId, Long.MAX_VALUE);
givenRelPresent(expiredKey, survivedTokenId, tokenBalance);
givenRelPresent(expiredKey, EntityNum.fromTokenId(missingTokenGrpcId), 0);
givenModifiableRelPresent(EntityNum.fromAccountId(treasuryGrpcId), survivedTokenId, 0L);
assertTrue(liveAliasManager.contains(expiredAccountZeroBalance.getAlias()));
assertTrue(backingAccounts.contains(AccountID.newBuilder().setAccountNum(brokeExpiredAccountNum).build()));
subject.classify(brokeExpiredAccountNum, now);
subject.removeLastClassifiedAccount();
assertFalse(backingAccounts.contains(AccountID.newBuilder().setAccountNum(brokeExpiredAccountNum).build()));
}
Aggregations