use of com.hedera.services.utils.EntityNum in project hedera-services by hashgraph.
the class ExpirableTxnRecord method deserializeAllowanceMaps.
private void deserializeAllowanceMaps(SerializableDataInputStream in) throws IOException {
var numCryptoAllowances = in.readInt();
if (numCryptoAllowances > 0) {
cryptoAllowances = new TreeMap<>();
}
while (numCryptoAllowances-- > 0) {
final EntityNum owner = EntityNum.fromLong(in.readLong());
cryptoAllowances.put(owner, deserializeCryptoAllowances(in));
}
var numTokenAllowances = in.readInt();
if (numTokenAllowances > 0) {
fungibleTokenAllowances = new TreeMap<>();
}
while (numTokenAllowances-- > 0) {
final EntityNum owner = EntityNum.fromLong(in.readLong());
fungibleTokenAllowances.put(owner, deserializeFungibleTokenAllowances(in));
}
var numNftAllowances = in.readInt();
if (numNftAllowances > 0) {
nftAllowances = new TreeMap<>();
}
while (numNftAllowances-- > 0) {
final EntityNum owner = EntityNum.fromLong(in.readLong());
nftAllowances.put(owner, deserializeNftAllowances(in));
}
}
use of com.hedera.services.utils.EntityNum in project hedera-services by hashgraph.
the class MerkleAccountTest method settersDelegate.
@Test
void settersDelegate() throws NegativeAccountBalanceException {
subject = new MerkleAccount(List.of(delegate, new FCQueue<>(), new FCQueue<>()));
given(delegate.getMaxAutomaticAssociations()).willReturn(maxAutoAssociations);
subject.setExpiry(otherExpiry);
subject.setBalance(otherBalance);
subject.setAutoRenewSecs(otherAutoRenewSecs);
subject.setDeleted(otherDeleted);
subject.setSmartContract(otherSmartContract);
subject.setReceiverSigRequired(otherReceiverSigRequired);
subject.setMemo(otherMemo);
subject.setProxy(otherProxy);
subject.setAccountKey(otherKey);
subject.setKey(new EntityNum(number));
subject.setMaxAutomaticAssociations(maxAutoAssociations);
subject.setAlreadyUsedAutomaticAssociations(alreadyUsedAutoAssociations);
subject.setNftsOwned(2L);
subject.setAlias(alias);
subject.setNumContractKvPairs(kvPairs);
subject.setCryptoAllowances(cryptoAllowances);
subject.setFungibleTokenAllowances(fungibleTokenAllowances);
subject.setNftAllowances(nftAllowances);
verify(delegate).setExpiry(otherExpiry);
verify(delegate).setAutoRenewSecs(otherAutoRenewSecs);
verify(delegate).setDeleted(otherDeleted);
verify(delegate).setSmartContract(otherSmartContract);
verify(delegate).setReceiverSigRequired(otherReceiverSigRequired);
verify(delegate).setMemo(otherMemo);
verify(delegate).setProxy(otherProxy);
verify(delegate).setAccountKey(otherKey);
verify(delegate).setHbarBalance(otherBalance);
verify(delegate).setNumber(number);
verify(delegate).setMaxAutomaticAssociations(maxAutoAssociations);
verify(delegate).setAlreadyUsedAutomaticAssociations(alreadyUsedAutoAssociations);
verify(delegate).setNumContractKvPairs(kvPairs);
verify(delegate).setNftsOwned(2L);
verify(delegate).setAlias(alias);
verify(delegate).setCryptoAllowances(cryptoAllowances);
verify(delegate).setFungibleTokenAllowances(fungibleTokenAllowances);
verify(delegate).setNftAllowances(nftAllowances);
}
use of com.hedera.services.utils.EntityNum 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));
}
use of com.hedera.services.utils.EntityNum in project hedera-services by hashgraph.
the class FcmCustomFeeSchedulesTest method testObjectContract.
@Test
void testObjectContract() {
// given:
MerkleMap<EntityNum, MerkleToken> secondMerkleMap = new MerkleMap<>();
MerkleToken token = new MerkleToken();
final var missingFees = List.of(FcCustomFee.fixedFee(50L, missingToken, feeCollector).asGrpc());
token.setFeeScheduleFrom(missingFees);
secondMerkleMap.put(EntityNum.fromLong(missingToken.num()), new MerkleToken());
final var fees1 = new FcmCustomFeeSchedules(() -> tokens);
final var fees2 = new FcmCustomFeeSchedules(() -> secondMerkleMap);
// expect:
assertNotEquals(fees1, fees2);
assertNotEquals(fees1.hashCode(), fees2.hashCode());
}
use of com.hedera.services.utils.EntityNum in project hedera-services by hashgraph.
the class GetTopicInfoAnswer method checkValidity.
@Override
public ResponseCodeEnum checkValidity(Query query, StateView view) {
MerkleMap<EntityNum, MerkleTopic> topics = view.topics();
ConsensusGetTopicInfoQuery op = query.getConsensusGetTopicInfo();
return validityOf(op, topics);
}
Aggregations