2024 11 27 processtransaction flaky test (#5793)

* Fix TxUtil.isValidFeeRange()

* Make fee checks exclusive
This commit is contained in:
Chris Stewart 2024-11-28 10:58:31 -06:00 committed by GitHub
parent 6f13f263ee
commit 98e89a6e93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 9 deletions

View file

@ -289,7 +289,9 @@ object TxUtil {
val actualFee = creditingAmount - spentAmount
val estimatedFee = expectedFeeRate * expectedTx
isValidFeeRange(estimatedFee, actualFee, expectedFeeRate)
isValidFeeRange(estimatedFee = estimatedFee,
actualFee = actualFee,
feeRate = expectedFeeRate)
}
}
@ -328,10 +330,10 @@ object TxUtil {
val min = Satoshis(-acceptableVariance)
val max = Satoshis(acceptableVariance)
val difference = estimatedFee - actualFee
if (difference <= min) {
TxBuilderError.HighFee
} else if (difference >= max) {
TxBuilderError.LowFee
if (difference < min) {
TxBuilderError.highFee(estimatedFee, actualFee)
} else if (difference > max) {
TxBuilderError.lowFee(min = estimatedFee, actual = actualFee)
} else {
Success(())
}

View file

@ -1,5 +1,6 @@
package org.bitcoins.core.wallet.builder
import org.bitcoins.core.currency.CurrencyUnit
import org.bitcoins.core.protocol.transaction.TransactionOutput
import scala.util.Failure
@ -169,15 +170,21 @@ object TxBuilderError {
/** Means that the fee was too low for
* [[org.bitcoins.core.wallet.builder.TxBuilder.feeRate TxBuilder.feeRate]]
*/
val LowFee = Failure(
new IllegalArgumentException("Means that the fee was too low"))
def lowFee(min: CurrencyUnit, actual: CurrencyUnit): Failure[Nothing] = {
Failure(
new IllegalArgumentException(
s"Means that the fee was too low min=$min actual=$actual"))
}
/** Means tha this transaction pays too high of a fee for
* [[org.bitcoins.core.wallet.builder.TxBuilder.feeRate TxBuilder.feeRate]]
*/
val HighFee = Failure(
new IllegalArgumentException("Means that the fee was too high"))
def highFee(max: CurrencyUnit, actual: CurrencyUnit): Failure[Nothing] = {
Failure(
new IllegalArgumentException(
s"Means that the fee was too high, max=$max actual=$actual"))
}
/** Indicates we are spending multiple
* [[org.bitcoins.core.protocol.script.CLTVScriptPubKey CLTVScriptPubKey]],