Search in sources :

Example 1 with BackingAccounts

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()));
}
Also used : AliasManager(com.hedera.services.ledger.accounts.AliasManager) BackingAccounts(com.hedera.services.ledger.backing.BackingAccounts) MerkleMap(com.swirlds.merkle.map.MerkleMap) MerkleAccount(com.hedera.services.state.merkle.MerkleAccount) EntityNum(com.hedera.services.utils.EntityNum) Test(org.junit.jupiter.api.Test)

Aggregations

AliasManager (com.hedera.services.ledger.accounts.AliasManager)1 BackingAccounts (com.hedera.services.ledger.backing.BackingAccounts)1 MerkleAccount (com.hedera.services.state.merkle.MerkleAccount)1 EntityNum (com.hedera.services.utils.EntityNum)1 MerkleMap (com.swirlds.merkle.map.MerkleMap)1 Test (org.junit.jupiter.api.Test)1