Search in sources :

Example 56 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.

the class LedgerBalanceChangesTest method happyPathTransfersWithAutoCreation.

@Test
void happyPathTransfersWithAutoCreation() {
    final Key aliasA = KeyFactory.getDefaultInstance().newEd25519();
    final AccountID a = AccountID.newBuilder().setShardNum(0).setRealmNum(0).setAccountNum(10L).build();
    final AccountID validAliasAccountWithAlias = AccountID.newBuilder().setAlias(aliasA.toByteString()).build();
    final AccountID validAliasAccountWithId = AccountID.newBuilder().setShardNum(0).setRealmNum(0).setAccountNum(11L).build();
    final AccountID funding = AccountID.newBuilder().setShardNum(0).setRealmNum(0).setAccountNum(98L).build();
    final EntityNum validAliasEntityNum = new EntityNum(11);
    List<BalanceChange> changes = new ArrayList<>();
    changes.add(hbarChange(a, -100));
    changes.add(hbarChange(validAliasAccountWithAlias, 0));
    final var validAliasAccount = MerkleAccountFactory.newAccount().get();
    final var fundingAccount = MerkleAccountFactory.newAccount().get();
    final var aAccount = MerkleAccountFactory.newAccount().balance(aStartBalance).get();
    backingAccounts.put(a, aAccount);
    backingAccounts.put(validAliasAccountWithId, validAliasAccount);
    backingAccounts.put(funding, fundingAccount);
    given(autoCreationLogic.create(any(), eq(accountsLedger))).willAnswer(invocationOnMock -> {
        final var change = (BalanceChange) invocationOnMock.getArgument(0);
        change.replaceAliasWith(validAliasEntityNum.toGrpcAccountId());
        return Pair.of(OK, 100L);
    });
    given(dynamicProperties.fundingAccount()).willReturn(funding);
    subject.begin();
    assertDoesNotThrow(() -> subject.doZeroSum(changes));
    subject.commit();
    assertEquals(aStartBalance - 100, backingAccounts.getImmutableRef(a).getBalance());
    assertEquals(0, backingAccounts.getImmutableRef(validAliasEntityNum.toGrpcAccountId()).getBalance());
}
Also used : AccountID(com.hederahashgraph.api.proto.java.AccountID) ArrayList(java.util.ArrayList) Key(com.hederahashgraph.api.proto.java.Key) EntityNum(com.hedera.services.utils.EntityNum) Test(org.junit.jupiter.api.Test)

Example 57 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.

the class MerkleAccountPropertyTest method gettersAndSettersWork.

