diff options
author | Andrew Chow <github@achow101.com> | 2023-05-01 09:21:28 -0400 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-05-01 09:28:06 -0400 |
commit | 539452242e895f2dcd719d41f447a48896d0e4b2 (patch) | |
tree | 7a3319286ac4a3c84ed3995f37a738505f449aa7 /test/functional/wallet_basic.py | |
parent | ab99b95b003a0e9a485d15120d8ebd6417ea5b30 (diff) | |
parent | 057057a2d7e23c2e29cbfd29a5124b3947a33757 (diff) |
Merge bitcoin/bitcoin#26733: test: Add test for `sendmany` rpc that uses `subtractfeefrom` parameter
057057a2d7e23c2e29cbfd29a5124b3947a33757 Add test for `sendmany` rpc that uses `subtractfeefrom` parameter (Yusuf Sahin HAMZA)
Pull request description:
This PR adds test that uses `sendmany` rpc to send **BTC** to multiple addresses using `subtractfeefrom` parameter, then checks receiver addresses balances to make sure fees are subtracted correctly.
ACKs for top commit:
achow101:
ACK 057057a2d7e23c2e29cbfd29a5124b3947a33757
Tree-SHA512: 51167120d489f0ff7b8b9855424d07cb55a8965984f904643cddf45e7a08c350eaded498c350ec9c660edf72c2f128ec142347c9c79d5043d9f6cd481b15cd7e
Diffstat (limited to 'test/functional/wallet_basic.py')
-rwxr-xr-x | test/functional/wallet_basic.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index 53ac01686a..1f771dabe4 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -267,6 +267,20 @@ class WalletTest(BitcoinTestFramework): assert_equal(self.nodes[2].getbalance(), node_2_bal) node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), node_0_bal + Decimal('10'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])) + # Sendmany 5 BTC to two addresses with subtracting fee from both addresses + a0 = self.nodes[0].getnewaddress() + a1 = self.nodes[0].getnewaddress() + txid = self.nodes[2].sendmany(dummy='', amounts={a0: 5, a1: 5}, subtractfeefrom=[a0, a1]) + self.generate(self.nodes[2], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3])) + node_2_bal -= Decimal('10') + assert_equal(self.nodes[2].getbalance(), node_2_bal) + tx = self.nodes[2].gettransaction(txid) + node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), node_0_bal + Decimal('10'), fee_per_byte, self.get_vsize(tx['hex'])) + assert_equal(self.nodes[0].getbalance(), node_0_bal) + expected_bal = Decimal('5') + (tx['fee'] / 2) + assert_equal(self.nodes[0].getreceivedbyaddress(a0), expected_bal) + assert_equal(self.nodes[0].getreceivedbyaddress(a1), expected_bal) + self.log.info("Test sendmany with fee_rate param (explicit fee rate in sat/vB)") fee_rate_sat_vb = 2 fee_rate_btc_kvb = fee_rate_sat_vb * 1e3 / 1e8 |