Search in sources :

Example 6 with SigImpactHistorian

use of com.hedera.services.ledger.SigImpactHistorian in project hedera-services by hashgraph.

the class FileSysUndelTransitionLogicTest method setup.

@BeforeEach
private void setup() throws Throwable {
    wacl = TxnHandlingScenario.SIMPLE_NEW_WACL_KT.asJKey();
    attr = new HFileMeta(false, wacl, currExpiry);
    deletedAttr = new HFileMeta(true, wacl, currExpiry);
    accessor = mock(PlatformTxnAccessor.class);
    txnCtx = mock(TransactionContext.class);
    oldExpiries = mock(Map.class);
    sigImpactHistorian = mock(SigImpactHistorian.class);
    hfs = mock(HederaFs.class);
    given(hfs.exists(undeleted)).willReturn(true);
    given(hfs.exists(deleted)).willReturn(true);
    given(hfs.exists(missing)).willReturn(false);
    given(hfs.getattr(undeleted)).willReturn(attr);
    given(hfs.getattr(deleted)).willReturn(deletedAttr);
    subject = new FileSysUndelTransitionLogic(hfs, sigImpactHistorian, oldExpiries, txnCtx);
}
Also used : PlatformTxnAccessor(com.hedera.services.utils.PlatformTxnAccessor) SigImpactHistorian(com.hedera.services.ledger.SigImpactHistorian) TransactionContext(com.hedera.services.context.TransactionContext) HFileMeta(com.hedera.services.files.HFileMeta) HederaFs(com.hedera.services.files.HederaFs) Map(java.util.Map) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with SigImpactHistorian

use of com.hedera.services.ledger.SigImpactHistorian in project hedera-services by hashgraph.

the class FileUpdateTransitionLogicTest method happyPathFlows.

@Test
void happyPathFlows() {
    // setup:
    InOrder inOrder = inOrder(hfs, txnCtx, sigImpactHistorian);
    givenTxnCtxUpdating(EnumSet.allOf(UpdateTarget.class));
    // and:
    given(hfs.overwrite(any(), any())).willReturn(new SimpleUpdateResult(false, true, SUCCESS));
    given(hfs.setattr(any(), any())).willReturn(new SimpleUpdateResult(true, false, SUCCESS));
    given(hfs.getattr(nonSysFileTarget)).willReturn(oldAttr);
    // when:
    subject.doStateTransition();
    // then:
    inOrder.verify(hfs).overwrite(argThat(nonSysFileTarget::equals), argThat(bytes -> Arrays.equals(newContents, bytes)));
    inOrder.verify(hfs).setattr(argThat(nonSysFileTarget::equals), argThat(attr -> newAttr.toString().equals(attr.toString())));
    inOrder.verify(txnCtx).setStatus(SUCCESS);
    inOrder.verify(sigImpactHistorian).markEntityChanged(nonSysFileTarget.getFileNum());
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) Arrays(java.util.Arrays) HFileMeta(com.hedera.services.files.HFileMeta) BDDMockito.inOrder(org.mockito.BDDMockito.inOrder) StringValue(com.google.protobuf.StringValue) Duration(com.hederahashgraph.api.proto.java.Duration) BDDMockito.verify(org.mockito.BDDMockito.verify) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BDDMockito.given(org.mockito.BDDMockito.given) PlatformTxnAccessor(com.hedera.services.utils.PlatformTxnAccessor) EnumSet(java.util.EnumSet) BDDMockito.willThrow(org.mockito.BDDMockito.willThrow) DecoderException(org.apache.commons.codec.DecoderException) BDDMockito.never(org.mockito.BDDMockito.never) SigImpactHistorian(com.hedera.services.ledger.SigImpactHistorian) Instant(java.time.Instant) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) OptionValidator(com.hedera.services.txns.validation.OptionValidator) ByteString(com.google.protobuf.ByteString) Test(org.junit.jupiter.api.Test) MiscUtils(com.hedera.services.utils.MiscUtils) JKey(com.hedera.services.legacy.core.jproto.JKey) AUTORENEW_DURATION_NOT_IN_RANGE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.AUTORENEW_DURATION_NOT_IN_RANGE) INVALID_FILE_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_FILE_ID) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) UNAUTHORIZED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.UNAUTHORIZED) EntityNumbers(com.hedera.services.config.EntityNumbers) INVALID_EXPIRATION_TIME(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_EXPIRATION_TIME) StateView(com.hedera.services.context.primitives.StateView) TieredHederaFs(com.hedera.services.files.TieredHederaFs) AUTHORIZATION_FAILED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.AUTHORIZATION_FAILED) TransactionContext(com.hedera.services.context.TransactionContext) MerkleNetworkContext(com.hedera.services.state.merkle.MerkleNetworkContext) BDDMockito.any(org.mockito.BDDMockito.any) ArgumentCaptor(org.mockito.ArgumentCaptor) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FILE_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.FILE_DELETED) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) AccountID(com.hederahashgraph.api.proto.java.AccountID) TxnHandlingScenario(com.hedera.test.factories.scenarios.TxnHandlingScenario) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) PREPARED_UPDATE_FILE_IS_IMMUTABLE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.PREPARED_UPDATE_FILE_IS_IMMUTABLE) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) MAX_FILE_SIZE_EXCEEDED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.MAX_FILE_SIZE_EXCEEDED) FileID(com.hederahashgraph.api.proto.java.FileID) InOrder(org.mockito.InOrder) MockEntityNumbers(com.hedera.services.config.MockEntityNumbers) INVALID_ZERO_BYTE_IN_STRING(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ZERO_BYTE_IN_STRING) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) FAIL_INVALID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.FAIL_INVALID) HederaFs(com.hedera.services.files.HederaFs) IdUtils(com.hedera.test.utils.IdUtils) Key(com.hederahashgraph.api.proto.java.Key) SimpleUpdateResult(com.hedera.services.files.SimpleUpdateResult) BAD_ENCODING(com.hederahashgraph.api.proto.java.ResponseCodeEnum.BAD_ENCODING) BDDMockito.argThat(org.mockito.BDDMockito.argThat) BDDMockito.mock(org.mockito.BDDMockito.mock) InOrder(org.mockito.InOrder) SimpleUpdateResult(com.hedera.services.files.SimpleUpdateResult) Test(org.junit.jupiter.api.Test)

Aggregations

SigImpactHistorian (com.hedera.services.ledger.SigImpactHistorian)7 TransactionContext (com.hedera.services.context.TransactionContext)6 HFileMeta (com.hedera.services.files.HFileMeta)6 HederaFs (com.hedera.services.files.HederaFs)6 PlatformTxnAccessor (com.hedera.services.utils.PlatformTxnAccessor)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 TieredHederaFs (com.hedera.services.files.TieredHederaFs)4 OptionValidator (com.hedera.services.txns.validation.OptionValidator)4 IdUtils (com.hedera.test.utils.IdUtils)3 AccountID (com.hederahashgraph.api.proto.java.AccountID)3 OK (com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK)3 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)3 TransactionID (com.hederahashgraph.api.proto.java.TransactionID)3 Instant (java.time.Instant)3 Map (java.util.Map)3 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)3 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)3 Test (org.junit.jupiter.api.Test)3 ByteString (com.google.protobuf.ByteString)2 StateView (com.hedera.services.context.primitives.StateView)2