@Test
void gettersAndSettersWork() throws Exception {
    final boolean origIsDeleted = false;
    final boolean origIsReceiverSigReq = false;
    final boolean origIsContract = false;
    final long origBalance = 1L;
    final long origAutoRenew = 1L;
    final long origNumNfts = 123L;
    final long origExpiry = 1L;
    final int origMaxAutoAssociations = 10;
    final int origAlreadyUsedAutoAssociations = 7;
    final var origKey = SignedTxnFactory.DEFAULT_PAYER_KT.asKey();
    final String origMemo = "a";
    final var origProxy = AccountID.getDefaultInstance();
    final List<ExpirableTxnRecord> origRecords = new ArrayList<>();
    origRecords.add(expirableRecord(ResponseCodeEnum.MODIFYING_IMMUTABLE_CONTRACT));
    origRecords.add(expirableRecord(ResponseCodeEnum.INVALID_PAYER_SIGNATURE));
    final List<ExpirableTxnRecord> origPayerRecords = new ArrayList<>();
    origPayerRecords.add(expirableRecord(ResponseCodeEnum.INVALID_CHUNK_NUMBER));
    origPayerRecords.add(expirableRecord(ResponseCodeEnum.INSUFFICIENT_TX_FEE));
    final boolean newIsDeleted = true;
    final boolean newIsReceiverSigReq = true;
    final boolean newIsContract = true;
    final long newBalance = 2L;
    final long newAutoRenew = 2L;
    final long newExpiry = 2L;
    final long newNumNfts = 321L;
    final int newMaxAutoAssociations = 15;
    final int newAlreadyUsedAutoAssociations = 11;
    final JKey newKey = new JKeyList();
    final String newMemo = "b";
    final EntityId newProxy = new EntityId(0, 0, 2);
    final var oldAlias = ByteString.copyFromUtf8("then");
    final var newAlias = ByteString.copyFromUtf8("now");
    final int oldNumKvPairs = 123;
    final int newNumKvPairs = 123;
    final long initialAllowance = 100L;
    final AccountID payer = AccountID.newBuilder().setAccountNum(12345L).build();
    final AccountID owner = AccountID.newBuilder().setAccountNum(12347L).build();
    final EntityNum payerNum = EntityNum.fromAccountId(payer);
    final TokenID fungibleTokenID = TokenID.newBuilder().setTokenNum(1234L).build();
    final TokenID nonFungibleTokenID = TokenID.newBuilder().setTokenNum(1235L).build();
    final FcTokenAllowanceId fungibleAllowanceId = FcTokenAllowanceId.from(EntityNum.fromTokenId(fungibleTokenID), payerNum);
    final FcTokenAllowanceId nftAllowanceId = FcTokenAllowanceId.from(EntityNum.fromTokenId(nonFungibleTokenID), payerNum);
    final TreeMap<EntityNum, Long> cryptoAllowances = new TreeMap<>() {

        {
            put(payerNum, initialAllowance);
        }
    };
    final TreeMap<FcTokenAllowanceId, Long> fungibleAllowances = new TreeMap<>() {

        {
            put(fungibleAllowanceId, initialAllowance);
        }
    };
    final TreeMap<FcTokenAllowanceId, FcTokenAllowance> nftAllowances = new TreeMap<>() {

        {
            put(fungibleAllowanceId, FcTokenAllowance.from(true));
            put(nftAllowanceId, FcTokenAllowance.from(List.of(1L, 2L)));
        }
    };
    final var account = new HederaAccountCustomizer().key(JKey.mapKey(origKey)).expiry(origExpiry).proxy(EntityId.fromGrpcAccountId(origProxy)).autoRenewPeriod(origAutoRenew).isDeleted(origIsDeleted).alias(oldAlias).memo(origMemo).isSmartContract(origIsContract).isReceiverSigRequired(origIsReceiverSigReq).customizing(new MerkleAccount());
    account.setNumContractKvPairs(oldNumKvPairs);
    account.setNftsOwned(origNumNfts);
    account.setBalance(origBalance);
    account.records().offer(origPayerRecords.get(0));
    account.records().offer(origPayerRecords.get(1));
    account.setMaxAutomaticAssociations(origMaxAutoAssociations);
    account.setAlreadyUsedAutomaticAssociations(origAlreadyUsedAutoAssociations);
    final var adminKey = TOKEN_ADMIN_KT.asJKeyUnchecked();
    final var unfrozenToken = new MerkleToken(Long.MAX_VALUE, 100, 1, "UnfrozenToken", "UnfrozenTokenName", false, true, new EntityId(1, 2, 3));
    unfrozenToken.setFreezeKey(adminKey);
    unfrozenToken.setKycKey(adminKey);
    final var frozenToken = new MerkleToken(Long.MAX_VALUE, 100, 1, "FrozenToken", "FrozenTokenName", true, false, new EntityId(1, 2, 3));
    frozenToken.setFreezeKey(adminKey);
    frozenToken.setKycKey(adminKey);
    ALIAS.setter().accept(account, newAlias);
    IS_DELETED.setter().accept(account, newIsDeleted);
    IS_RECEIVER_SIG_REQUIRED.setter().accept(account, newIsReceiverSigReq);
    IS_SMART_CONTRACT.setter().accept(account, newIsContract);
    BALANCE.setter().accept(account, newBalance);
    AUTO_RENEW_PERIOD.setter().accept(account, newAutoRenew);
    EXPIRY.setter().accept(account, newExpiry);
    KEY.setter().accept(account, newKey);
    MEMO.setter().accept(account, newMemo);
    PROXY.setter().accept(account, newProxy);
    NUM_NFTS_OWNED.setter().accept(account, newNumNfts);
    MAX_AUTOMATIC_ASSOCIATIONS.setter().accept(account, newMaxAutoAssociations);
    ALREADY_USED_AUTOMATIC_ASSOCIATIONS.setter().accept(account, newAlreadyUsedAutoAssociations);
    NUM_CONTRACT_KV_PAIRS.setter().accept(account, newNumKvPairs);
    CRYPTO_ALLOWANCES.setter().accept(account, cryptoAllowances);
    FUNGIBLE_TOKEN_ALLOWANCES.setter().accept(account, fungibleAllowances);
    NFT_ALLOWANCES.setter().accept(account, nftAllowances);
    assertEquals(newIsDeleted, IS_DELETED.getter().apply(account));
    assertEquals(newIsReceiverSigReq, IS_RECEIVER_SIG_REQUIRED.getter().apply(account));
    assertEquals(newIsContract, IS_SMART_CONTRACT.getter().apply(account));
    assertEquals(newBalance, BALANCE.getter().apply(account));
    assertEquals(newAutoRenew, AUTO_RENEW_PERIOD.getter().apply(account));
    assertEquals(newExpiry, EXPIRY.getter().apply(account));
    assertEquals(newKey, KEY.getter().apply(account));
    assertEquals(newMemo, MEMO.getter().apply(account));
    assertEquals(newProxy, PROXY.getter().apply(account));
    assertEquals(newNumNfts, NUM_NFTS_OWNED.getter().apply(account));
    assertEquals(newAlreadyUsedAutoAssociations, ALREADY_USED_AUTOMATIC_ASSOCIATIONS.getter().apply(account));
    assertEquals(newMaxAutoAssociations, MAX_AUTOMATIC_ASSOCIATIONS.getter().apply(account));
    assertEquals(newAlias, ALIAS.getter().apply(account));
    assertEquals(newNumKvPairs, NUM_CONTRACT_KV_PAIRS.getter().apply(account));
    assertEquals(cryptoAllowances, CRYPTO_ALLOWANCES.getter().apply(account));
    assertEquals(fungibleAllowances, FUNGIBLE_TOKEN_ALLOWANCES.getter().apply(account));
    assertEquals(nftAllowances, NFT_ALLOWANCES.getter().apply(account));
}
Also used : ExpirableTxnRecord(com.hedera.services.state.submerkle.ExpirableTxnRecord) JKeyList(com.hedera.services.legacy.core.jproto.JKeyList) AccountID(com.hederahashgraph.api.proto.java.AccountID) MerkleToken(com.hedera.services.state.merkle.MerkleToken) ArrayList(java.util.ArrayList) MerkleAccount(com.hedera.services.state.merkle.MerkleAccount) ByteString(com.google.protobuf.ByteString) TreeMap(java.util.TreeMap) EntityNum(com.hedera.services.utils.EntityNum) EntityId(com.hedera.services.state.submerkle.EntityId) FcTokenAllowanceId(com.hedera.services.state.submerkle.FcTokenAllowanceId) JKey(com.hedera.services.legacy.core.jproto.JKey) TokenID(com.hederahashgraph.api.proto.java.TokenID) FcTokenAllowance(com.hedera.services.state.submerkle.FcTokenAllowance) HederaAccountCustomizer(com.hedera.services.ledger.accounts.HederaAccountCustomizer) Test(org.junit.jupiter.api.Test)

