def test_init_with_invalid_timeout(self, mock_rpc): """Test bitcoinProxy.__init__""" with self.assertRaises(ValueError) as context: proxy = bitcoinProxy(timeout='invalid input') self.assertIsNone(proxy) self.assertTrue( 'Timeout should be a positive integer.' in str(context.exception)) with self.assertRaises(ValueError) as context_two: proxy = bitcoinProxy(timeout=-381) self.assertIsNone(proxy) self.assertTrue('Timeout should be a positive integer.' in str( context_two.exception))
def test_init_with_invalid(self, mock_rpc): """Test bitcoinProxy.__init__""" with self.assertRaises(ValueError) as context: proxy = bitcoinProxy(network='invalid input') self.assertIsNone(proxy) self.assertTrue('Allowed networks are regtest, testnet, mainnet.' in str(context.exception)) with self.assertRaises(ValueError) as context_two: proxy = bitcoinProxy(network=819.3) self.assertIsNone(proxy) self.assertTrue('Allowed networks are regtest, testnet, mainnet.' in str(context_two.exception))
def test_init_with_no_network(self, mock_SP, mock_rpc): """Test bitcoinProxy.__init__""" proxy = bitcoinProxy() mock_rpc.Proxy.assert_called_with(timeout=900) mock_SP.assert_called_with('regtest') self.assertIsInstance(proxy, bitcoinProxy)
def get_initiator_addresses(): bitcoinRPC = bitcoinProxy() zcashRPC = zcashProxy() btc_addr = input("Enter your bitcoin address or press enter to generate one: ") btc_addr = bitcoinRPC.new_bitcoin_addr() print(btc_addr) zec_addr = input("Enter your zcash address or press enter to generate one: ") zec_addr = zcashRPC.new_zcash_addr() print(zec_addr) addresses = {'bitcoin': btc_addr, 'zcash': zec_addr} return addresses
import json import os, sys from pprint import pprint from xcat.utils import * from xcat.trades import Contract, Trade import xcat.userInput as userInput import xcat.db as db from xcat.xcatconf import * from xcat.bitcoinRPC import bitcoinProxy from xcat.zcashRPC import zcashProxy bitcoinRPC = bitcoinProxy() zcashRPC = zcashProxy() def is_myaddr(address): if address[:1] == 'm': status = bitcoinRPC.validateaddress(address) else: status = zcashRPC.validateaddress(address) status = status['ismine'] # print("Address {0} is mine: {1}".format(address, status)) return status def find_secret_from_fundtx(currency, p2sh, fundtx): if currency == 'bitcoin': secret = bitcoinRPC.find_secret(p2sh, fundtx) else: secret = zcashRPC.find_secret(p2sh, fundtx) return secret
def __init__(self): self.bitcoinRPC = bitcoinProxy() self.zcashRPC = zcashProxy()