ttests: Fix listunspent. - obelisk - Electrum server using libbitcoin as its backend HTML git clone https://git.parazyd.org/obelisk DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit b5f75215bd26c7ad7461ccd2af3bd8490ab9a690 DIR parent bc3c4ee24a16a7397e41262acb25f8d4ef91375c HTML Author: parazyd <parazyd@dyne.org> Date: Thu, 15 Apr 2021 20:39:12 +0200 ttests: Fix listunspent. Diffstat: M obelisk/protocol.py | 6 +----- M obelisk/zeromq.py | 3 +-- M tests/test_electrum_protocol.py | 9 +++------ 3 files changed, 5 insertions(+), 13 deletions(-) --- DIR diff --git a/obelisk/protocol.py b/obelisk/protocol.py t@@ -452,11 +452,7 @@ class ElectrumProtocol(asyncio.Protocol): # pylint: disable=R0904,R0902 "height": rec["height"], }) - if len(ret) < 2: - return {"result": ret} - - # return {"result": sorted(ret, key=lambda x: x["height"], reverse=True)} - return {"result": sorted(ret, key=lambda x: x["height"])} + return {"result": ret} async def scripthash_notifier(self, writer, scripthash): # TODO: Figure out how this actually works DIR diff --git a/obelisk/zeromq.py b/obelisk/zeromq.py t@@ -381,8 +381,7 @@ class Client: correlated_points = Client.__correlate(points) # self.log.debug("history points: %s", points) # self.log.debug("history correlated: %s", correlated_points) - # return error_code, self._sort_correlated_points(correlated_points) - return error_code, correlated_points + return error_code, self._sort_correlated_points(correlated_points) @staticmethod def _sort_correlated_points(points): DIR diff --git a/tests/test_electrum_protocol.py b/tests/test_electrum_protocol.py t@@ -143,15 +143,12 @@ async def test_blockchain_scripthash_listunspent(protocol, writer): params = [ "92dd1eb7c042956d3dd9185a58a2578f61fee91347196604540838ccd0f8c08c" ] + # Blockstream is broken here and doesn't return in ascending order. expect = get_expect(method, params) + srt = sorted(expect["result"], key=lambda x: x["height"]) data = await protocol.blockchain_scripthash_listunspent( writer, {"params": params}) - - pprint(expect) - print() - pprint(data) - - assert data["result"] == expect["result"] + assert data["result"] == srt async def test_blockchain_transaction_get(protocol, writer):