Esempio n. 1
0
    def test_poll_network_transaction_confirmations(self):
        """See that the service broadcasts transactions when created."""

        config = self.prepare_config()

        self.service = service = Service(config, ALL_SUBSYSTEMS)
        self.service.setup_session()

        try:
            service.start()
            count = service.poll_network_transaction_confirmations()
            self.assertEqual(count, 1)
        finally:
            service.shutdown()
Esempio n. 2
0
    def test_start_shutdown_service(self):
        """See that service starts and stops with bitcoind config."""

        config = self.prepare_config()

        self.service = Service(config, ALL_SUBSYSTEMS)
        # We should get one thread monitoring bitcoind walletnotify
        self.assertEqual(len(self.service.incoming_transaction_runnables), 1)

        # Check we read broadcast_period config
        self.assertEqual(self.service.broadcast_period, 60)

        self.service.start()

        walletnotify_handler = self.service.incoming_transaction_runnables[
            "btc"]
        deadline = time.time() + 3
        while not walletnotify_handler.ready:
            self.assertLess(time.time(), deadline)
Esempio n. 3
0
    def test_run_receive_scan(self):
        """See that we complete received transactions scan on startup."""

        config = self.prepare_config()

        self.service = service = Service(config, ALL_SUBSYSTEMS)
        self.service.setup_session()

        try:
            service.start()

            # My local test wallet is big...
            deadline = time.time() + 5 * 60
            while True:
                if service.receive_scan_thread:
                    if service.receive_scan_thread.complete:
                        break
                self.assertLess(time.time(), deadline,
                                "oops could not rescan incoming transactions")

        finally:
            service.shutdown()
Esempio n. 4
0
    def test_status(self):
        """See that the service broadcasts transactions when created."""

        config = self.prepare_config()

        self.service = service = Service(config, ALL_SUBSYSTEMS)
        self.service.setup_session()

        status_http_server = self.service.status_server
        self.assertIsNotNone(status_http_server)

        # Don't show wanted exceptions in the logging output
        status.logger.setLevel(logging.FATAL)

        try:

            service.start()

            # See that walletnotify handler cleans up itself
            deadline = time.time() + 3
            while not status_http_server.ready:
                self.assertLess(time.time(), deadline,
                                "Status server did not start")

            for page in ("/", "/wallets", "/transactions",
                         "/network_transactions", "/accounts", "/addresses"):
                report = requests.get("http://localhost:{}{}".format(
                    config["status_server"]["port"], page))
                self.assertEqual(report.status_code, 200,
                                 "Failed page {}".format(page))

                # See we handle exception in status server code
                report = requests.get("http://localhost:{}/error".format(
                    config["status_server"]["port"]))
                self.assertEqual(report.status_code, 500)

        finally:

            service.shutdown()
Esempio n. 5
0
 def handle(self, *args, **options):
     """ """
     config = settings.CRYPTOASSETS
     service = Service(config)
     service.initialize_db()
 def handle(self, *args, **options):
     """ """
     config = settings.CRYPTOASSETS
     # We do not need to initialize logging as Django does it for us
     service = Service(config, ALL_SUBSYSTEMS, logging=False)
     service.start()