Example 58 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.

the class SeqNoEntityIdSourceTest method returnsExpectedAccountId.

@Test
void returnsExpectedAccountId() {
    given(seqNo.getAndIncrement()).willReturn(555L);
    // when:
    AccountID newId = subject.newAccountId(sponsor);
    // then:
    assertEquals(asAccount("1.2.555"), newId);
}
Also used : AccountID(com.hederahashgraph.api.proto.java.AccountID) Test(org.junit.jupiter.api.Test)

Example 59 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.

the class ScheduleExecutionSpecs method scheduledXferFailingWithUnassociatedAccountTransferPaysServiceFeeButNoImpact.

private HapiApiSpec scheduledXferFailingWithUnassociatedAccountTransferPaysServiceFeeButNoImpact() {
    String xToken = "XXX";
    String validSchedule = "withAssociatedToken";
    String invalidSchedule = "withUnassociatedToken";
    String schedulePayer = "somebody", xTreasury = "xt", xCivilian = "xc", nonXCivilian = "nxc";
    String successTxn = "good", failedTxn = "bad";
    AtomicReference<Map<AccountID, Long>> successFeesObs = new AtomicReference<>();
    AtomicReference<Map<AccountID, Long>> failureFeesObs = new AtomicReference<>();
    return defaultHapiSpec("ScheduledXferFailingWithUnassociatedAccountTransferPaysServiceFeeButNoImpact").given(cryptoCreate(schedulePayer), cryptoCreate(xTreasury), cryptoCreate(xCivilian), cryptoCreate(nonXCivilian), tokenCreate(xToken).treasury(xTreasury).initialSupply(101), tokenAssociate(xCivilian, xToken)).when(scheduleCreate(validSchedule, cryptoTransfer(moving(1, xToken).between(xTreasury, xCivilian))).via(successTxn).alsoSigningWith(xTreasury, schedulePayer).designatingPayer(schedulePayer), getAccountBalance(xTreasury).hasTokenBalance(xToken, 100), getAccountBalance(xCivilian).hasTokenBalance(xToken, 1), getTxnRecord(successTxn).scheduled().logged().revealingDebitsTo(successFeesObs::set), scheduleCreate(invalidSchedule, cryptoTransfer(moving(1, xToken).between(xTreasury, nonXCivilian))).via(failedTxn).alsoSigningWith(xTreasury, schedulePayer).designatingPayer(schedulePayer)).then(getTxnRecord(failedTxn).scheduled().hasPriority(recordWith().status(TOKEN_NOT_ASSOCIATED_TO_ACCOUNT)).revealingDebitsTo(failureFeesObs::set), getAccountBalance(xTreasury).hasTokenBalance(xToken, 100), getAccountInfo(nonXCivilian).hasNoTokenRelationship(xToken), assertionsHold((spec, opLog) -> assertBasicallyIdentical(successFeesObs.get(), failureFeesObs.get(), 1.0)));
}
Also used : ACCOUNT_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_DELETED) INVALID_NFT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_NFT_ID) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) INVALID_TRANSACTION_BODY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TRANSACTION_BODY) Random(java.util.Random) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) TxnVerbs.tokenDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenDelete) HapiGetTxnRecord(com.hedera.services.bdd.spec.queries.meta.HapiGetTxnRecord) HapiSpecSetup(com.hedera.services.bdd.spec.HapiSpecSetup) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) TxnUtils.asId(com.hedera.services.bdd.spec.transactions.TxnUtils.asId) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) NO_NEW_VALID_SIGNATURES(com.hederahashgraph.api.proto.java.ResponseCodeEnum.NO_NEW_VALID_SIGNATURES) INVALID_TOKEN_MINT_AMOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_MINT_AMOUNT) Map(java.util.Map) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) HapiCryptoTransfer.tinyBarsFromTo(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromTo) INVALID_ACCOUNT_AMOUNTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ACCOUNT_AMOUNTS) SCHEDULE_ALREADY_EXECUTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SCHEDULE_ALREADY_EXECUTED) BATCH_SIZE_LIMIT_EXCEEDED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BATCH_SIZE_LIMIT_EXCEEDED) MESSAGE_SIZE_TOO_LARGE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.MESSAGE_SIZE_TOO_LARGE) TxnVerbs.scheduleCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.scheduleCreate) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) TxnVerbs.deleteTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.deleteTopic) TxnVerbs.submitMessageTo(com.hedera.services.bdd.spec.transactions.TxnVerbs.submitMessageTo) INVALID_TOKEN_BURN_AMOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_BURN_AMOUNT) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) TOKEN_NOT_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT) ByteString(com.google.protobuf.ByteString) AccountAmount(com.hederahashgraph.api.proto.java.AccountAmount) List(java.util.List) Logger(org.apache.logging.log4j.Logger) UtilVerbs.assertionsHold(com.hedera.services.bdd.spec.utilops.UtilVerbs.assertionsHold) TxnVerbs.grantTokenKyc(com.hedera.services.bdd.spec.transactions.TxnVerbs.grantTokenKyc) UNRESOLVABLE_REQUIRED_SIGNERS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNRESOLVABLE_REQUIRED_SIGNERS) TxnUtils.randomUppercase(com.hedera.services.bdd.spec.transactions.TxnUtils.randomUppercase) UtilVerbs.usableTxnIdNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.usableTxnIdNamed) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) METADATA_TOO_LONG(com.hederahashgraph.api.proto.java.ResponseCodeEnum.METADATA_TOO_LONG) TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN) TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) INSUFFICIENT_ACCOUNT_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) QueryVerbs.getTokenInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTokenInfo) QueryVerbs.getTopicInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTopicInfo) TxnVerbs.createTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.createTopic) AtomicReference(java.util.concurrent.atomic.AtomicReference) EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS) TOKEN_WAS_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_WAS_DELETED) TOKEN_HAS_NO_SUPPLY_KEY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_HAS_NO_SUPPLY_KEY) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) TxnVerbs.cryptoDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoDelete) TxnVerbs.invalidBurnToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.invalidBurnToken) INSUFFICIENT_TOKEN_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TOKEN_BALANCE) ScheduleRecordSpecs.scheduledVersionOf(com.hedera.services.bdd.suites.schedule.ScheduleRecordSpecs.scheduledVersionOf) ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN) TxnVerbs.revokeTokenKyc(com.hedera.services.bdd.spec.transactions.TxnVerbs.revokeTokenKyc) AccountID(com.hederahashgraph.api.proto.java.AccountID) TxnVerbs.mintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) SOME_SIGNATURES_WERE_INVALID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SOME_SIGNATURES_WERE_INVALID) INVALID_CHUNK_NUMBER(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CHUNK_NUMBER) TxnVerbs.updateTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.updateTopic) ACCOUNT_FROZEN_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_FROZEN_FOR_TOKEN) TxnVerbs.tokenFreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenFreeze) UtilVerbs.recordFeeAmount(com.hedera.services.bdd.spec.utilops.UtilVerbs.recordFeeAmount) INVALID_TOKEN_BURN_METADATA(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_BURN_METADATA) TOKEN_ID_REPEATED_IN_TOKEN_LIST(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_ID_REPEATED_IN_TOKEN_LIST) TxnVerbs.scheduleSign(com.hedera.services.bdd.spec.transactions.TxnVerbs.scheduleSign) HapiCryptoTransfer.tinyBarsFromToWithInvalidAmounts(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromToWithInvalidAmounts) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) TxnVerbs.burnToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.burnToken) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) QueryVerbs.getScheduleInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getScheduleInfo) TokenType(com.hederahashgraph.api.proto.java.TokenType) TxnVerbs.invalidMintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.invalidMintToken) INVALID_CHUNK_TRANSACTION_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CHUNK_TRANSACTION_ID) Assertions(org.junit.jupiter.api.Assertions) LogManager(org.apache.logging.log4j.LogManager) TxnVerbs.tokenUnfreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUnfreeze) AtomicReference(java.util.concurrent.atomic.AtomicReference) ByteString(com.google.protobuf.ByteString) Map(java.util.Map)

