Ejemplo n.º 1
0
def test_config_get_irc_channel():
    load_test_config()
    channel = "dummy"
    assert get_config_irc_channel(channel) == "#dummy-test"
    jm_single().config.set("BLOCKCHAIN", "network", "mainnet")
    assert get_config_irc_channel(channel) == "#dummy"
    get_irc_mchannels()
    load_test_config()
Ejemplo n.º 2
0
    def clientStart(self):
        """Upon confirmation of network connection
        to daemon, request message channel initialization
        with relevant config data for our message channels
        """
        if self.client.aborted:
            return
        #needed only for naming convention in IRC currently
        blockchain_source = jm_single().config.get("BLOCKCHAIN",
                                                   "blockchain_source")
        #needed only for channel naming convention
        network = jm_single().config.get("BLOCKCHAIN", "network")
        irc_configs = get_irc_mchannels()
        minmakers = jm_single().config.getint("POLICY", "minimum_makers")
        maker_timeout_sec = jm_single().maker_timeout_sec

        #To avoid creating yet another config variable, we set the timeout
        #to 20 * maker_timeout_sec.
        if not hasattr(self.client, 'testflag'): #pragma: no cover
            reactor.callLater(20*maker_timeout_sec, self.stallMonitor,
                          self.client.schedule_index+1)

        d = self.callRemote(commands.JMInit,
                            bcsource=blockchain_source,
                            network=network,
                            irc_configs=json.dumps(irc_configs),
                            minmakers=minmakers,
                            maker_timeout_sec=maker_timeout_sec)
        self.defaultCallbacks(d)
Ejemplo n.º 3
0
def main():
    parser = OptionParser(
        usage='usage: %prog [options]',
        description='Runs a webservice which shows the orderbook.')
    add_base_options(parser)
    parser.add_option('-H',
                      '--host',
                      action='store',
                      type='string',
                      dest='host',
                      default='localhost',
                      help='hostname or IP to bind to, default=localhost')
    parser.add_option('-p',
                      '--port',
                      action='store',
                      type='int',
                      dest='port',
                      help='port to listen on, default=62601',
                      default=62601)
    (options, args) = parser.parse_args()
    load_program_config(config_path=options.datadir)
    hostport = (options.host, options.port)
    mcs = [ObIRCMessageChannel(c) for c in get_irc_mchannels()]
    mcc = MessageChannelCollection(mcs)
    mcc.set_nick(get_dummy_nick())
    taker = ObBasic(mcc, hostport)
    log.info("Starting ob-watcher")
    mcc.run()
Ejemplo n.º 4
0
    def clientStart(self):
        """Upon confirmation of network connection
        to daemon, request message channel initialization
        with relevant config data for our message channels
        """
        if self.client.aborted:
            return
        #needed only for naming convention in IRC currently
        blockchain_source = jm_single().config.get("BLOCKCHAIN",
                                                   "blockchain_source")
        #needed only for channel naming convention
        network = jm_single().config.get("BLOCKCHAIN", "network")
        irc_configs = get_irc_mchannels()
        #only here because Init message uses this field; not used by makers TODO
        minmakers = jm_single().config.getint("POLICY", "minimum_makers")
        maker_timeout_sec = jm_single().maker_timeout_sec

        d = self.callRemote(commands.JMInit,
                            bcsource=blockchain_source,
                            network=network,
                            irc_configs=json.dumps(irc_configs),
                            minmakers=minmakers,
                            maker_timeout_sec=maker_timeout_sec,
                            dust_threshold=jm_single().DUST_THRESHOLD)
        self.defaultCallbacks(d)
def get_ob():
    load_program_config()
    dm = DummyDaemon()
    mc = DummyMC(get_irc_mchannels()[0], "test", dm)
    ob = OrderbookWatch()
    ob.on_welcome = on_welcome
    ob.set_msgchan(mc)
    return ob
 def clientStart(self):
     self.sigs_received = 0
     irc = get_irc_mchannels()
     d = self.callRemote(JMInit,
                         bcsource="dummyblockchain",
                         network="dummynetwork",
                         irc_configs=json.dumps(irc),
                         minmakers=2,
                         maker_timeout_sec=3)
     self.defaultCallbacks(d)
def getmc(nick):
    dm = DummyDaemon()
    mc = DummyMC(get_irc_mchannels()[0], nick, dm)
    mc.register_orderbookwatch_callbacks(on_order_seen=on_order_seen)
    mc.register_taker_callbacks(on_pubkey=on_pubkey)
    mc.on_connect = on_connect
    mc.on_disconnect = on_disconnect
    mc.on_welcome = on_welcome
    mcc = MessageChannelCollection([mc])
    return dm, mc, mcc
def get_ob():
    load_test_config()
    dm = DummyDaemon()
    mc = DummyMC(get_irc_mchannels()[0], "test", dm)
    ob = OrderbookWatch()
    ob.on_welcome = on_welcome
    ob.set_msgchan(mc)
    # would usually be set in JMInit; we use
    # a fake small value to allow small orders:
    ob.dust_threshold = 2
    return ob
Ejemplo n.º 9
0
 def setUp(self):
     load_test_config()
     print(get_irc_mchannels()[0])
     jm_single().maker_timeout_sec = 1
     dm, mc, mcc = getmc("irc_publisher")
     dm2, mc2, mcc2 = getmc("irc_receiver")
     mcc.run()
     mcc2.run()
     def cb(m):
         #don't try to reconnect
         m.give_up = True
         m.tcp_connector.disconnect()
     self.addCleanup(cb, mc)
     self.addCleanup(cb, mc2)
     #test_junk_messages()
     print("Got here")