|
|
|
|
@ -1,4 +1,3 @@
|
|
|
|
|
#! /usr/bin/env python |
|
|
|
|
from __future__ import absolute_import |
|
|
|
|
'''test configure module.''' |
|
|
|
|
|
|
|
|
|
@ -6,7 +5,7 @@ import pytest
|
|
|
|
|
from jmclient import load_program_config, jm_single, get_irc_mchannels |
|
|
|
|
from jmclient.configure import (get_config_irc_channel, get_p2sh_vbyte, |
|
|
|
|
get_p2pk_vbyte, get_blockchain_interface_instance) |
|
|
|
|
import os |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_attribute_dict(): |
|
|
|
|
from jmclient.configure import AttributeDict |
|
|
|
|
@ -16,22 +15,16 @@ def test_attribute_dict():
|
|
|
|
|
assert ad.baz.x == 3 |
|
|
|
|
assert ad["foo"] == 1 |
|
|
|
|
|
|
|
|
|
def test_load_config(): |
|
|
|
|
|
|
|
|
|
def test_load_config(tmpdir): |
|
|
|
|
load_program_config(bs="regtest") |
|
|
|
|
os.makedirs("dummydirforconfig") |
|
|
|
|
ncp = os.path.join(os.getcwd(), "dummydirforconfig") |
|
|
|
|
jm_single().config_location = "joinmarket.cfg" |
|
|
|
|
#TODO hack: load from default implies a connection error unless |
|
|
|
|
#actually mainnet, but tests cannot; for now catch the connection error |
|
|
|
|
with pytest.raises(Exception) as e_info: |
|
|
|
|
load_program_config(config_path=ncp, bs="regtest") |
|
|
|
|
assert str(e_info.value) in ["[Errno 111] Connection refused", "authentication for JSON-RPC failed", |
|
|
|
|
"JSON-RPC connection failed. Err:error(111, 'Connection refused')"] |
|
|
|
|
os.remove("dummydirforconfig/joinmarket.cfg") |
|
|
|
|
os.removedirs("dummydirforconfig") |
|
|
|
|
with pytest.raises(SystemExit): |
|
|
|
|
load_program_config(config_path=str(tmpdir), bs="regtest") |
|
|
|
|
jm_single().config_location = "joinmarket.cfg" |
|
|
|
|
load_program_config() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_config_get_irc_channel(): |
|
|
|
|
load_program_config() |
|
|
|
|
channel = "dummy" |
|
|
|
|
@ -41,11 +34,13 @@ def test_config_get_irc_channel():
|
|
|
|
|
get_irc_mchannels() |
|
|
|
|
load_program_config() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_net_byte(): |
|
|
|
|
load_program_config() |
|
|
|
|
assert get_p2pk_vbyte() == 0x6f |
|
|
|
|
assert get_p2sh_vbyte() == 196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_blockchain_sources(): |
|
|
|
|
load_program_config() |
|
|
|
|
for src in ["electrum", "dummy"]: |
|
|
|
|
@ -58,8 +53,3 @@ def test_blockchain_sources():
|
|
|
|
|
else: |
|
|
|
|
get_blockchain_interface_instance(jm_single().config) |
|
|
|
|
load_program_config() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|