Example 60 with AccountID

use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.

the class ScheduleExecutionSpecs method scheduledXferFailingWithRepeatedTokenIdPaysServiceFeeButNoImpact.

private HapiApiSpec scheduledXferFailingWithRepeatedTokenIdPaysServiceFeeButNoImpact() {
    String xToken = "XXX", yToken = "YYY";
    String validSchedule = "withNoRepeats";
    String invalidSchedule = "withRepeats";
    String schedulePayer = "somebody", xTreasury = "xt", yTreasury = "yt";
    String successTxn = "good", failedTxn = "bad";
    AtomicReference<Map<AccountID, Long>> successFeesObs = new AtomicReference<>();
    AtomicReference<Map<AccountID, Long>> failureFeesObs = new AtomicReference<>();
    return defaultHapiSpec("ScheduledXferFailingWithRepeatedTokenIdPaysServiceFeeButNoImpact").given(cryptoCreate(schedulePayer), cryptoCreate(xTreasury), cryptoCreate(yTreasury), tokenCreate(xToken).treasury(xTreasury).initialSupply(101), tokenCreate(yToken).treasury(yTreasury).initialSupply(101), tokenAssociate(xTreasury, yToken), tokenAssociate(yTreasury, xToken)).when(scheduleCreate(validSchedule, cryptoTransfer(moving(1, xToken).between(xTreasury, yTreasury), moving(1, yToken).between(yTreasury, xTreasury))).via(successTxn).alsoSigningWith(xTreasury, yTreasury, schedulePayer).designatingPayer(schedulePayer), getAccountBalance(xTreasury).hasTokenBalance(xToken, 100), getAccountBalance(xTreasury).hasTokenBalance(yToken, 1), getAccountBalance(yTreasury).hasTokenBalance(yToken, 100), getAccountBalance(yTreasury).hasTokenBalance(xToken, 1), getTxnRecord(successTxn).scheduled().logged().revealingDebitsTo(successFeesObs::set), scheduleCreate(invalidSchedule, cryptoTransfer(moving(1, xToken).between(xTreasury, yTreasury)).appendingTokenFromTo(xToken, xTreasury, yTreasury, 1)).via(failedTxn).alsoSigningWith(xTreasury, schedulePayer).designatingPayer(schedulePayer)).then(getTxnRecord(failedTxn).scheduled().hasPriority(recordWith().status(TOKEN_ID_REPEATED_IN_TOKEN_LIST)).revealingDebitsTo(failureFeesObs::set), getAccountBalance(xTreasury).hasTokenBalance(xToken, 100), getAccountBalance(xTreasury).hasTokenBalance(yToken, 1), getAccountBalance(yTreasury).hasTokenBalance(yToken, 100), getAccountBalance(yTreasury).hasTokenBalance(xToken, 1), assertionsHold((spec, opLog) -> assertBasicallyIdentical(successFeesObs.get(), failureFeesObs.get(), 1.0)));
}
Also used : ACCOUNT_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_DELETED) INVALID_NFT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_NFT_ID) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) INVALID_TRANSACTION_BODY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TRANSACTION_BODY) Random(java.util.Random) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) TxnVerbs.tokenDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenDelete) HapiGetTxnRecord(com.hedera.services.bdd.spec.queries.meta.HapiGetTxnRecord) HapiSpecSetup(com.hedera.services.bdd.spec.HapiSpecSetup) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) TxnUtils.asId(com.hedera.services.bdd.spec.transactions.TxnUtils.asId) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) NO_NEW_VALID_SIGNATURES(com.hederahashgraph.api.proto.java.ResponseCodeEnum.NO_NEW_VALID_SIGNATURES) INVALID_TOKEN_MINT_AMOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_MINT_AMOUNT) Map(java.util.Map) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) HapiCryptoTransfer.tinyBarsFromTo(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromTo) INVALID_ACCOUNT_AMOUNTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ACCOUNT_AMOUNTS) SCHEDULE_ALREADY_EXECUTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SCHEDULE_ALREADY_EXECUTED) BATCH_SIZE_LIMIT_EXCEEDED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BATCH_SIZE_LIMIT_EXCEEDED) MESSAGE_SIZE_TOO_LARGE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.MESSAGE_SIZE_TOO_LARGE) TxnVerbs.scheduleCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.scheduleCreate) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) TxnVerbs.deleteTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.deleteTopic) TxnVerbs.submitMessageTo(com.hedera.services.bdd.spec.transactions.TxnVerbs.submitMessageTo) INVALID_TOKEN_BURN_AMOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_BURN_AMOUNT) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) TOKEN_NOT_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT) ByteString(com.google.protobuf.ByteString) AccountAmount(com.hederahashgraph.api.proto.java.AccountAmount) List(java.util.List) Logger(org.apache.logging.log4j.Logger) UtilVerbs.assertionsHold(com.hedera.services.bdd.spec.utilops.UtilVerbs.assertionsHold) TxnVerbs.grantTokenKyc(com.hedera.services.bdd.spec.transactions.TxnVerbs.grantTokenKyc) UNRESOLVABLE_REQUIRED_SIGNERS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNRESOLVABLE_REQUIRED_SIGNERS) TxnUtils.randomUppercase(com.hedera.services.bdd.spec.transactions.TxnUtils.randomUppercase) UtilVerbs.usableTxnIdNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.usableTxnIdNamed) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) METADATA_TOO_LONG(com.hederahashgraph.api.proto.java.ResponseCodeEnum.METADATA_TOO_LONG) TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSFERS_NOT_ZERO_SUM_FOR_TOKEN) TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) INSUFFICIENT_PAYER_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_PAYER_BALANCE) INSUFFICIENT_ACCOUNT_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) QueryVerbs.getTokenInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTokenInfo) QueryVerbs.getTopicInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTopicInfo) TxnVerbs.createTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.createTopic) AtomicReference(java.util.concurrent.atomic.AtomicReference) EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.EMPTY_TOKEN_TRANSFER_ACCOUNT_AMOUNTS) TOKEN_WAS_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_WAS_DELETED) TOKEN_HAS_NO_SUPPLY_KEY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_HAS_NO_SUPPLY_KEY) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) TxnVerbs.cryptoDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoDelete) TxnVerbs.invalidBurnToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.invalidBurnToken) INSUFFICIENT_TOKEN_BALANCE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TOKEN_BALANCE) ScheduleRecordSpecs.scheduledVersionOf(com.hedera.services.bdd.suites.schedule.ScheduleRecordSpecs.scheduledVersionOf) ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_KYC_NOT_GRANTED_FOR_TOKEN) TxnVerbs.revokeTokenKyc(com.hedera.services.bdd.spec.transactions.TxnVerbs.revokeTokenKyc) AccountID(com.hederahashgraph.api.proto.java.AccountID) TxnVerbs.mintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) SOME_SIGNATURES_WERE_INVALID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SOME_SIGNATURES_WERE_INVALID) INVALID_CHUNK_NUMBER(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CHUNK_NUMBER) TxnVerbs.updateTopic(com.hedera.services.bdd.spec.transactions.TxnVerbs.updateTopic) ACCOUNT_FROZEN_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_FROZEN_FOR_TOKEN) TxnVerbs.tokenFreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenFreeze) UtilVerbs.recordFeeAmount(com.hedera.services.bdd.spec.utilops.UtilVerbs.recordFeeAmount) INVALID_TOKEN_BURN_METADATA(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_TOKEN_BURN_METADATA) TOKEN_ID_REPEATED_IN_TOKEN_LIST(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_ID_REPEATED_IN_TOKEN_LIST) TxnVerbs.scheduleSign(com.hedera.services.bdd.spec.transactions.TxnVerbs.scheduleSign) HapiCryptoTransfer.tinyBarsFromToWithInvalidAmounts(com.hedera.services.bdd.spec.transactions.crypto.HapiCryptoTransfer.tinyBarsFromToWithInvalidAmounts) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) TxnVerbs.burnToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.burnToken) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) QueryVerbs.getScheduleInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getScheduleInfo) TokenType(com.hederahashgraph.api.proto.java.TokenType) TxnVerbs.invalidMintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.invalidMintToken) INVALID_CHUNK_TRANSACTION_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CHUNK_TRANSACTION_ID) Assertions(org.junit.jupiter.api.Assertions) LogManager(org.apache.logging.log4j.LogManager) TxnVerbs.tokenUnfreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUnfreeze) AtomicReference(java.util.concurrent.atomic.AtomicReference) ByteString(com.google.protobuf.ByteString) Map(java.util.Map)

Aggregations

AccountID (com.hederahashgraph.api.proto.java.AccountID)71 Test (org.junit.jupiter.api.Test)24 List (java.util.List)21 ByteString (com.google.protobuf.ByteString)20 Assertions (org.junit.jupiter.api.Assertions)20 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)17 LogManager (org.apache.logging.log4j.LogManager)17 Logger (org.apache.logging.log4j.Logger)17 HapiApiSuite (com.hedera.services.bdd.suites.HapiApiSuite)16 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)15 QueryVerbs.getTxnRecord (com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord)15 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)15 QueryVerbs.getAccountInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo)14 TransactionRecordAsserts.recordWith (com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith)13 QueryVerbs.getAccountBalance (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance)13 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)13 TxnVerbs.cryptoTransfer (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer)13 TxnVerbs.mintToken (com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken)13 HapiSpecSetup (com.hedera.services.bdd.spec.HapiSpecSetup)12 QueryVerbs.getScheduleInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getScheduleInfo)12