Skip to content

Commit

Permalink
Fix exchange rate rounding issue in acceptance tests (#8968)
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Sheehy <steven.sheehy@swirldslabs.com>
  • Loading branch information
steven-sheehy authored Aug 7, 2024
1 parent 3c49fc6 commit 96acb4c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import com.hedera.mirror.test.e2e.acceptance.props.NodeProperties;
import jakarta.inject.Named;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.security.SecureRandom;
import java.time.Duration;
import java.util.ArrayList;
Expand Down Expand Up @@ -189,9 +191,11 @@ private ExpandedAccountId getOperatorAccount(TransactionReceipt receipt) {

// Convert USD balance property to hbars using exchange rate from probe
double exchangeRate = getExchangeRate(receipt);
var exchangeRateUsd = BigDecimal.valueOf(exchangeRate).divide(BigDecimal.valueOf(100));
var balance =
Hbar.from(acceptanceTestProperties.getOperatorBalance().divide(exchangeRateUsd));
var exchangeRateUsd =
BigDecimal.valueOf(exchangeRate).divide(BigDecimal.valueOf(100), MathContext.DECIMAL128);
var balance = Hbar.from(acceptanceTestProperties
.getOperatorBalance()
.divide(exchangeRateUsd, 8, RoundingMode.HALF_EVEN));

var accountId = new AccountCreateTransaction()
.setAlias(alias)
Expand Down

0 comments on commit 96acb4c

Please sign in to comment.