obelisk

Electrum server using libbitcoin as its backend
git clone https://git.parazyd.org/obelisk
Log | Files | Refs | README | LICENSE

commit ab955fd58e1705b2ee1a5cf69461daa7ee51bf5c
parent 7125ed4eda0e013c80ec9c4d1314cba08e4ea892
Author: parazyd <parazyd@dyne.org>
Date:   Fri, 16 Apr 2021 03:03:26 +0200

tests: Add server.version

This will be necessary for future protocols, where it will have to be
negotiated upon initiating connection.

Will have to see how this will reflect with the blockstream test server.

Diffstat:
Mtests/test_electrum_protocol.py | 18+++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/tests/test_electrum_protocol.py b/tests/test_electrum_protocol.py @@ -28,7 +28,12 @@ from logging import getLogger from pprint import pprint from socket import socket, AF_INET, SOCK_STREAM -from obelisk.protocol import ElectrumProtocol +from obelisk.protocol import ( + ElectrumProtocol, + VERSION, + SERVER_PROTO_MIN, + SERVER_PROTO_MAX, +) from obelisk.zeromq import create_random_id libbitcoin = { @@ -196,6 +201,13 @@ async def test_ping(protocol, writer, method): assert_equal(data["result"], expect["result"]) +async def test_server_version(protocol, writer, method): + params = ["obelisk 42", [SERVER_PROTO_MIN, SERVER_PROTO_MAX]] + expect = {"result": [f"obelisk {VERSION}", SERVER_PROTO_MAX]} + data = await protocol.server_version(writer, {"params": params}) + assert_equal(data["result"], expect["result"]) + + class MockWriter(asyncio.StreamWriter): """Mock class for StreamWriter""" @@ -211,6 +223,8 @@ class MockWriter(asyncio.StreamWriter): # Test orchestration orchestration = { + "server.version": test_server_version, + "server.ping": test_ping, "blockchain.block.header": test_block_header, "blockchain.block.headers": test_block_headers, # "blockchain.estimatefee": test_estimatefee, @@ -231,8 +245,6 @@ orchestration = { # "server.donation_address": test_donation_address, # "server.features": test_server_features, # "server.peers_subscribe": test_peers_subscribe, - "server.ping": test_ping, - # "server.version": test_server_version, }