Пример #1
0
    def start(cls, net, factory, dcrd, peer_ports, merged_urls):
        self = cls()

        self.n = node.Node(factory, dcrd, [], [], net)
        yield self.n.start()

        self.n.p2p_node = node.P2PNode(self.n,
                                       port=0,
                                       max_incoming_conns=1000000,
                                       addr_store={},
                                       connect_addrs=[
                                           ('127.0.0.1', peer_port)
                                           for peer_port in peer_ports
                                       ])
        self.n.p2p_node.start()

        wb = work.WorkerBridge(node=self.n,
                               my_pubkey_hash=random.randrange(2**160),
                               donation_percentage=random.uniform(0, 10),
                               merged_urls=merged_urls,
                               worker_fee=3,
                               args=math.Object(
                                   donation_percentage=random.uniform(0, 10),
                                   address='foo',
                                   worker_fee=3,
                                   timeaddresses=1000),
                               pubkeys=main.keypool(),
                               dcrd=dcrd)
        self.wb = wb
        web_root = resource.Resource()
        worker_interface.WorkerInterface(wb).attach_to(web_root)
        self.web_port = reactor.listenTCP(0, server.Site(web_root))

        defer.returnValue(self)
Пример #2
0
    def test_node(self):
        bitd = dcrd()

        mm_root = resource.Resource()
        mm_root.putChild('', jsonrpc.HTTPServer(mm_provider))
        mm_port = reactor.listenTCP(0, server.Site(mm_root))

        n = node.Node(bitd, bitd, [], [], mynet)
        yield n.start()

        wb = work.WorkerBridge(node=n,
                               my_pubkey_hash=42,
                               donation_percentage=2,
                               merged_urls=[('http://127.0.0.1:%i' %
                                             (mm_port.getHost().port, ), '')],
                               worker_fee=3,
                               args=math.Object(donation_percentage=2,
                                                address='foo',
                                                worker_fee=3,
                                                timeaddresses=1000),
                               pubkeys=main.keypool(),
                               dcrd=bitd)
        web_root = resource.Resource()
        worker_interface.WorkerInterface(wb).attach_to(web_root)
        port = reactor.listenTCP(0, server.Site(web_root))

        proxy = jsonrpc.HTTPProxy(
            'http://127.0.0.1:' + str(port.getHost().port),
            headers=dict(Authorization='Basic ' +
                         base64.b64encode('user/0:password')))

        yield deferral.sleep(3)

        for i in xrange(100):
            blah = yield proxy.rpc_getwork()
            yield proxy.rpc_getwork(blah['data'])

        yield deferral.sleep(3)

        assert len(n.tracker.items) == 100
        assert n.tracker.verified.get_height(n.best_share_var.value) == 100

        wb.stop()
        n.stop()

        yield port.stopListening()
        del n, wb, web_root, port, proxy
        import gc
        gc.collect()
        gc.collect()
        gc.collect()

        yield deferral.sleep(20)  # waiting for work_poller to exit
        yield mm_port.stopListening()
Пример #3
0
    def test_node(self):
        bitd = bitcoind()

        mm_root = resource.Resource()
        mm_root.putChild('', jsonrpc.HTTPServer(mm_provider))
        mm_port = reactor.listenTCP(0, server.Site(mm_root))

        n = node.Node(bitd, bitd, [], [], mynet)
        yield n.start()

        wb = work.WorkerBridge(node=n, my_pubkey_hash=42, donation_percentage=2, merged_urls=[('http://127.0.0.1:%i' % (mm_port.getHost().port,), '')], worker_fee=3, args=math.Object(donation_percentage=2, address='foo', worker_fee=3, timeaddresses=1000), pubkeys=main.keypool(), bitcoind=bitd)
        web_root = resource.Resource()
        worker_interface.WorkerInterface(wb).attach_to(web_root)
        port = reactor.listenTCP(0, server.Site(web_root))

        proxy = jsonrpc.HTTPProxy('http://127.0.0.1:' + str(port.getHost().port),
            headers=dict(Authorization='Basic ' + base64.b64encode('user/0:password')))

        yield deferral.sleep(3)

        for i in xrange(100):
            blah = yield proxy.rpc_getwork()
            yield proxy.rpc_getwork(blah['data'])


        yield deferral.sleep(3)

        assert len(n.tracker.items) == 100
        assert n.tracker.verified.get_height(n.best_share_var.value) == 100

        wb.stop()
        n.stop()

        yield port.stopListening()
        del n, wb, web_root, port, proxy
        import gc
        gc.collect()
        gc.collect()
        gc.collect()

        yield deferral.sleep(20) # waiting for work_poller to exit
        yield mm_port.stopListening()
Пример #4
0
    def start(cls, net, factory, bitcoind, peer_ports, merged_urls):
        self = cls()

        self.n = node.Node(factory, bitcoind, [], [], net)
        yield self.n.start()

        self.n.p2p_node = node.P2PNode(self.n, port=0, max_incoming_conns=1000000, addr_store={}, connect_addrs=[('127.0.0.1', peer_port) for peer_port in peer_ports])
        self.n.p2p_node.start()

        wb = work.WorkerBridge(node=self.n, my_pubkey_hash=random.randrange(2**160), donation_percentage=random.uniform(0, 10), merged_urls=merged_urls, worker_fee=3, args=math.Object(donation_percentage=random.uniform(0, 10), address='foo', worker_fee=3, timeaddresses=1000), pubkeys=main.keypool(), bitcoind=bitcoind)
        self.wb = wb
        web_root = resource.Resource()
        worker_interface.WorkerInterface(wb).attach_to(web_root)
        self.web_port = reactor.listenTCP(0, server.Site(web_root))

        defer.returnValue(self)