use of com.hedera.hashgraph.sdk.FileInfoQuery in project hedera-sdk-java by hashgraph.
the class FileCreateIntegrationTest method canCreateFileWithNoKeys.
@Test
@DisplayName("Can create file with no keys")
void canCreateFileWithNoKeys() 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.FileInfoQuery in project hedera-sdk-java by hashgraph.
the class FileCreateIntegrationTest method canCreateFile.
@Test
@DisplayName("Can create file")
void canCreateFile() 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.FileInfoQuery in project hedera-sdk-java by hashgraph.
the class FileInfoIntegrationTest method getCostBigMaxQueryFileInfo.
@Test
@DisplayName("Can get cost, even with a big max")
@SuppressWarnings("UnusedVariable")
void getCostBigMaxQueryFileInfo() 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(new Hbar(1000));
var cost = infoQuery.getCost(testEnv.client);
var info = infoQuery.setQueryPayment(cost).execute(testEnv.client);
new FileDeleteTransaction().setFileId(fileId).execute(testEnv.client).getReceipt(testEnv.client);
testEnv.close();
}
use of com.hedera.hashgraph.sdk.FileInfoQuery in project hedera-sdk-java by hashgraph.
the class FileInfoIntegrationTest method getCostSmallMaxQueryFileInfo.
@Test
@DisplayName("Error, max is smaller than set payment.")
void getCostSmallMaxQueryFileInfo() 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(MaxQueryPaymentExceededException.class).isThrownBy(() -> {
infoQuery.execute(testEnv.client);
});
new FileDeleteTransaction().setFileId(fileId).execute(testEnv.client).getReceipt(testEnv.client);
testEnv.close();
}
use of com.hedera.hashgraph.sdk.FileInfoQuery in project hedera-sdk-java by hashgraph.
the class FileInfoIntegrationTest method canQueryFileInfo.
@Test
@DisplayName("Can query file info")
void canQueryFileInfo() 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();
}
Aggregations