use of com.hederahashgraph.api.proto.java.ResponseCodeEnum in project hedera-services by hashgraph.
the class GetAccountBalanceAnswerTest method syntaxCheckRequiresId.
@Test
void syntaxCheckRequiresId() {
// given:
CryptoGetAccountBalanceQuery op = CryptoGetAccountBalanceQuery.newBuilder().build();
Query query = Query.newBuilder().setCryptogetAccountBalance(op).build();
// when:
ResponseCodeEnum status = subject.checkValidity(query, view);
// expect:
assertEquals(INVALID_ACCOUNT_ID, status);
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum in project hedera-services by hashgraph.
the class GetAccountBalanceAnswerTest method syntaxCheckValidatesIdIfPresent.
@Test
void syntaxCheckValidatesIdIfPresent() {
// setup:
AccountID id = asAccount(accountIdLit);
// given:
CryptoGetAccountBalanceQuery op = CryptoGetAccountBalanceQuery.newBuilder().setAccountID(id).build();
Query query = Query.newBuilder().setCryptogetAccountBalance(op).build();
// and:
given(optionValidator.queryableAccountStatus(id, accounts)).willReturn(ACCOUNT_DELETED);
// when:
ResponseCodeEnum status = subject.checkValidity(query, view);
// expect:
assertEquals(ACCOUNT_DELETED, status);
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum in project hedera-services by hashgraph.
the class GetAccountBalanceAnswerTest method resolvesAliasIfExtant.
@Test
void resolvesAliasIfExtant() {
final var aliasId = AccountID.newBuilder().setAlias(ByteString.copyFromUtf8("nope")).build();
final var wellKnownId = EntityNum.fromLong(12345L);
given(aliasManager.lookupIdBy(aliasId.getAlias())).willReturn(wellKnownId);
CryptoGetAccountBalanceQuery op = CryptoGetAccountBalanceQuery.newBuilder().setAccountID(aliasId).build();
Query query = Query.newBuilder().setCryptogetAccountBalance(op).build();
Response response = subject.responseGiven(query, view, OK);
ResponseCodeEnum status = response.getCryptogetAccountBalance().getHeader().getNodeTransactionPrecheckCode();
long answer = response.getCryptogetAccountBalance().getBalance();
assertTrue(response.getCryptogetAccountBalance().hasHeader(), "Missing response header!");
assertEquals(List.of(tokenBalanceWith(aToken, aBalance, 1), tokenBalanceWith(bToken, bBalance, 2), tokenBalanceWith(cToken, cBalance, 123), tokenBalanceWith(dToken, dBalance, 0)), response.getCryptogetAccountBalance().getTokenBalancesList());
assertEquals(OK, status);
assertEquals(balance, answer);
assertEquals(wellKnownId.toGrpcAccountId(), response.getCryptogetAccountBalance().getAccountID());
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum in project hedera-services by hashgraph.
the class GetAccountInfoAnswerTest method usesValidatorOnAccountWithAlias.
@Test
void usesValidatorOnAccountWithAlias() throws Throwable {
EntityNum entityNum = EntityNum.fromAccountId(payerId);
Query query = validQueryWithAlias(COST_ANSWER, fee, "aaaa");
given(aliasManager.lookupIdBy(any())).willReturn(entityNum);
given(optionValidator.queryableAccountStatus(entityNum, accounts)).willReturn(INVALID_ACCOUNT_ID);
ResponseCodeEnum validity = subject.checkValidity(query, view);
assertEquals(INVALID_ACCOUNT_ID, validity);
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum in project hedera-services by hashgraph.
the class GetFileInfoAnswerTest method usesValidator.
@Test
void usesValidator() throws Throwable {
// setup:
Query query = validQuery(COST_ANSWER, fee, target);
given(optionValidator.queryableFileStatus(asFile(target), view)).willReturn(FILE_DELETED);
// when:
ResponseCodeEnum validity = subject.checkValidity(query, view);
// then:
assertEquals(FILE_DELETED, validity);
// and:
verify(optionValidator).queryableFileStatus(any(), any());
}
Aggregations