diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-04-22 13:44:05 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-04-23 09:39:21 +0200 |
commit | fa085b470a9647f3b261f506b46f4e7ca2baf0b0 (patch) | |
tree | 12742857fda9411cc33166e520c64b46f2ce713b /test/functional/test_framework | |
parent | fa1bedb4944b513a3c9184ad549f58bfbe69e20e (diff) | |
download | bitcoin-fa085b470a9647f3b261f506b46f4e7ca2baf0b0.tar.xz |
test: Create MiniWallet.create_self_transfer
Diffstat (limited to 'test/functional/test_framework')
-rw-r--r-- | test/functional/test_framework/wallet.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py index 26294d6a9d..59ef18635b 100644 --- a/test/functional/test_framework/wallet.py +++ b/test/functional/test_framework/wallet.py @@ -73,6 +73,12 @@ class MiniWallet: def send_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_spend=None): """Create and send a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed.""" + tx = self.create_self_transfer(fee_rate=fee_rate, from_node=from_node, utxo_to_spend=utxo_to_spend) + self.sendrawtransaction(from_node=from_node, tx_hex=tx['hex']) + return tx + + def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node, utxo_to_spend=None, mempool_valid=True): + """Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed.""" self._utxos = sorted(self._utxos, key=lambda k: k['value']) utxo_to_spend = utxo_to_spend or self._utxos.pop() # Pick the largest utxo (if none provided) and hope it covers the fee vsize = Decimal(96) @@ -88,9 +94,10 @@ class MiniWallet: tx_hex = tx.serialize().hex() tx_info = from_node.testmempoolaccept([tx_hex])[0] - self.sendrawtransaction(from_node=from_node, tx_hex=tx_hex) - assert_equal(tx_info['vsize'], vsize) - assert_equal(tx_info['fees']['base'], fee) + assert_equal(mempool_valid, tx_info['allowed']) + if mempool_valid: + assert_equal(tx_info['vsize'], vsize) + assert_equal(tx_info['fees']['base'], fee) return {'txid': tx_info['txid'], 'wtxid': tx_info['wtxid'], 'hex': tx_hex} def sendrawtransaction(self, *, from_node, tx_hex): |