예제 #1
0
파일: id_lib.py 프로젝트: luomin/bbc1
 def __init__(self,
              domain_id,
              namespace_id=default_namespace_id,
              port=DEFAULT_CORE_PORT,
              logname="-",
              loglevel="none"):
     self.logger = logger.get_logger(
         key="id_lib", level=loglevel,
         logname=logname)  # FIXME: use the logger
     self.domain_id = domain_id
     self.namespace_id = namespace_id
     self.__app = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT,
                                       loglevel=loglevel)
     self.__app.set_user_id(id_publickey_map_user_id)
     self.__app.set_domain_id(domain_id)
     self.__app.set_callback(bbc_app.Callback())
     ret = self.__app.register_to_core()
     assert ret
     self.__db = app_support_lib.Database()
     self.__db.setup_db(domain_id, NAME_OF_DB)
     self.__db.create_table_in_db(domain_id,
                                  NAME_OF_DB,
                                  'id_pubkey_table',
                                  id_pubkey_table_definition,
                                  indices=[0, 1])
예제 #2
0
def setup_bbc_client():
    bbc_app_client = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT, loglevel="all")
    bbc_app_client.set_user_id(user_id)
    bbc_app_client.set_asset_group_id(asset_group_id)
    bbc_app_client.set_callback(bbc_app.Callback())
    ret = bbc_app_client.register_to_core()
    assert ret
    return bbc_app_client
예제 #3
0
def setup_bbc_client(port_increase=0, user_id=None):
    bbc_app_client = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT +
                                          port_increase,
                                          loglevel="all")
    bbc_app_client.set_user_id(user_id)
    bbc_app_client.set_domain_id(domain_id)
    bbc_app_client.set_callback(bbc_app.Callback())
    bbc_app_client.domain_setup(domain_id)
    bbc_app_client.callback.synchronize()
    return bbc_app_client
예제 #4
0
def test_store():

    (mint_id, keypairs) = idPubkeyMap.create_user_id(num_pubkeys=1)

    app = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT, loglevel="all")
    app.set_user_id(mint_id)
    app.set_domain_id(domain_id)
    app.set_callback(bbc_app.Callback())
    ret = app.register_to_core()

    store = token_lib.Store(domain_id, mint_id, app)

    currency_spec = token_lib.CurrencySpec({
        'name': "Japanese Yen",
        'symbol': "JPY",
    })

    store.set_condition(0, keypair=keypairs[0], idPublickeyMap=idPubkeyMap)
    store.set_currency_spec(currency_spec,
                            keypair=keypairs[0],
                            idPublickeyMap=idPubkeyMap)

    assert store.get_condition() == 0
    assert store.get_currency_spec() == currency_spec
예제 #5
0
def setup_bbc_client(port_increase=0, user_id=None):
    bbc_app_client = bbc_app.BBcAppClient(port=DEFAULT_CORE_PORT+port_increase, loglevel="all")
    bbc_app_client.set_user_id(user_id)
    bbc_app_client.set_callback(bbc_app.Callback())
    return bbc_app_client