use of com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody in project hedera-services by hashgraph.
the class RequestBuilder method getTokenTransferRequest.
public static Transaction getTokenTransferRequest(Long payerAccountNum, Long payerRealmNum, Long payerShardNum, Long nodeAccountNum, Long nodeRealmNum, Long nodeShardNum, long transactionFee, Timestamp timestamp, Duration transactionDuration, boolean generateRecord, String memo, TokenTransferList tokenTransferList) {
CryptoTransferTransactionBody cryptoTransferTransaction = CryptoTransferTransactionBody.newBuilder().addTokenTransfers(tokenTransferList).build();
TransactionBody.Builder body = getTransactionBody(payerAccountNum, payerRealmNum, payerShardNum, nodeAccountNum, nodeRealmNum, nodeShardNum, transactionFee, timestamp, transactionDuration, generateRecord, memo);
body.setCryptoTransfer(cryptoTransferTransaction);
byte[] bodyBytesArr = body.build().toByteArray();
ByteString bodyBytes = ByteString.copyFrom(bodyBytesArr);
return Transaction.newBuilder().setBodyBytes(bodyBytes).build();
}
use of com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody in project hedera-services by hashgraph.
the class HapiQueryOp method opDef.
private Consumer<TransactionBody.Builder> opDef(HapiApiSpec spec, long amount) throws Throwable {
TransferList transfers = asTransferList(tinyBarsFromTo(amount, spec.registry().getAccountID(effectivePayer(spec)), targetNodeFor(spec)));
CryptoTransferTransactionBody opBody = spec.txns().<CryptoTransferTransactionBody, CryptoTransferTransactionBody.Builder>body(CryptoTransferTransactionBody.class, b -> b.setTransfers(transfers));
return b -> b.setCryptoTransfer(opBody);
}
use of com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody in project hedera-mirror-node by hashgraph.
the class PubSubRecordItemListenerTest method testSendRetries.
@Test
void testSendRetries() throws Exception {
// when
CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().setTransfers(TransferList.newBuilder().build()).build();
Transaction transaction = buildTransaction(builder -> builder.setCryptoTransfer(cryptoTransfer));
pubSubProperties.setMaxSendAttempts(3);
// when
when(messageChannel.send(any())).thenThrow(MessageTimeoutException.class).thenThrow(MessageTimeoutException.class).thenReturn(true);
pubSubRecordItemListener.onItem(new RecordItem(transaction, DEFAULT_RECORD));
// then
var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 3);
assertThat(pubSubMessage.getEntity()).isNull();
assertThat(pubSubMessage.getNonFeeTransfers()).isNull();
}
use of com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody in project hedera-mirror-node by hashgraph.
the class PubSubRecordItemListenerTest method testPubSubMessageWithNonFeeTransferAndNullEntityId.
@Test
void testPubSubMessageWithNonFeeTransferAndNullEntityId() throws Exception {
// given
List<AccountAmount> nonFeeTransfers = new ArrayList<>();
nonFeeTransfers.add(buildAccountAmount(10L, 100L));
nonFeeTransfers.add(buildAccountAmount(11L, 111L));
CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().setTransfers(TransferList.newBuilder().addAccountAmounts(nonFeeTransfers.get(0)).addAccountAmounts(nonFeeTransfers.get(1)).build()).build();
Transaction transaction = buildTransaction(builder -> builder.setCryptoTransfer(cryptoTransfer));
var recordItem = new RecordItem(transaction, DEFAULT_RECORD);
when(nonFeeTransferExtractionStrategy.extractNonFeeTransfers(recordItem.getTransactionBody(), recordItem.getRecord())).thenReturn(cryptoTransfer.getTransfers().getAccountAmountsList());
// when
pubSubRecordItemListener.onItem(recordItem);
// then
var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 1);
assertThat(pubSubMessage.getEntity()).isNull();
assertThat(pubSubMessage.getNonFeeTransfers()).isEqualTo(nonFeeTransfers);
}
use of com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody in project hedera-services by hashgraph.
the class RequestBuilder method getCryptoTransferRequest.
public static Transaction getCryptoTransferRequest(Long payerAccountNum, Long payerRealmNum, Long payerShardNum, Long nodeAccountNum, Long nodeRealmNum, Long nodeShardNum, long transactionFee, Timestamp timestamp, Duration transactionDuration, boolean generateRecord, String memo, TransferList transferList) {
CryptoTransferTransactionBody cryptoTransferTransaction = CryptoTransferTransactionBody.newBuilder().setTransfers(transferList).build();
TransactionBody.Builder body = getTransactionBody(payerAccountNum, payerRealmNum, payerShardNum, nodeAccountNum, nodeRealmNum, nodeShardNum, transactionFee, timestamp, transactionDuration, generateRecord, memo);
body.setCryptoTransfer(cryptoTransferTransaction);
byte[] bodyBytesArr = body.build().toByteArray();
ByteString bodyBytes = ByteString.copyFrom(bodyBytesArr);
return Transaction.newBuilder().setBodyBytes(bodyBytes).build();
}
Aggregations