use of com.hedera.hashgraph.sdk.FileDeleteTransaction in project hedera-sdk-java by hashgraph.
the class FileContentsIntegrationTest method getCostInsufficientTxFeeQueryFileContents.
@Test
@DisplayName("Insufficient tx fee error.")
void getCostInsufficientTxFeeQueryFileContents() 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 contentsQuery = new FileContentsQuery().setFileId(fileId).setMaxQueryPayment(new Hbar(100));
assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
contentsQuery.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.FileDeleteTransaction in project hedera-sdk-java by hashgraph.
the class FileCreateIntegrationTest method canCreateFileWithNoContents.
@Test
@DisplayName("Can create file with no contents")
void canCreateFileWithNoContents() throws Exception {
var testEnv = new IntegrationTestEnv(1);
var response = new FileCreateTransaction().setKeys(testEnv.operatorKey).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).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.FileDeleteTransaction 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.FileDeleteTransaction 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.FileDeleteTransaction in project hedera-mirror-node by hashgraph.
the class FileClient method deleteFile.
public NetworkTransactionResponse deleteFile(FileId fileId) {
String memo = "Delete file";
log.debug(memo);
FileDeleteTransaction fileUpdateTransaction = new FileDeleteTransaction().setFileId(fileId).setTransactionMemo(getMemo(memo));
NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(fileUpdateTransaction);
log.debug("Deleted file {}", fileId);
return networkTransactionResponse;
}
Aggregations