示例#1
0
    def __init__(self):
        set_testnet()
        # logging.config.fileConfig(log_conf_path)
        init()
        network = NetWorkManager()
        network.start()
        BlockChain().init_header()

        # todo: init from config
        self.conf = MyConfigParser()
        self.conf.read(conf_path)
        self.wallet_dict = SortedDict()
        for k, v in self.conf.items('wallet'):
            if k.startswith('wallet_name_'):
                wallet_name = k[12:]
                wallet_type = self.conf.get('wallet',
                                            'wallet_type_' + wallet_name)
                wallet_config_file = v  # self.conf.get('wallet', k)
                self.wallet_dict[wallet_name] = self.init_wallet(
                    wallet_type, wallet_config_file)

        self._current = self.conf.get('wallet', 'current')
        if self._current is not None:
            self.current_wallet = self.wallet_dict[self._current]
            self.current_wallet.sync()
        else:
            self.current_wallet = None
示例#2
0
    def test_application(self):
        manager = NetWorkManager()
        manager.start()

        @gen.coroutine
        def version_callback(msg_id, msg, param):
            self.is_callback = True
            self.assertEqual(msg_id, 0)
            self.assertEqual(msg, {'params': {}, 'method': 'server.version'})

        manager.add_message(Version({}), version_callback)

        manager.quit()
示例#3
0
class HowToUseChain(AsyncTestCase):
    def setUp(self):
        super(HowToUseChain, self).setUp()
        self.manager = NetWorkManager()
        self.manager.start()

    def tearDown(self):
        self.manager.quit()
        self.wait_quit()
        super(HowToUseChain, self).tearDown()

    @gen_test()
    def wait_quit(self):
        yield gen.sleep(MAX_WAIT_SECONDS_BEFORE_SHUTDOWN + 0.01)

    def test_application(self):
        bc = BlockChain()
        future = Future()
        future.set_result(open('../files/testnet_headers').read())
        bc.init_header_callback(future)
示例#4
0
 def test_base_wallet(self):
     network = NetWorkManager()
     network.start()
     wallet = SimpleWallet(
         WalletConfig(store_path=dirs.user_data_dir + '/' + '00.json'))
     wallet.sync()