mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 10:28:10 +01:00
Split rpc functions into new file.
This commit is contained in:
@@ -34,7 +34,10 @@ from basicswap.basicswap import (
|
||||
from basicswap.util import (
|
||||
COIN,
|
||||
toWIF,
|
||||
)
|
||||
from basicswap.rpc import (
|
||||
callrpc_cli,
|
||||
waitForRPC,
|
||||
)
|
||||
from basicswap.key import (
|
||||
ECKey,
|
||||
@@ -206,17 +209,6 @@ def run_loop(self):
|
||||
btcRpc('generatetoaddress 1 {}'.format(self.btc_addr))
|
||||
|
||||
|
||||
def waitForRPC(rpc_func, wallet=None):
|
||||
for i in range(5):
|
||||
try:
|
||||
rpc_func('getwalletinfo')
|
||||
return
|
||||
except Exception as ex:
|
||||
logging.warning('Can\'t connect to daemon RPC: %s. Trying again in %d second/s.', str(ex), (1 + i))
|
||||
time.sleep(1 + i)
|
||||
raise ValueError('waitForRPC failed')
|
||||
|
||||
|
||||
class Test(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -31,7 +31,7 @@ from unittest.mock import patch
|
||||
from urllib.request import urlopen
|
||||
from urllib import parse
|
||||
|
||||
from basicswap.util import (
|
||||
from basicswap.rpc import (
|
||||
callrpc_cli,
|
||||
)
|
||||
|
||||
|
||||
@@ -37,9 +37,12 @@ from basicswap.basicswap import (
|
||||
from basicswap.util import (
|
||||
COIN,
|
||||
toWIF,
|
||||
callrpc_cli,
|
||||
dumpje,
|
||||
)
|
||||
from basicswap.rpc import (
|
||||
callrpc_cli,
|
||||
waitForRPC,
|
||||
)
|
||||
from basicswap.key import (
|
||||
ECKey,
|
||||
)
|
||||
@@ -210,17 +213,6 @@ def run_loop(self):
|
||||
btcRpc('generatetoaddress 1 {}'.format(self.btc_addr))
|
||||
|
||||
|
||||
def waitForRPC(rpc_func, wallet=None):
|
||||
for i in range(5):
|
||||
try:
|
||||
rpc_func('getwalletinfo')
|
||||
return
|
||||
except Exception as ex:
|
||||
logging.warning('Can\'t connect to daemon RPC: %s. Trying again in %d second/s.', str(ex), (1 + i))
|
||||
time.sleep(1 + i)
|
||||
raise ValueError('waitForRPC failed')
|
||||
|
||||
|
||||
def checkForks(ro):
|
||||
if 'bip9_softforks' in ro:
|
||||
assert(ro['bip9_softforks']['csv']['status'] == 'active')
|
||||
|
||||
Reference in New Issue
Block a user