From 712dcaf86be4759b5c517dc5c16c2dc6866d218e Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 25 Apr 2023 11:30:50 +0100 Subject: [PATCH] Merge bitcoin/bitcoin#27516: test: simplify uint256 (de)serialization routines 96bf0bca4a0e3aa0b7c07d8c225861e72f970fa9 test: simplify uint256 (de)serialization routines (Sebastian Falbesoner) Pull request description: These routines look fancy, but do nothing more than converting between byte objects of length 32 to/from integers in little endian byte order and can be replaced by simple one-liners, using the `int.{from,to}_bytes` methods (available since Python 3.2). ACKs for top commit: MarcoFalke: lgtm ACK 96bf0bca4a0e3aa0b7c07d8c225861e72f970fa9 brunoerg: crACK 96bf0bca4a0e3aa0b7c07d8c225861e72f970fa9 Tree-SHA512: f3031502d61a936147867ad8a0efa841a9bbdd2acf8781653036889a38524f4f1a5c86b1e07157bf2d9663097e7b84be6846678d0883d2a334beafd87e9510f0 --- test/functional/test_framework/messages.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index da8345b881..9d3c77847c 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -86,6 +86,7 @@ def ser_compact_size(l): r = struct.pack(">= 32 - return rs + return u.to_bytes(32, 'little') def uint256_from_str(s): - r = 0 - t = struct.unpack("