use of com.hedera.services.files.HFileMeta in project hedera-services by hashgraph.
the class FeeSchedulesManagerTest method setup.
@BeforeEach
private void setup() {
attr = new HFileMeta(false, new JContractIDKey(1, 2, 3), Instant.now().getEpochSecond());
fees = mock(FeeCalculator.class);
subject = new FeeSchedulesManager(new MockFileNumbers(), fees);
}
use of com.hedera.services.files.HFileMeta in project hedera-services by hashgraph.
the class FileAppendTransitionLogic method doStateTransition.
@Override
public void doStateTransition() {
var op = txnCtx.accessor().getTxn().getFileAppend();
try {
var target = op.getFileID();
var data = op.getContents().toByteArray();
ResponseCodeEnum validity;
if (fileNumbers.isSoftwareUpdateFile(target.getFileNum())) {
validity = hfs.exists(target) ? OK : INVALID_FILE_ID;
} else {
Optional<HFileMeta> attr = hfs.exists(target) ? Optional.of(hfs.getattr(target)) : Optional.empty();
validity = classify(attr);
}
if (validity != OK) {
txnCtx.setStatus(validity);
return;
}
if (networkCtx.get().getPreparedUpdateFileNum() == target.getFileNum()) {
txnCtx.setStatus(PREPARED_UPDATE_FILE_IS_IMMUTABLE);
return;
}
final var result = hfs.append(target, data);
final var status = result.outcome();
txnCtx.setStatus(status);
} catch (IllegalArgumentException iae) {
mapToStatus(iae, txnCtx);
} catch (Exception unknown) {
log.warn("Unrecognized failure handling {}!", txnCtx.accessor().getSignedTxnWrapper(), unknown);
txnCtx.setStatus(FAIL_INVALID);
}
}
use of com.hedera.services.files.HFileMeta 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);
}
use of com.hedera.services.files.HFileMeta in project hedera-services by hashgraph.
the class FileUpdateTransitionLogicTest method doesntUpdateWaclIfNoNew.
@Test
void doesntUpdateWaclIfNoNew() {
// setup:
HederaFs.UpdateResult res = mock(HederaFs.UpdateResult.class);
ArgumentCaptor<HFileMeta> captor = ArgumentCaptor.forClass(HFileMeta.class);
givenTxnCtxUpdating(EnumSet.of(UpdateTarget.EXPIRY));
// and:
given(hfs.getattr(nonSysFileTarget)).willReturn(new HFileMeta(false, oldWacl, oldExpiry));
given(hfs.setattr(any(), any())).willReturn(res);
// when:
subject.doStateTransition();
// then:
verify(hfs).setattr(argThat(nonSysFileTarget::equals), captor.capture());
// and:
assertEquals(oldAttr.getWacl().toString(), captor.getValue().getWacl().toString());
}
use of com.hedera.services.files.HFileMeta 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);
}
Aggregations