From 935d6553a500438abc608b119d92c2f80100c004 Mon Sep 17 00:00:00 2001 From: Luke Lee Date: Mon, 23 Dec 2024 17:03:49 -0800 Subject: [PATCH] remove unnecessary exception translation Signed-off-by: Luke Lee --- .../hts/transfer/ClassicTransfersDecoder.java | 12 ++++-------- .../hts/transfer/ClassicTransfersDecoderTest.java | 6 ++---- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/hts/transfer/ClassicTransfersDecoder.java b/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/hts/transfer/ClassicTransfersDecoder.java index 91a4fe761fe..da7635a76de 100644 --- a/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/hts/transfer/ClassicTransfersDecoder.java +++ b/hedera-node/hedera-smart-contract-service-impl/src/main/java/com/hedera/node/app/service/contract/impl/exec/systemcontracts/hts/transfer/ClassicTransfersDecoder.java @@ -317,14 +317,10 @@ private void consolidateInto( } private AccountAmount mergeAdjusts(@NonNull final AccountAmount from, @NonNull final AccountAmount to) { - try { - return from.copyBuilder() - .amount(Math.addExact(from.amount(), to.amount())) - .isApproval(from.isApproval() || to.isApproval()) - .build(); - } catch (ArithmeticException e) { - throw new IllegalArgumentException("Amount overflow when merging account amounts"); - } + return from.copyBuilder() + .amount(Math.addExact(from.amount(), to.amount())) + .isApproval(from.isApproval() || to.isApproval()) + .build(); } private List mergeNftTransfers( diff --git a/hedera-node/hedera-smart-contract-service-impl/src/test/java/com/hedera/node/app/service/contract/impl/test/exec/systemcontracts/hts/transfer/ClassicTransfersDecoderTest.java b/hedera-node/hedera-smart-contract-service-impl/src/test/java/com/hedera/node/app/service/contract/impl/test/exec/systemcontracts/hts/transfer/ClassicTransfersDecoderTest.java index 961d9b8fb37..2a6ffd7471d 100644 --- a/hedera-node/hedera-smart-contract-service-impl/src/test/java/com/hedera/node/app/service/contract/impl/test/exec/systemcontracts/hts/transfer/ClassicTransfersDecoderTest.java +++ b/hedera-node/hedera-smart-contract-service-impl/src/test/java/com/hedera/node/app/service/contract/impl/test/exec/systemcontracts/hts/transfer/ClassicTransfersDecoderTest.java @@ -131,8 +131,7 @@ void decodeCryptoTransferOverflow() { .build(), EMPTY_TUPLE_ARRAY); Assertions.assertThatThrownBy(() -> subject.decodeCryptoTransferV2(encodedInput.array(), converter)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Amount overflow when merging account amounts"); + .isInstanceOf(ArithmeticException.class); } @Test @@ -153,8 +152,7 @@ void decodeCryptoTokenTransferOverflow() { .build()) .build()); Assertions.assertThatThrownBy(() -> subject.decodeCryptoTransferV2(encodedInput.array(), converter)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Amount overflow when merging account amounts"); + .isInstanceOf(ArithmeticException.class); } private static List unwrapTokenAmounts(final TransactionBody body) {