aboutsummaryrefslogtreecommitdiff
path: root/test/functional/feature_coinstatsindex.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-06-24 12:47:04 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-06-24 12:47:13 +0200
commitd6a59166a1879c1dd5b3a301847961f4b3f17742 (patch)
tree17408a0a952372e1cfe16b41ceca50dd866be085 /test/functional/feature_coinstatsindex.py
parentc31161f4f79b6e1dc0f8bfc2a5e7815e8c55ed91 (diff)
parentbdb8b9a347e68f80a2e8d44ce5590a2e8214b6bb (diff)
downloadbitcoin-d6a59166a1879c1dd5b3a301847961f4b3f17742.tar.xz
Merge bitcoin/bitcoin#22257: test: refactor: various (de)serialization helpers cleanups/improvements
bdb8b9a347e68f80a2e8d44ce5590a2e8214b6bb test: doc: improve doc for `from_hex` helper (mention `to_hex` alternative) (Sebastian Falbesoner) 191405420815d49ab50184513717a303fc2744d6 scripted-diff: test: rename `FromHex` to `from_hex` (Sebastian Falbesoner) a79396fe5f8f81c78cf84117a87074c6ff6c9d95 test: remove `ToHex` helper, use .serialize().hex() instead (Sebastian Falbesoner) 2ce7b47958c4a10ba20dc86c011d71cda4b070a5 test: introduce `tx_from_hex` helper for tx deserialization (Sebastian Falbesoner) Pull request description: There are still many functional tests that perform conversions from a hex-string to a message object (deserialization) manually. This PR identifies all those instances and replaces them with a newly introduced helper `tx_from_hex`. Instances were found via * `git grep "deserialize.*BytesIO"` and some of them manually, when it were not one-liners. Further, the helper `ToHex` was removed and simply replaced by `.serialize().hex()`, since now both variants are in use (sometimes even within the same test) and using the helper doesn't really have an advantage in readability. (see discussion https://github.com/bitcoin/bitcoin/pull/22257#discussion_r652404782) ACKs for top commit: MarcoFalke: review re-ACK bdb8b9a347e68f80a2e8d44ce5590a2e8214b6bb 😁 Tree-SHA512: e25d7dc85918de1d6755a5cea65471b07a743204c20ad1c2f71ff07ef48cc1b9ad3fe5f515c1efaba2b2e3d89384e7980380c5d81895f9826e2046808cd3266e
Diffstat (limited to 'test/functional/feature_coinstatsindex.py')
-rwxr-xr-xtest/functional/feature_coinstatsindex.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/test/functional/feature_coinstatsindex.py b/test/functional/feature_coinstatsindex.py
index 7488e3cb42..5d8ec2a8da 100755
--- a/test/functional/feature_coinstatsindex.py
+++ b/test/functional/feature_coinstatsindex.py
@@ -22,7 +22,6 @@ from test_framework.messages import (
CTransaction,
CTxIn,
CTxOut,
- ToHex,
)
from test_framework.script import (
CScript,
@@ -170,7 +169,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
tx2 = CTransaction()
tx2.vin.append(CTxIn(COutPoint(int(tx1_txid, 16), n), b''))
tx2.vout.append(CTxOut(int(20.99 * COIN), CScript([OP_RETURN] + [OP_FALSE]*30)))
- tx2_hex = self.nodes[0].signrawtransactionwithwallet(ToHex(tx2))['hex']
+ tx2_hex = self.nodes[0].signrawtransactionwithwallet(tx2.serialize().hex())['hex']
self.nodes[0].sendrawtransaction(tx2_hex)
# Include both txs in a block
@@ -207,7 +206,7 @@ class CoinStatsIndexTest(BitcoinTestFramework):
block_time = self.nodes[0].getblock(tip)['time'] + 1
block = create_block(int(tip, 16), cb, block_time)
block.solve()
- self.nodes[0].submitblock(ToHex(block))
+ self.nodes[0].submitblock(block.serialize().hex())
self.sync_all()
self.wait_until(lambda: not try_rpc(-32603, "Unable to read UTXO set", index_node.gettxoutsetinfo, 'muhash'))