use of com.hedera.services.state.merkle.MerkleAccount in project hedera-services by hashgraph.
the class FcmToJsonUtil method convertAccountsToJson.
@Test
void convertAccountsToJson() throws Exception {
ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleLong.class, MerkleLong::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(FCQueue.class, FCQueue::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleEntityId.class, MerkleEntityId::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(EntityId.class, EntityId::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleAccount.class, MerkleAccount::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleAccountState.class, MerkleAccountState::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(ExpirableTxnRecord.class, ExpirableTxnRecord::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(TxnReceipt.class, TxnReceipt::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(TxnId.class, TxnId::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(CurrencyAdjustments.class, CurrencyAdjustments::new));
ConstructableRegistry.registerConstructable(new ClassConstructorPair(EvmFnResult.class, EvmFnResult::new));
for (String dumpLoc : accountsLocs) {
PojoLedger.fromDisk(dumpLoc).asJsonTo(jsonSuffixed(dumpLoc));
}
}
use of com.hedera.services.state.merkle.MerkleAccount in project hedera-services by hashgraph.
the class PojoLedger method fromDisk.
public static PojoLedger fromDisk(String dumpLoc) throws Exception {
try (MerkleDataInputStream in = new MerkleDataInputStream(Files.newInputStream(Path.of(dumpLoc)))) {
MerkleMap<EntityNum, MerkleAccount> fcm = in.readMerkleTree(Integer.MAX_VALUE);
var pojo = from(fcm);
return pojo;
}
}
use of com.hedera.services.state.merkle.MerkleAccount in project hedera-services by hashgraph.
the class UsageBasedFeeCalculatorTest method delegatesAutoRenewCalcs.
@Test
void delegatesAutoRenewCalcs() {
// setup:
final var expected = new RenewAssessment(456L, 123L);
given(autoRenewCalcs.maxRenewalAndFeeFor(any(), anyLong(), any(), any())).willReturn(expected);
// when:
var actual = subject.assessCryptoAutoRenewal(new MerkleAccount(), 1L, Instant.ofEpochSecond(2L));
// then:
assertSame(expected, actual);
}
use of com.hedera.services.state.merkle.MerkleAccount in project hedera-services by hashgraph.
the class SignedStateBalancesExporterTest method setUp.
@BeforeEach
void setUp() throws ConstructableRegistryException {
ConstructableRegistry.registerConstructable(new ClassConstructorPair(MerkleAccount.class, MerkleAccount::new));
thisNodeAccount = MerkleAccountFactory.newAccount().balance(thisNodeBalance).get();
anotherNodeAccount = MerkleAccountFactory.newAccount().balance(anotherNodeBalance).get();
firstNonNodeAccount = MerkleAccountFactory.newAccount().balance(firstNonNodeAccountBalance).get();
secondNonNodeAccount = MerkleAccountFactory.newAccount().balance(secondNonNodeAccountBalance).tokens(theToken, theDeletedToken, theMissingToken).get();
deletedAccount = MerkleAccountFactory.newAccount().deleted(true).get();
accounts.put(fromAccountId(thisNode), thisNodeAccount);
accounts.put(fromAccountId(anotherNode), anotherNodeAccount);
accounts.put(fromAccountId(firstNonNode), firstNonNodeAccount);
accounts.put(fromAccountId(secondNonNode), secondNonNodeAccount);
accounts.put(fromAccountId(deleted), deletedAccount);
token = mock(MerkleToken.class);
given(token.isDeleted()).willReturn(false);
deletedToken = mock(MerkleToken.class);
given(deletedToken.isDeleted()).willReturn(true);
tokens.put(fromTokenId(theToken), token);
tokens.put(fromTokenId(theDeletedToken), deletedToken);
tokenRels.put(fromAccountTokenRel(secondNonNode, theToken), new MerkleTokenRelStatus(secondNonNodeTokenBalance, false, true, false));
tokenRels.put(fromAccountTokenRel(secondNonNode, theDeletedToken), new MerkleTokenRelStatus(secondNonNodeDeletedTokenBalance, false, true, false));
assurance = mock(DirectoryAssurance.class);
properties = mock(PropertySource.class);
given(properties.getLongProperty("ledger.totalTinyBarFloat")).willReturn(ledgerFloat);
var firstNodeAddress = mock(Address.class);
given(firstNodeAddress.getMemo()).willReturn("0.0.3");
var secondNodeAddress = mock(Address.class);
given(secondNodeAddress.getMemo()).willReturn("0.0.4");
var book = mock(AddressBook.class);
given(book.getSize()).willReturn(2);
given(book.getAddress(0)).willReturn(firstNodeAddress);
given(book.getAddress(1)).willReturn(secondNodeAddress);
state = mock(ServicesState.class);
given(state.getAccountFromNodeId(nodeId)).willReturn(thisNode);
given(state.tokens()).willReturn(tokens);
given(state.accounts()).willReturn(accounts);
given(state.tokenAssociations()).willReturn(tokenRels);
given(state.addressBook()).willReturn(book);
signer = mock(UnaryOperator.class);
given(signer.apply(fileHash)).willReturn(sig);
systemExits = mock(SystemExits.class);
subject = new SignedStateBalancesExporter(systemExits, properties, signer, dynamicProperties);
sigFileWriter = mock(SigFileWriter.class);
hashReader = mock(FileHashReader.class);
subject.sigFileWriter = sigFileWriter;
subject.hashReader = hashReader;
}
use of com.hedera.services.state.merkle.MerkleAccount in project hedera-services by hashgraph.
the class FeeCalcUtilsTest method returnsAccountExpiryIfAvail.
@Test
void returnsAccountExpiryIfAvail() {
// setup:
final var account = mock(MerkleAccount.class);
final MerkleMap<EntityNum, MerkleAccount> accounts = mock(MerkleMap.class);
Timestamp expected = Timestamp.newBuilder().setSeconds(Long.MAX_VALUE).build();
given(account.getExpiry()).willReturn(Long.MAX_VALUE);
given(accounts.get(key)).willReturn(account);
assertEquals(expected, lookupAccountExpiry(key, accounts));
}
Aggregations