use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.
the class MerkleTopicTest method constructorWithEmptyValuesTestingAccessors.
@Test
void constructorWithEmptyValuesTestingAccessors() {
final var topic = new MerkleTopic("", new JKeyList(), new JKeyList(), 0L, new EntityId(), new RichInstant());
assertDefaultTopicAccessors(topic);
}
use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.
the class StateViewTest method setup.
@BeforeEach
@SuppressWarnings("unchecked")
private void setup() throws Throwable {
metadata = new HFileMeta(false, TxnHandlingScenario.MISC_FILE_WACL_KT.asJKey(), expiry, fileMemo);
immutableMetadata = new HFileMeta(false, StateView.EMPTY_WACL, expiry);
expectedImmutable = FileGetInfoResponse.FileInfo.newBuilder().setLedgerId(ledgerId).setDeleted(false).setExpirationTime(Timestamp.newBuilder().setSeconds(expiry)).setFileID(target).setSize(data.length).build();
expected = expectedImmutable.toBuilder().setKeys(TxnHandlingScenario.MISC_FILE_WACL_KT.asKey().getKeyList()).setMemo(fileMemo).build();
tokenAccount = MerkleAccountFactory.newAccount().isSmartContract(false).tokens(tokenId).get();
tokenAccount.setNftsOwned(10);
tokenAccount.setMaxAutomaticAssociations(123);
tokenAccount.setAlias(TxnHandlingScenario.TOKEN_ADMIN_KT.asKey().getEd25519());
contract = MerkleAccountFactory.newAccount().alias(create2Address).memo("Stay cold...").numKvPairs(wellKnownNumKvPairs).isSmartContract(true).accountKeys(COMPLEX_KEY_ACCOUNT_KT).proxy(asAccount("0.0.3")).senderThreshold(1_234L).receiverThreshold(4_321L).receiverSigRequired(true).balance(555L).autoRenewPeriod(1_000_000L).deleted(true).expirationTime(9_999_999L).get();
contracts = (MerkleMap<EntityNum, MerkleAccount>) mock(MerkleMap.class);
topics = (MerkleMap<EntityNum, MerkleTopic>) mock(MerkleMap.class);
tokenRels = new MerkleMap<>();
tokenRels.put(EntityNumPair.fromLongs(tokenAccountId.getAccountNum(), tokenId.getTokenNum()), new MerkleTokenRelStatus(123L, false, true, true));
tokenStore = mock(TokenStore.class);
token = new MerkleToken(Long.MAX_VALUE, 100, 1, "UnfrozenToken", "UnfrozenTokenName", true, true, new EntityId(0, 0, 3));
token.setMemo(tokenMemo);
token.setAdminKey(TxnHandlingScenario.TOKEN_ADMIN_KT.asJKey());
token.setFreezeKey(TxnHandlingScenario.TOKEN_FREEZE_KT.asJKey());
token.setKycKey(TxnHandlingScenario.TOKEN_KYC_KT.asJKey());
token.setSupplyKey(COMPLEX_KEY_ACCOUNT_KT.asJKey());
token.setWipeKey(MISC_ACCOUNT_KT.asJKey());
token.setFeeScheduleKey(MISC_ACCOUNT_KT.asJKey());
token.setPauseKey(TxnHandlingScenario.TOKEN_PAUSE_KT.asJKey());
token.setAutoRenewAccount(EntityId.fromGrpcAccountId(autoRenew));
token.setExpiry(expiry);
token.setAutoRenewPeriod(autoRenewPeriod);
token.setDeleted(true);
token.setPaused(true);
token.setTokenType(TokenType.FUNGIBLE_COMMON);
token.setSupplyType(TokenSupplyType.FINITE);
token.setFeeScheduleFrom(grpcCustomFees);
scheduleStore = mock(ScheduleStore.class);
final var scheduleMemo = "For what but eye and ear";
parentScheduleCreate = scheduleCreateTxnWith(SCHEDULE_ADMIN_KT.asKey(), scheduleMemo, payerAccountId, creatorAccountID, MiscUtils.asTimestamp(now.toJava()));
schedule = MerkleSchedule.from(parentScheduleCreate.toByteArray(), expiry);
schedule.witnessValidSignature("01234567890123456789012345678901".getBytes());
schedule.witnessValidSignature("_123456789_123456789_123456789_1".getBytes());
schedule.witnessValidSignature("_o23456789_o23456789_o23456789_o".getBytes());
contents = mock(Map.class);
attrs = mock(Map.class);
bytecode = mock(Map.class);
specialFiles = mock(MerkleSpecialFiles.class);
mockTokenRelsFn = (BiFunction<StateView, EntityNum, List<TokenRelationship>>) mock(BiFunction.class);
StateView.tokenRelsFn = mockTokenRelsFn;
final var uniqueTokens = new MerkleMap<EntityNumPair, MerkleUniqueToken>();
uniqueTokens.put(targetNftKey, targetNft);
uniqueTokens.put(treasuryNftKey, treasuryNft);
storage = (VirtualMap<VirtualBlobKey, VirtualBlobValue>) mock(VirtualMap.class);
contractStorage = (VirtualMap<ContractKey, ContractValue>) mock(VirtualMap.class);
children = new MutableStateChildren();
children.setUniqueTokens(uniqueTokens);
children.setAccounts(contracts);
children.setTokenAssociations(tokenRels);
children.setSpecialFiles(specialFiles);
networkInfo = mock(NetworkInfo.class);
subject = new StateView(tokenStore, scheduleStore, children, networkInfo);
subject.fileAttrs = attrs;
subject.fileContents = contents;
subject.contractBytecode = bytecode;
}
use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.
the class ScheduleDelegatingSigMetadataLookupTest method setup.
@BeforeEach
void setup() {
schedule = MerkleSchedule.from(MerkleScheduleTest.scheduleCreateTxnWith(TxnHandlingScenario.TOKEN_ADMIN_KT.asKey(), memo, IdUtils.asAccount("0.0.2"), schedulingAccount.toGrpcAccountId(), schedulingTXValidStart.toGrpc()).toByteArray(), 0L);
schedule.setPayer(new EntityId(0, 0, 2));
scheduleStore = mock(ScheduleStore.class);
subject = DelegatingSigMetadataLookup.SCHEDULE_REF_LOOKUP_FACTORY.apply(scheduleStore);
}
use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.
the class TokenMetaUtilsTest method classifiesRoyaltyWithFallback.
@Test
void classifiesRoyaltyWithFallback() {
// setup:
final var treasury = new EntityId(1, 2, 4);
var royaltyFeeWithFallbackToken = new MerkleToken(Long.MAX_VALUE, 100, 1, "ZPHYR", "West Wind Art", false, true, treasury);
royaltyFeeWithFallbackToken.setTokenType(NON_FUNGIBLE_UNIQUE);
royaltyFeeWithFallbackToken.setFeeSchedule(List.of(FcCustomFee.royaltyFee(1, 2, new FixedFeeSpec(1, null), new EntityId(1, 2, 5))));
// given:
final var meta = TokenMetaUtils.signingMetaFrom(royaltyFeeWithFallbackToken);
// expect:
assertTrue(meta.hasRoyaltyWithFallback());
assertSame(treasury, meta.treasury());
}
use of com.hedera.services.state.submerkle.EntityId in project hedera-services by hashgraph.
the class TokenMetaUtilsTest method classifiesRoyaltyWithNoFallback.
@Test
void classifiesRoyaltyWithNoFallback() {
// setup:
final var treasury = new EntityId(1, 2, 4);
var royaltyFeeNoFallbackToken = new MerkleToken(Long.MAX_VALUE, 100, 1, "ZPHYR", "West Wind Art", false, true, treasury);
royaltyFeeNoFallbackToken.setTokenType(NON_FUNGIBLE_UNIQUE);
royaltyFeeNoFallbackToken.setFeeSchedule(List.of(FcCustomFee.royaltyFee(1, 2, null, new EntityId(1, 2, 5))));
// given:
final var meta = TokenMetaUtils.signingMetaFrom(royaltyFeeNoFallbackToken);
// expect:
assertFalse(meta.hasRoyaltyWithFallback());
assertSame(treasury, meta.treasury());
}
Aggregations