Search in sources :

Example 1 with SigImpactHistorian

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

the class FileCreateTransitionLogicTest method setup.

@BeforeEach
private void setup() throws Throwable {
    hederaWacl = waclSkeleton.asJKey();
    attr = new HFileMeta(false, hederaWacl, expiry);
    accessor = mock(PlatformTxnAccessor.class);
    txnCtx = mock(TransactionContext.class);
    hfs = mock(HederaFs.class);
    sigImpactHistorian = mock(SigImpactHistorian.class);
    validator = mock(OptionValidator.class);
    given(validator.isValidAutoRenewPeriod(expectedDuration)).willReturn(true);
    given(validator.hasGoodEncoding(wacl)).willReturn(true);
    given(validator.memoCheck(any())).willReturn(OK);
    subject = new FileCreateTransitionLogic(hfs, validator, sigImpactHistorian, txnCtx);
}
Also used : PlatformTxnAccessor(com.hedera.services.utils.PlatformTxnAccessor) OptionValidator(com.hedera.services.txns.validation.OptionValidator) SigImpactHistorian(com.hedera.services.ledger.SigImpactHistorian) TransactionContext(com.hedera.services.context.TransactionContext) HFileMeta(com.hedera.services.files.HFileMeta) TieredHederaFs(com.hedera.services.files.TieredHederaFs) HederaFs(com.hedera.services.files.HederaFs) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with SigImpactHistorian

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

the class FileUpdateTransitionLogicTest method setup.

@BeforeEach
private void setup() throws Throwable {
    oldWacl = TxnHandlingScenario.SIMPLE_NEW_WACL_KT.asJKey();
    oldAttr = new HFileMeta(false, oldWacl, oldExpiry, oldMemo);
    deletedAttr = new HFileMeta(true, oldWacl, oldExpiry);
    immutableAttr = new HFileMeta(false, StateView.EMPTY_WACL, oldExpiry);
    actionableNewWacl = TxnHandlingScenario.MISC_FILE_WACL_KT.asJKey();
    newAttr = new HFileMeta(false, actionableNewWacl, newExpiry, newMemo);
    accessor = mock(PlatformTxnAccessor.class);
    txnCtx = mock(TransactionContext.class);
    given(txnCtx.activePayer()).willReturn(nonSysAdmin);
    networkCtx = mock(MerkleNetworkContext.class);
    hfs = mock(HederaFs.class);
    given(hfs.exists(nonSysFileTarget)).willReturn(true);
    given(hfs.getattr(nonSysFileTarget)).willReturn(oldAttr);
    validator = mock(OptionValidator.class);
    given(validator.isValidAutoRenewPeriod(expectedDuration)).willReturn(false);
    given(validator.hasGoodEncoding(newWacl)).willReturn(true);
    given(validator.memoCheck(newMemo)).willReturn(OK);
    sigImpactHistorian = mock(SigImpactHistorian.class);
    subject = new FileUpdateTransitionLogic(hfs, number, validator, sigImpactHistorian, txnCtx, () -> networkCtx);
}
Also used : PlatformTxnAccessor(com.hedera.services.utils.PlatformTxnAccessor) MerkleNetworkContext(com.hedera.services.state.merkle.MerkleNetworkContext) OptionValidator(com.hedera.services.txns.validation.OptionValidator) SigImpactHistorian(com.hedera.services.ledger.SigImpactHistorian) TransactionContext(com.hedera.services.context.TransactionContext) HFileMeta(com.hedera.services.files.HFileMeta) TieredHederaFs(com.hedera.services.files.TieredHederaFs) HederaFs(com.hedera.services.files.HederaFs) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with SigImpactHistorian

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

the class ExpiryManagerTest method expiresSchedulesAsExpected.

@Test
void expiresSchedulesAsExpected() {
    subject = new ExpiryManager(mockScheduleStore, nums, sigImpactHistorian, mockTxnHistories, () -> mockAccounts, () -> mockSchedules);
    // given:
    subject.trackExpirationEvent(Pair.of(aKey.longValue(), entityId -> mockScheduleStore.expire(entityId)), firstThen);
    subject.trackExpirationEvent(Pair.of(bKey.longValue(), entityId -> mockScheduleStore.expire(entityId)), secondThen);
    subject.purge(now);
    // then:
    verify(mockScheduleStore).expire(new EntityId(0, 0, aKey.longValue()));
    verify(sigImpactHistorian).markEntityChanged(aKey.longValue());
    assertEquals(1, subject.getShortLivedEntityExpiries().getAllExpiries().size());
}
Also used : TxnIdRecentHistory(com.hedera.services.records.TxnIdRecentHistory) OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) Mock(org.mockito.Mock) EntityId(com.hedera.services.state.submerkle.EntityId) HashMap(java.util.HashMap) MerkleAccount(com.hedera.services.state.merkle.MerkleAccount) MerkleMap(com.swirlds.merkle.map.MerkleMap) HederaNumbers(com.hedera.services.config.HederaNumbers) EntityNum(com.hedera.services.utils.EntityNum) Pair(org.apache.commons.lang3.tuple.Pair) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Map(java.util.Map) MockHederaNumbers(com.hedera.services.config.MockHederaNumbers) ExpirableTxnRecord(com.hedera.services.state.submerkle.ExpirableTxnRecord) ScheduleStore(com.hedera.services.store.schedule.ScheduleStore) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) AccountID(com.hederahashgraph.api.proto.java.AccountID) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) SigImpactHistorian(com.hedera.services.ledger.SigImpactHistorian) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) RichInstant(com.hedera.services.state.submerkle.RichInstant) Instant(java.time.Instant) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) IdUtils(com.hedera.test.utils.IdUtils) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) TxnReceipt(com.hedera.services.legacy.core.jproto.TxnReceipt) MerkleSchedule(com.hedera.services.state.merkle.MerkleSchedule) TxnId(com.hedera.services.state.submerkle.TxnId) EntityId(com.hedera.services.state.submerkle.EntityId) Test(org.junit.jupiter.api.Test)

