Make tests always pass by ensuring there is only 1 coinbase utxo to shield

This commit is contained in:
Duke
2025-10-16 01:10:33 -04:00
parent 6069a49508
commit 37e35854ab

View File

@@ -109,10 +109,6 @@ class ShieldCoinbaseDonationTest (BitcoinTestFramework):
# sendAmount/donationAmount arithmetic leads to a situation where the # sendAmount/donationAmount arithmetic leads to a situation where the
# exact amount in satoshis must deal with truncation/rounding # exact amount in satoshis must deal with truncation/rounding
# generate some new coinbase funds
rpc.generate(1)
self.sync_all()
# shield funds to a new zaddr in this wallet with non-default fee # shield funds to a new zaddr in this wallet with non-default fee
fee = 0.00000001 # 1 puposhi fee will lead to some kind of rounding/truncation arithmetic fee = 0.00000001 # 1 puposhi fee will lead to some kind of rounding/truncation arithmetic
response = rpc.z_shieldcoinbase('*', zaddr1, fee, 1, donation) response = rpc.z_shieldcoinbase('*', zaddr1, fee, 1, donation)
@@ -120,8 +116,9 @@ class ShieldCoinbaseDonationTest (BitcoinTestFramework):
print("opid=" + opid) print("opid=" + opid)
shieldingValue = response['shieldingValue'] shieldingValue = response['shieldingValue']
# sanity check # sanity check. None of the expected values below will be correct if
assert_greater_than_or_equal( shieldingValue , 3.0 ) # this is different
assert_equal( str(shieldingValue) , "3.00010000" )
# TODO: this might not be enough time for slow machines, better # TODO: this might not be enough time for slow machines, better
# solution would be to wait until the opid finishes # solution would be to wait until the opid finishes
@@ -140,19 +137,18 @@ class ShieldCoinbaseDonationTest (BitcoinTestFramework):
rpc.z_listunspent() rpc.z_listunspent()
# (300000000 - 1)*.95 # (300010000 - 1)*.05
# 284999999.05 # 15000499.95
# (300000000 - 1)*.05 # (300010000 - 1) - 15000499
# 14999999.95 # 285009500
# The above value will be truncated (not rounded) by casting from # The above value will be truncated (not rounded) by casting from
# double to CAmount/int64_t which means the donation will be 14999999 # double to CAmount/int64_t which means the donation will be 15000499
# and the sendAmount will be 300000000 - 1 (the fee) - 14999999 = 285000000 # and the sendAmount will be 300010000 - 1 (the fee) - 15000499 = 285009500
expectedSendAmount = 285000000
expectedDonationAmount = 14999999
# actually seeing this: 2.84990500 + 0.14999500 = 2.99990000 # these values assume that 3.0001 was shielded
# logging: donation=5, sendAmount=299999999, donationAmount=14999999 expectedSendAmount = 285009500
expectedDonationAmount = 15000499
# lookup txid # lookup txid
rawtx1 = rpc.z_viewtransaction(txid) rawtx1 = rpc.z_viewtransaction(txid)