Search in sources :

Example 1 with FreezeTransactionBody

use of com.hederahashgraph.api.proto.java.FreezeTransactionBody in project hedera-services by hashgraph.

the class FreezeTestHelper method createFreezeTransaction.

static Transaction createFreezeTransaction(final boolean paidBy58, final boolean valid, final FileID fileID, final byte[] fileHash, final int[] startHourMin, final int[] endHourMin, final Instant timeStamp) {
    FreezeTransactionBody freezeBody;
    if (valid) {
        final var builder = (timeStamp == null) ? getFreezeTranBuilder(startHourMin[0], startHourMin[1], endHourMin[0], endHourMin[1]) : getFreezeTranBuilder(timeStamp);
        if (fileID != null) {
            builder.setUpdateFile(fileID);
            builder.setFileHash(ByteString.copyFrom(fileHash));
        }
        freezeBody = builder.build();
    } else {
        freezeBody = getFreezeTranBuilder(25, 1, 3, 4).build();
    }
    final var timestamp = TestHelper.getDefaultCurrentTimestampUTC();
    final var transactionDuration = RequestBuilder.getDuration(30);
    final long transactionFee = 100000000000l;
    final String memo = "Freeze Test";
    final var payerAccountId = (paidBy58) ? RequestBuilder.getAccountIdBuild(58l, 0l, 0l) : RequestBuilder.getAccountIdBuild(100l, 0l, 0l);
    final var body = RequestBuilder.getTxBodyBuilder(transactionFee, timestamp, transactionDuration, true, memo, payerAccountId, nodeAccountId);
    body.setFreeze(freezeBody);
    final var bodyBytesArr = body.build().toByteArray();
    final var bodyBytes = ByteString.copyFrom(bodyBytesArr);
    return Transaction.newBuilder().setBodyBytes(bodyBytes).build();
}
Also used : FreezeTransactionBody(com.hederahashgraph.api.proto.java.FreezeTransactionBody) ByteString(com.google.protobuf.ByteString)

Aggregations

ByteString (com.google.protobuf.ByteString)1 FreezeTransactionBody (com.hederahashgraph.api.proto.java.FreezeTransactionBody)1