Example 4 with SigImpactHistorian

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

the class FileCreateTransitionLogicTest method happyPathFlows.

@Test
void happyPathFlows() {
    // setup:
    InOrder inOrder = inOrder(hfs, txnCtx, sigImpactHistorian);
    givenTxnCtxCreating(EnumSet.allOf(ValidProperty.class));
    // and:
    given(hfs.create(any(), any(), any())).willReturn(created);
    // when:
    subject.doStateTransition();
    // then:
    inOrder.verify(txnCtx).activePayer();
    inOrder.verify(hfs).create(argThat(bytes -> Arrays.equals(contents, bytes)), argThat(info -> info.getWacl().toString().equals(hederaWacl.toString()) && info.getExpiry() == expiry && memo.equals(info.getMemo())), argThat(genesis::equals));
    inOrder.verify(txnCtx).setCreated(created);
    inOrder.verify(txnCtx).setStatus(SUCCESS);
    inOrder.verify(sigImpactHistorian).markEntityChanged(created.getFileNum());
}
Also used : StateView(com.hedera.services.context.primitives.StateView) BeforeEach(org.junit.jupiter.api.BeforeEach) OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) Arrays(java.util.Arrays) HFileMeta(com.hedera.services.files.HFileMeta) TieredHederaFs(com.hedera.services.files.TieredHederaFs) BDDMockito.inOrder(org.mockito.BDDMockito.inOrder) Duration(com.hederahashgraph.api.proto.java.Duration) TransactionContext(com.hedera.services.context.TransactionContext) BDDMockito.any(org.mockito.BDDMockito.any) BDDMockito.verify(org.mockito.BDDMockito.verify) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) BDDMockito.given(org.mockito.BDDMockito.given) CONTENTS(com.hedera.services.txns.file.FileCreateTransitionLogicTest.ValidProperty.CONTENTS) EXPIRY(com.hedera.services.txns.file.FileCreateTransitionLogicTest.ValidProperty.EXPIRY) KEY(com.hedera.services.txns.file.FileCreateTransitionLogicTest.ValidProperty.KEY) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PlatformTxnAccessor(com.hedera.services.utils.PlatformTxnAccessor) AccountID(com.hederahashgraph.api.proto.java.AccountID) EnumSet(java.util.EnumSet) TxnHandlingScenario(com.hedera.test.factories.scenarios.TxnHandlingScenario) FileID(com.hederahashgraph.api.proto.java.FileID) FileCreateTransactionBody(com.hederahashgraph.api.proto.java.FileCreateTransactionBody) InOrder(org.mockito.InOrder) BDDMockito.willThrow(org.mockito.BDDMockito.willThrow) INVALID_ZERO_BYTE_IN_STRING(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_ZERO_BYTE_IN_STRING) SigImpactHistorian(com.hedera.services.ledger.SigImpactHistorian) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) FAIL_INVALID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.FAIL_INVALID) HederaFs(com.hedera.services.files.HederaFs) Instant(java.time.Instant) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) OptionValidator(com.hedera.services.txns.validation.OptionValidator) IdUtils(com.hedera.test.utils.IdUtils) ByteString(com.google.protobuf.ByteString) Test(org.junit.jupiter.api.Test) MiscUtils(com.hedera.services.utils.MiscUtils) INVALID_FILE_WACL(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_FILE_WACL) Key(com.hederahashgraph.api.proto.java.Key) JKey(com.hedera.services.legacy.core.jproto.JKey) AUTORENEW_DURATION_NOT_IN_RANGE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.AUTORENEW_DURATION_NOT_IN_RANGE) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) BDDMockito.argThat(org.mockito.BDDMockito.argThat) BDDMockito.mock(org.mockito.BDDMockito.mock) KeyTree(com.hedera.test.factories.keys.KeyTree) INVALID_EXPIRATION_TIME(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_EXPIRATION_TIME) InOrder(org.mockito.InOrder) Test(org.junit.jupiter.api.Test)

Example 5 with SigImpactHistorian

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

the class FileSysDelTransitionLogicTest method setup.

@BeforeEach
private void setup() throws Throwable {
    wacl = TxnHandlingScenario.SIMPLE_NEW_WACL_KT.asJKey();
    attr = new HFileMeta(false, wacl, oldExpiry);
    deletedAttr = new HFileMeta(true, wacl, oldExpiry);
    accessor = mock(PlatformTxnAccessor.class);
    txnCtx = mock(TransactionContext.class);
    sigImpactHistorian = mock(SigImpactHistorian.class);
    oldExpiries = mock(Map.class);
    hfs = mock(HederaFs.class);
    given(hfs.exists(tbd)).willReturn(true);
    given(hfs.exists(deleted)).willReturn(true);
    given(hfs.exists(missing)).willReturn(false);
    given(hfs.getattr(tbd)).willReturn(attr);
    given(hfs.getattr(deleted)).willReturn(deletedAttr);
    subject = new FileSysDelTransitionLogic(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)

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