use of com.hedera.services.ledger.accounts.AliasManager in project hedera-services by hashgraph.
the class WorldLedgersTest method wrapsAsExpectedWithoutCommitInterceptors.
@Test
void wrapsAsExpectedWithoutCommitInterceptors() {
final var liveTokenRels = new TransactionalLedger<>(TokenRelProperty.class, MerkleTokenRelStatus::new, new HashMapBackingTokenRels(), new ChangeSummaryManager<>());
final var liveAccounts = new TransactionalLedger<>(AccountProperty.class, MerkleAccount::new, new HashMapBackingAccounts(), new ChangeSummaryManager<>());
final var liveNfts = new TransactionalLedger<>(NftProperty.class, MerkleUniqueToken::new, new HashMapBackingNfts(), new ChangeSummaryManager<>());
final var liveTokens = new TransactionalLedger<>(TokenProperty.class, MerkleToken::new, new HashMapBackingTokens(), new ChangeSummaryManager<>());
final var liveAliases = new AliasManager();
final var source = new WorldLedgers(liveAliases, liveTokenRels, liveAccounts, liveNfts, liveTokens);
assertTrue(source.areMutable());
final var nullTokenRels = new WorldLedgers(liveAliases, null, liveAccounts, liveNfts, liveTokens);
final var nullAccounts = new WorldLedgers(liveAliases, liveTokenRels, null, liveNfts, liveTokens);
final var nullNfts = new WorldLedgers(liveAliases, liveTokenRels, liveAccounts, null, liveTokens);
final var nullTokens = new WorldLedgers(liveAliases, liveTokenRels, liveAccounts, liveNfts, null);
assertFalse(nullTokenRels.areMutable());
assertFalse(nullAccounts.areMutable());
assertFalse(nullNfts.areMutable());
assertFalse(nullTokens.areMutable());
final var wrappedUnusable = nullAccounts.wrapped();
assertSame(((StackedContractAliases) wrappedUnusable.aliases()).wrappedAliases(), nullAccounts.aliases());
assertFalse(wrappedUnusable.areMutable());
final var wrappedSource = source.wrapped();
assertSame(liveTokenRels, wrappedSource.tokenRels().getEntitiesLedger());
assertSame(liveAccounts, wrappedSource.accounts().getEntitiesLedger());
assertSame(liveNfts, wrappedSource.nfts().getEntitiesLedger());
assertSame(liveTokens, wrappedSource.tokens().getEntitiesLedger());
final var stackedAliases = (StackedContractAliases) wrappedSource.aliases();
assertSame(liveAliases, stackedAliases.wrappedAliases());
}
use of com.hedera.services.ledger.accounts.AliasManager in project hedera-services by hashgraph.
the class SigOpsRegressionTest method setupFor.
private void setupFor(TxnHandlingScenario scenario) throws Throwable {
hfs = scenario.hfs();
aliasManager = mock(AliasManager.class);
runningAvgs = mock(MiscRunningAvgs.class);
speedometers = mock(MiscSpeedometers.class);
accounts = scenario.accounts();
platformTxn = scenario.platformTxn();
expectedErrorStatus = null;
final var hfsSigMetaLookup = new HfsSigMetaLookup(hfs, fileNumbers);
signingOrder = new SigRequirements(defaultLookupsFor(aliasManager, hfsSigMetaLookup, () -> accounts, () -> null, ref -> null, ref -> null), mockSignatureWaivers);
final var payerKeys = signingOrder.keysForPayer(platformTxn.getTxn(), CODE_ORDER_RESULT_FACTORY);
expectedSigs = new ArrayList<>();
if (payerKeys.hasErrorReport()) {
expectedErrorStatus = payerKeys.getErrorReport();
} else {
PlatformSigsCreationResult payerResult = PlatformSigOps.createCryptoSigsFrom(payerKeys.getOrderedKeys(), new PojoSigMapPubKeyToSigBytes(platformTxn.getSigMap()), new ReusableBodySigningFactory(platformTxn));
expectedSigs.addAll(payerResult.getPlatformSigs());
SigningOrderResult<ResponseCodeEnum> otherKeys = signingOrder.keysForOtherParties(platformTxn.getTxn(), CODE_ORDER_RESULT_FACTORY);
if (otherKeys.hasErrorReport()) {
expectedErrorStatus = otherKeys.getErrorReport();
} else {
PlatformSigsCreationResult otherResult = PlatformSigOps.createCryptoSigsFrom(otherKeys.getOrderedKeys(), new PojoSigMapPubKeyToSigBytes(platformTxn.getSigMap()), new ReusableBodySigningFactory(platformTxn));
if (!otherResult.hasFailed()) {
expectedSigs.addAll(otherResult.getPlatformSigs());
}
}
}
}
use of com.hedera.services.ledger.accounts.AliasManager in project hedera-services by hashgraph.
the class SigVerifierRegressionTest method setupFor.
private void setupFor(TxnHandlingScenario scenario) throws Throwable {
accounts = scenario.accounts();
platformTxn = scenario.platformTxn();
aliasManager = mock(AliasManager.class);
keyOrder = new SigRequirements(defaultLookupsFor(aliasManager, null, () -> accounts, () -> null, ref -> null, ref -> null), mockSignatureWaivers);
final var nodeInfo = mock(NodeInfo.class);
given(nodeInfo.selfAccount()).willReturn(DEFAULT_NODE);
isQueryPayment = PrecheckUtils.queryPaymentTestFor(nodeInfo);
SyncVerifier syncVerifier = new CryptoEngine()::verifySync;
precheckKeyReqs = new PrecheckKeyReqs(keyOrder, isQueryPayment);
precheckVerifier = new PrecheckVerifier(syncVerifier, precheckKeyReqs);
}
use of com.hedera.services.ledger.accounts.AliasManager in project hedera-services by hashgraph.
the class GetAccountBalanceAnswerTest method setup.
@BeforeEach
private void setup() {
deleted = mock(MerkleToken.class);
given(deleted.isDeleted()).willReturn(true);
given(deleted.decimals()).willReturn(123);
notDeleted = mock(MerkleToken.class);
given(notDeleted.isDeleted()).willReturn(false);
given(notDeleted.decimals()).willReturn(1).willReturn(2);
tokenRels = new MerkleMap<>();
tokenRels.put(fromAccountTokenRel(target, aToken), new MerkleTokenRelStatus(aBalance, true, true, true));
tokenRels.put(fromAccountTokenRel(target, bToken), new MerkleTokenRelStatus(bBalance, false, false, false));
tokenRels.put(fromAccountTokenRel(target, cToken), new MerkleTokenRelStatus(cBalance, false, false, true));
tokenRels.put(fromAccountTokenRel(target, dToken), new MerkleTokenRelStatus(dBalance, false, false, true));
accounts = mock(MerkleMap.class);
nodeProps = mock(NodeLocalProperties.class);
given(accounts.get(fromAccountId(asAccount(accountIdLit)))).willReturn(accountV);
given(accounts.get(fromContractId(asContract(contractIdLit)))).willReturn(contractV);
tokenStore = mock(TokenStore.class);
given(tokenStore.exists(aToken)).willReturn(true);
given(tokenStore.exists(bToken)).willReturn(true);
given(tokenStore.exists(cToken)).willReturn(true);
given(tokenStore.exists(dToken)).willReturn(false);
given(tokenStore.get(aToken)).willReturn(notDeleted);
given(tokenStore.get(bToken)).willReturn(notDeleted);
given(tokenStore.get(cToken)).willReturn(deleted);
scheduleStore = mock(ScheduleStore.class);
final MutableStateChildren children = new MutableStateChildren();
children.setAccounts(accounts);
children.setTokenAssociations(tokenRels);
view = new StateView(tokenStore, scheduleStore, children, null);
optionValidator = mock(OptionValidator.class);
aliasManager = mock(AliasManager.class);
subject = new GetAccountBalanceAnswer(aliasManager, optionValidator);
}
use of com.hedera.services.ledger.accounts.AliasManager in project hedera-services by hashgraph.
the class WorldLedgersTest method wrapsAsExpectedWithCommitInterceptors.
@Test
void wrapsAsExpectedWithCommitInterceptors() {
final var liveTokenRels = new TransactionalLedger<>(TokenRelProperty.class, MerkleTokenRelStatus::new, new HashMapBackingTokenRels(), new ChangeSummaryManager<>());
final var liveAccounts = new TransactionalLedger<>(AccountProperty.class, MerkleAccount::new, new HashMapBackingAccounts(), new ChangeSummaryManager<>());
final var liveNfts = new TransactionalLedger<>(NftProperty.class, MerkleUniqueToken::new, new HashMapBackingNfts(), new ChangeSummaryManager<>());
final var liveTokens = new TransactionalLedger<>(TokenProperty.class, MerkleToken::new, new HashMapBackingTokens(), new ChangeSummaryManager<>());
final var liveAliases = new AliasManager();
final var source = new WorldLedgers(liveAliases, liveTokenRels, liveAccounts, liveNfts, liveTokens);
assertTrue(source.areMutable());
final var nullTokenRels = new WorldLedgers(liveAliases, null, liveAccounts, liveNfts, liveTokens);
final var nullAccounts = new WorldLedgers(liveAliases, liveTokenRels, null, liveNfts, liveTokens);
final var nullNfts = new WorldLedgers(liveAliases, liveTokenRels, liveAccounts, null, liveTokens);
final var nullTokens = new WorldLedgers(liveAliases, liveTokenRels, liveAccounts, liveNfts, null);
assertFalse(nullTokenRels.areMutable());
assertFalse(nullAccounts.areMutable());
assertFalse(nullNfts.areMutable());
assertFalse(nullTokens.areMutable());
final var wrappedUnusable = nullAccounts.wrapped(sideEffectsTracker);
assertSame(((StackedContractAliases) wrappedUnusable.aliases()).wrappedAliases(), nullAccounts.aliases());
assertFalse(wrappedUnusable.areMutable());
final var wrappedSource = source.wrapped(sideEffectsTracker);
assertSame(liveTokenRels, wrappedSource.tokenRels().getEntitiesLedger());
assertSame(liveAccounts, wrappedSource.accounts().getEntitiesLedger());
assertSame(liveNfts, wrappedSource.nfts().getEntitiesLedger());
assertSame(liveTokens, wrappedSource.tokens().getEntitiesLedger());
final var stackedAliases = (StackedContractAliases) wrappedSource.aliases();
assertSame(liveAliases, stackedAliases.wrappedAliases());
}
Aggregations