Changeset View
Changeset View
Standalone View
Standalone View
test/functional/getblocktemplate_longpoll.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2014-2016 The Bitcoin Core developers | # Copyright (c) 2014-2016 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.decorators import * | |||||
from test_framework.util import * | from test_framework.util import * | ||||
import threading | import threading | ||||
class LongpollThread(threading.Thread): | class LongpollThread(threading.Thread): | ||||
def __init__(self, node): | def __init__(self, node): | ||||
threading.Thread.__init__(self) | threading.Thread.__init__(self) | ||||
# query current longpollid | # query current longpollid | ||||
templat = node.getblocktemplate() | templat = node.getblocktemplate() | ||||
self.longpollid = templat['longpollid'] | self.longpollid = templat['longpollid'] | ||||
# create a new connection to the node, we can't use the same | # create a new connection to the node, we can't use the same | ||||
# connection from two threads | # connection from two threads | ||||
self.node = get_rpc_proxy( | self.node = get_rpc_proxy( | ||||
node.url, 1, timeout=600, coveragedir=node.coverage_dir) | node.url, 1, timeout=600, coveragedir=node.coverage_dir) | ||||
def run(self): | def run(self): | ||||
self.node.getblocktemplate({'longpollid': self.longpollid}) | self.node.getblocktemplate({'longpollid': self.longpollid}) | ||||
@extended | |||||
class GetBlockTemplateLPTest(BitcoinTestFramework): | class GetBlockTemplateLPTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
def run_test(self): | def run_test(self): | ||||
self.log.info( | self.log.info( | ||||
"Warning: this test will take about 70 seconds in the best case. Be patient.") | "Warning: this test will take about 70 seconds in the best case. Be patient.") | ||||
self.nodes[0].generate(10) | self.nodes[0].generate(10) | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |