use of com.hedera.services.usage.crypto.CryptoTransferMeta in project hedera-services by hashgraph.
the class AccessorBasedUsagesTest method worksAsExpectedForCryptoTransfer.
@Test
void worksAsExpectedForCryptoTransfer() {
int multiplier = 30;
final var baseMeta = new BaseTransactionMeta(100, 2);
final var xferMeta = new CryptoTransferMeta(1, 3, 7, 4);
final var usageAccumulator = new UsageAccumulator();
given(dynamicProperties.feesTokenTransferUsageMultiplier()).willReturn(multiplier);
given(txnAccessor.getFunction()).willReturn(CryptoTransfer);
given(txnAccessor.availXferUsageMeta()).willReturn(xferMeta);
given(txnAccessor.baseUsageMeta()).willReturn(baseMeta);
subject.assess(sigUsage, txnAccessor, usageAccumulator);
verify(cryptoOpsUsage).cryptoTransferUsage(sigUsage, xferMeta, baseMeta, usageAccumulator);
assertEquals(multiplier, xferMeta.getTokenMultiplier());
}
use of com.hedera.services.usage.crypto.CryptoTransferMeta in project hedera-services by hashgraph.
the class SignedTxnAccessor method setXferUsageMeta.
private void setXferUsageMeta() {
var totalTokensInvolved = 0;
var totalTokenTransfers = 0;
var numNftOwnershipChanges = 0;
final var op = txn.getCryptoTransfer();
for (var tokenTransfers : op.getTokenTransfersList()) {
totalTokensInvolved++;
totalTokenTransfers += tokenTransfers.getTransfersCount();
numNftOwnershipChanges += tokenTransfers.getNftTransfersCount();
}
xferUsageMeta = new CryptoTransferMeta(1, totalTokensInvolved, totalTokenTransfers, numNftOwnershipChanges);
}
Aggregations