use of com.hedera.services.store.models.Account in project hedera-services by hashgraph.
the class CallLocalExecutorTest method processingSuccessfulWithAlias.
@Test
void processingSuccessfulWithAlias() {
// setup:
final var targetAlias = CommonUtils.unhex("6aea3773ea468a814d954e6dec795bfee7d76e25");
final var target = ContractID.newBuilder().setEvmAddress(ByteString.copyFrom(targetAlias)).build();
query = localCallQuery(target, ANSWER_ONLY);
given(aliasManager.lookupIdBy(target.getEvmAddress())).willReturn(EntityNum.fromLong(contractID.num()));
final var transactionProcessingResult = TransactionProcessingResult.successful(new ArrayList<>(), 0, 0, 1, Bytes.EMPTY, callerID.asEvmAddress(), new TreeMap<>());
final var expected = response(OK, transactionProcessingResult);
given(accountStore.loadAccount(any())).willReturn(new Account(callerID));
given(accountStore.loadContract(contractID)).willReturn(new Account(contractID));
given(evmTxProcessor.execute(any(), any(), anyLong(), anyLong(), any(), any())).willReturn(transactionProcessingResult);
// when:
final var result = CallLocalExecutor.execute(accountStore, evmTxProcessor, query, aliasManager);
// then:
assertEquals(expected, result);
}
use of com.hedera.services.store.models.Account in project hedera-services by hashgraph.
the class CallLocalExecutorTest method processingReturnsRevertReason.
@Test
void processingReturnsRevertReason() {
// setup:
final var transactionProcessingResult = TransactionProcessingResult.failed(0, 0, 1, Optional.of(Bytes.of("out of gas".getBytes())), Optional.empty(), Collections.emptyMap());
final var expected = response(CONTRACT_REVERT_EXECUTED, transactionProcessingResult);
given(accountStore.loadAccount(any())).willReturn(new Account(callerID));
given(accountStore.loadContract(any())).willReturn(new Account(contractID));
given(evmTxProcessor.execute(any(), any(), anyLong(), anyLong(), any(), any())).willReturn(transactionProcessingResult);
// when:
final var result = CallLocalExecutor.execute(accountStore, evmTxProcessor, query, aliasManager);
// then:
assertEquals(expected, result);
}
use of com.hedera.services.store.models.Account in project hedera-services by hashgraph.
the class SideEffectsTrackerTest method prioritizesExplicitTokenBalanceChanges.
@Test
void prioritizesExplicitTokenBalanceChanges() {
final var aaRelChange = new TokenRelationship(new Token(Id.fromGrpcToken(aToken)), new Account(Id.fromGrpcAccount(aAccount)));
aaRelChange.getToken().setType(FUNGIBLE_COMMON);
aaRelChange.setBalance(aFirstBalanceChange);
final var bbRelChange = new TokenRelationship(new Token(Id.fromGrpcToken(bToken)), new Account(Id.fromGrpcAccount(bAccount)));
bbRelChange.getToken().setType(FUNGIBLE_COMMON);
final var ccRelChange = new TokenRelationship(new Token(Id.fromGrpcToken(cToken)), new Account(Id.fromGrpcAccount(cAccount)));
ccRelChange.setBalance(cOnlyBalanceChange);
ccRelChange.getToken().setType(FUNGIBLE_COMMON);
subject.trackNftOwnerChange(cSN1, aAccount, bAccount);
subject.trackTokenBalanceChanges(List.of(ccRelChange, bbRelChange, aaRelChange));
final var tokenChanges = subject.getNetTrackedTokenUnitAndOwnershipChanges();
assertEquals(2, tokenChanges.size());
final var aChange = tokenChanges.get(0);
assertEquals(aToken, aChange.getToken());
assertEquals(1, aChange.getTransfersCount());
assertEquals(aFirstBalanceChange, aChange.getTransfers(0).getAmount());
final var cChange = tokenChanges.get(1);
assertEquals(cToken, cChange.getToken());
assertEquals(1, cChange.getTransfersCount());
assertEquals(cOnlyBalanceChange, cChange.getTransfers(0).getAmount());
}
use of com.hedera.services.store.models.Account in project hedera-services by hashgraph.
the class EntityNumPairTest method factoryFromModelRelWorks.
@Test
void factoryFromModelRelWorks() {
final var expected = fromLongs(1, 2);
final var modelRel = new TokenRelationship(new Token(new Id(0, 0, 2)), new Account(new Id(0, 0, 1)));
final var actual = EntityNumPair.fromModelRel(modelRel);
assertEquals(expected, actual);
}
use of com.hedera.services.store.models.Account in project hedera-services by hashgraph.
the class TokenWipeTransitionLogicTest method followsHappyPathForUnique.
@Test
void followsHappyPathForUnique() {
givenValidUniqueTxnCtx();
// needed only in the context of this test
Account acc = mock(Account.class);
var treasury = mock(Account.class);
TokenRelationship treasuryRel = mock(TokenRelationship.class);
TokenRelationship accRel = mock(TokenRelationship.class);
given(token.getTreasury()).willReturn(treasury);
given(accountStore.loadAccount(any())).willReturn(acc);
given(typedTokenStore.loadTokenRelationship(token, acc)).willReturn(accRel);
given(typedTokenStore.loadTokenRelationship(token, token.getTreasury())).willReturn(treasuryRel);
// when:
subject.doStateTransition();
// then:
verify(token).wipe(any(OwnershipTracker.class), any(TokenRelationship.class), anyList());
}
Aggregations