use of com.hedera.hashgraph.sdk.FileCreateTransaction in project hedera-sdk-java by hashgraph.
the class FileDeleteIntegrationTest method canDeleteFile.
@Test
@DisplayName("Can delete file")
void canDeleteFile() throws Exception {
var testEnv = new IntegrationTestEnv(1);
var response = new FileCreateTransaction().setKeys(testEnv.operatorKey).setContents("[e2e::FileCreateTransaction]").execute(testEnv.client);
var fileId = Objects.requireNonNull(response.getReceipt(testEnv.client).fileId);
var info = new FileInfoQuery().setFileId(fileId).execute(testEnv.client);
assertThat(info.fileId).isEqualTo(fileId);
assertThat(info.size).isEqualTo(28);
assertThat(info.isDeleted).isFalse();
assertThat(info.keys).isNotNull();
assertThat(info.keys.getThreshold()).isNull();
assertThat(info.keys).isEqualTo(KeyList.of(testEnv.operatorKey));
new FileDeleteTransaction().setFileId(fileId).execute(testEnv.client).getReceipt(testEnv.client);
testEnv.close();
}
use of com.hedera.hashgraph.sdk.FileCreateTransaction in project hedera-sdk-java by hashgraph.
the class FileInfoIntegrationTest method canQueryFileInfoWithNoAdminKeyOrContents.
@Test
@DisplayName("Can query file info with no admin key or contents")
void canQueryFileInfoWithNoAdminKeyOrContents() throws Exception {
var testEnv = new IntegrationTestEnv(1);
var response = new FileCreateTransaction().execute(testEnv.client);
var fileId = Objects.requireNonNull(response.getReceipt(testEnv.client).fileId);
var info = new FileInfoQuery().setFileId(fileId).execute(testEnv.client);
assertThat(info.fileId).isEqualTo(fileId);
assertThat(info.size).isEqualTo(0);
assertThat(info.isDeleted).isFalse();
assertThat(info.keys).isNull();
testEnv.close();
}
use of com.hedera.hashgraph.sdk.FileCreateTransaction in project hedera-sdk-java by hashgraph.
the class FileInfoIntegrationTest method getCostInsufficientTxFeeQueryFileInfo.
@Test
@DisplayName("Insufficient tx fee error.")
void getCostInsufficientTxFeeQueryFileInfo() throws Exception {
var testEnv = new IntegrationTestEnv(1);
var response = new FileCreateTransaction().setKeys(testEnv.operatorKey).setContents("[e2e::FileCreateTransaction]").execute(testEnv.client);
var fileId = Objects.requireNonNull(response.getReceipt(testEnv.client).fileId);
var infoQuery = new FileInfoQuery().setFileId(fileId).setMaxQueryPayment(Hbar.fromTinybars(1));
assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
infoQuery.setQueryPayment(Hbar.fromTinybars(1)).execute(testEnv.client);
}).satisfies(error -> assertThat(error.status.toString()).isEqualTo("INSUFFICIENT_TX_FEE"));
new FileDeleteTransaction().setFileId(fileId).execute(testEnv.client).getReceipt(testEnv.client);
testEnv.close();
}
use of com.hedera.hashgraph.sdk.FileCreateTransaction in project hedera-mirror-node by hashgraph.
the class FileClient method createFile.
public NetworkTransactionResponse createFile(byte[] content) {
log.debug("Create new file");
String memo = getMemo("Create file");
FileCreateTransaction fileCreateTransaction = new FileCreateTransaction().setKeys(sdkClient.getExpandedOperatorAccountId().getPublicKey()).setContents(content).setFileMemo(memo).setTransactionMemo(memo);
NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(fileCreateTransaction, KeyList.of(sdkClient.getExpandedOperatorAccountId().getPrivateKey()));
FileId fileId = networkTransactionResponse.getReceipt().fileId;
log.debug("Created new file {}", fileId);
return networkTransactionResponse;
}
use of com.hedera.hashgraph.sdk.FileCreateTransaction in project hedera-sdk-java by hashgraph.
the class SystemIntegrationTest method allSystemTransactionsAreNotSupported.
@Test
@DisplayName("All system transactions are not supported")
void allSystemTransactionsAreNotSupported() throws Exception {
var testEnv = new IntegrationTestEnv(1);
var fileId = Objects.requireNonNull(new FileCreateTransaction().setContents(SMART_CONTRACT_BYTECODE).execute(testEnv.client).getReceipt(testEnv.client).fileId);
var contractId = Objects.requireNonNull(new ContractCreateTransaction().setAdminKey(testEnv.operatorKey).setGas(100000).setConstructorParameters(new ContractFunctionParameters().addString("Hello from Hedera.")).setBytecodeFileId(fileId).setContractMemo("[e2e::ContractCreateTransaction]").execute(testEnv.client).getReceipt(testEnv.client).contractId);
assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
new SystemDeleteTransaction().setContractId(contractId).setExpirationTime(Instant.now()).execute(testEnv.client);
}).withMessageContaining(Status.NOT_SUPPORTED.toString());
assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
new SystemDeleteTransaction().setFileId(fileId).setExpirationTime(Instant.now()).execute(testEnv.client);
}).withMessageContaining(Status.NOT_SUPPORTED.toString());
assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
new SystemUndeleteTransaction().setContractId(contractId).execute(testEnv.client);
}).withMessageContaining(Status.NOT_SUPPORTED.toString());
assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
new SystemUndeleteTransaction().setFileId(fileId).execute(testEnv.client);
}).withMessageContaining(Status.NOT_SUPPORTED.toString());
testEnv.close();
}
Aggregations