Search in sources :

Example 1 with FileID

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

the class BaseHederaLedgerTestHelper method commonSetup.

protected void commonSetup() {
    sideEffectsTracker = mock(SideEffectsTracker.class);
    creator = mock(ExpiringCreations.class);
    historian = mock(AccountRecordsHistorian.class);
    ids = new EntityIdSource() {

        long nextId = NEXT_ID;

        @Override
        public TopicID newTopicId(final AccountID sponsor) {
            return TopicID.newBuilder().setTopicNum(nextId++).build();
        }

        @Override
        public AccountID newAccountId(AccountID newAccountSponsor) {
            return AccountID.newBuilder().setAccountNum(nextId++).build();
        }

        @Override
        public ContractID newContractId(AccountID newContractSponsor) {
            return ContractID.newBuilder().setContractNum(nextId++).build();
        }

        @Override
        public FileID newFileId(AccountID newFileSponsor) {
            return FileID.newBuilder().setFileNum(nextId++).build();
        }

        @Override
        public TokenID newTokenId(AccountID sponsor) {
            return TokenID.newBuilder().setTokenNum(nextId++).build();
        }

        @Override
        public ScheduleID newScheduleId(AccountID sponsor) {
            return ScheduleID.newBuilder().setScheduleNum(nextId++).build();
        }

        @Override
        public void reclaimLastId() {
            nextId--;
        }

        @Override
        public void reclaimProvisionalIds() {
        }

        @Override
        public void resetProvisionalIds() {
        }
    };
}
Also used : EntityIdSource(com.hedera.services.ledger.ids.EntityIdSource) AccountID(com.hederahashgraph.api.proto.java.AccountID) SideEffectsTracker(com.hedera.services.context.SideEffectsTracker) TopicID(com.hederahashgraph.api.proto.java.TopicID) FileID(com.hederahashgraph.api.proto.java.FileID) ContractID(com.hederahashgraph.api.proto.java.ContractID) ExpiringCreations(com.hedera.services.state.expiry.ExpiringCreations) TokenID(com.hederahashgraph.api.proto.java.TokenID) ScheduleID(com.hederahashgraph.api.proto.java.ScheduleID) AccountRecordsHistorian(com.hedera.services.records.AccountRecordsHistorian)

Example 2 with FileID

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

the class SeqNoEntityIdSourceTest method returnsExpectedFileId.

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

Example 3 with FileID

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

the class StateViewTest method getsSpecialFileContents.

@Test
void getsSpecialFileContents() {
    FileID file150 = asFile("0.0.150");
    given(specialFiles.get(file150)).willReturn(data);
    given(specialFiles.contains(file150)).willReturn(true);
    final var stuff = subject.contentsOf(file150);
    assertTrue(Arrays.equals(data, stuff.get()));
}
Also used : FileID(com.hederahashgraph.api.proto.java.FileID) Test(org.junit.jupiter.api.Test)

Example 4 with FileID

use of com.hederahashgraph.api.proto.java.FileID in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerFileTest method fileCreatePersistSystemPositive.

@Test
void fileCreatePersistSystemPositive() {
    entityProperties.getPersist().setFiles(false);
    Transaction transaction = fileCreateTransaction();
    TransactionBody transactionBody = getTransactionBody(transaction);
    FileID fileID = FileID.newBuilder().setShardNum(0).setRealmNum(0).setFileNum(10).build();
    TransactionRecord record = transactionRecord(transactionBody, fileID);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    assertAll(() -> assertRowCountOnSuccess(fileID), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileEntityAndData(transactionBody.getFileCreate(), record.getConsensusTimestamp()));
}
Also used : FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) FileCreateTransactionBody(com.hederahashgraph.api.proto.java.FileCreateTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) FileID(com.hederahashgraph.api.proto.java.FileID) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with FileID

use of com.hederahashgraph.api.proto.java.FileID in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerFileTest method fileUpdateAllToNewSystem.

@Test
void fileUpdateAllToNewSystem() {
    FileID fileID = FileID.newBuilder().setShardNum(0).setRealmNum(0).setFileNum(10).build();
    Transaction transaction = fileUpdateAllTransaction(fileID, FILE_CONTENTS);
    TransactionBody transactionBody = getTransactionBody(transaction);
    FileUpdateTransactionBody fileUpdateTransactionBody = transactionBody.getFileUpdate();
    TransactionRecord record = transactionRecord(transactionBody, fileID);
    entityProperties.getPersist().setFiles(true);
    entityProperties.getPersist().setSystemFiles(true);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    assertAll(() -> assertRowCountOnSuccess(fileID), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileEntityAndData(fileUpdateTransactionBody, record.getConsensusTimestamp()));
}
Also used : FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) FileCreateTransactionBody(com.hederahashgraph.api.proto.java.FileCreateTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) FileID(com.hederahashgraph.api.proto.java.FileID) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

FileID (com.hederahashgraph.api.proto.java.FileID)12 Test (org.junit.jupiter.api.Test)8 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)7 Transaction (com.hederahashgraph.api.proto.java.Transaction)6 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)6 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 ByteString (com.google.protobuf.ByteString)3 EntityId (com.hedera.mirror.common.domain.entity.EntityId)3 ContractID (com.hederahashgraph.api.proto.java.ContractID)3 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)3 FileCreateTransactionBody (com.hederahashgraph.api.proto.java.FileCreateTransactionBody)3 FileUpdateTransactionBody (com.hederahashgraph.api.proto.java.FileUpdateTransactionBody)3 ContractCreateTransactionBody (com.hederahashgraph.api.proto.java.ContractCreateTransactionBody)2 Duration (com.hederahashgraph.api.proto.java.Duration)2 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)2 List (java.util.List)2 Optional (java.util.Optional)2 Consumer (java.util.function.Consumer)2 Resource (javax.annotation.Resource)2