def test_real(self): ewctrl = EWalletController(self.pwallet.get_model(), self.wctrl) config = {"offer_expiry_interval": 30, "ep_expiry_interval": 30} comm1 = MockComm() comm2 = MockComm() comm1.add_peer(comm2) comm2.add_peer(comm1) agent1 = EAgent(ewctrl, config, comm1) agent2 = EAgent(ewctrl, config, comm2) self.cd0 = "obc:cc8e64cef1a880f5132e73b5a1f52a72565c92afa8ec36c445c635fe37b372fd:0:263370" self.cd1 = "obc:caff27b3fe0a826b776906aceafecac7bb34af16971b8bd790170329309391ac:0:265577" cv0 = {'color_spec': self.cd0, 'value': 100} cv1 = {'color_spec': self.cd1, 'value': 200} ag1_offer = MyEOffer(None, cv0, cv1) ag2_offer = MyEOffer(None, cv0, cv1) ag2_offer.auto_post = False agent1.register_my_offer(ag1_offer) agent2.register_my_offer(ag2_offer) for _ in xrange(3): agent1._update_state() agent2._update_state()
def p2ptrade_init(self): ewctrl = EWalletController(self.model, self.controller) config = {"offer_expiry_interval": 30, "ep_expiry_interval": 30} self.thread_comm = ThreadedComm( config, 'http://p2ptrade.btx.udoidio.info/messages') self.p2p_agent = EAgent(ewctrl, config, self.thread_comm) self.thread_comm.start()
def test_real(self): ewctrl = EWalletController(self.pwallet.get_model(), self.wctrl) config = {"offer_expiry_interval": 30, "ep_expiry_interval": 30} comm1 = MockComm() comm2 = MockComm() comm1.add_peer(comm2) comm2.add_peer(comm1) agent1 = EAgent(ewctrl, config, comm1) agent2 = EAgent(ewctrl, config, comm2) frobla_color_desc = "obc:cc8e64cef1a880f5132e73b5a1f52a72565c92afa8ec36c445c635fe37b372fd:0:263370" foo_color_desc = "obc:caff27b3fe0a826b776906aceafecac7bb34af16971b8bd790170329309391ac:0:265577" self.cd0 = OBColorDefinition(1, {'txhash': 'cc8e64cef1a880f5132e73b5a1f52a72565c92afa8ec36c445c635fe37b372fd', 'outindex': 0, 'height':263370}) self.cd1 = OBColorDefinition(1, {'txhash': 'caff27b3fe0a826b776906aceafecac7bb34af16971b8bd790170329309391ac', 'outindex': 0, 'height':265577}) cv0 = SimpleColorValue(colordef=self.cd0, value=100) cv1 = SimpleColorValue(colordef=self.cd1, value=200) ag1_offer = MyEOffer(None, cv0, cv1) ag2_offer = MyEOffer(None, cv0, cv1, False) agent1.register_my_offer(ag1_offer) agent2.register_my_offer(ag2_offer) for _ in xrange(3): agent1._update_state() agent2._update_state()
def test_basic(self): model = MockModel() ewctrl = EWalletController(model, None) config = {"offer_expiry_interval": 30, "ep_expiry_interval": 30} comm = MockComm() agent = EAgent(ewctrl, config, comm) # At this point the agent should not have an active proposal self.assertFalse(agent.has_active_ep()) # no messages should have been sent to the network self.assertEqual(len(comm.get_messages()), 0) color_spec = "obc:03524a4d6492e8d43cb6f3906a99be5a1bcd93916241f759812828b301f25a6c:0:153267" cv0 = {'color_spec': "", 'value': 100} cv1 = {'color_spec': color_spec, 'value': 200} my_offer = MyEOffer(None, cv0, cv1) their_offer = EOffer('abcdef', cv1, cv0) agent.register_my_offer(my_offer) agent.register_their_offer(their_offer) agent.update() # Agent should have an active exchange proposal self.assertTrue(agent.has_active_ep()) # Exchange proposal should have been sent over comm # it should be the only message, as we should not resend our offer # if their is an active proposal to match it self.assertTrue(len(comm.get_messages()), 1) [proposal] = comm.get_messages() # The offer data should be in the proposal their_offer_data = their_offer.get_data() self.assertEquals(their_offer_data, proposal["offer"])
def init_p2ptrade(self): from ngcccbase.p2ptrade.ewctrl import EWalletController from ngcccbase.p2ptrade.agent import EAgent from ngcccbase.p2ptrade.comm import HTTPComm ewctrl = EWalletController(self.model, self.controller) config = {"offer_expiry_interval": 30, "ep_expiry_interval": 30} comm = HTTPComm(config, 'http://p2ptrade.btx.udoidio.info/messages') agent = EAgent(ewctrl, config, comm) return agent
def setUp(self): self.pwallet = PersistentWallet(None, True) self.pwallet.init_model() self.model = self.pwallet.get_model() adm = self.model.get_asset_definition_manager() # make sure you have the asset 'testobc' in your testnet.wallet !! self.asset = adm.get_asset_by_moniker('testobc') self.color_spec = self.asset.get_color_set().get_data()[0] self.wc = WalletController(self.model) self.ewc = EWalletController(self.model, self.wc) def null(a): pass self.wc.publish_tx = null
def setUp(self): self.path = ":memory:" self.config = { 'hdw_master_key': '91813223e97697c42f05e54b3a85bae601f04526c5c053ff0811747db77cfdf5f1accb50b3765377c379379cd5aa512c38bf24a57e4173ef592305d16314a0f4', 'testnet': True, 'ccc': { 'colordb_path': self.path }, } self.pwallet = PersistentWallet(self.path, self.config) self.pwallet.init_model() self.model = self.pwallet.get_model() self.wc = WalletController(self.model) self.ewc = EWalletController(self.model, self.wc) self.bcolorset = self.ewc.resolve_color_spec('') self.cspec = "obc:03524a4d6492e8d43cb6f3906a99be5a1bcd93916241f759812828b301f25a6c:0:153267"
def setUp(self): self.path = ":memory:" self.config = { 'hdw_master_key': '91813223e97697c42f05e54b3a85bae601f04526c5c053ff0811747db77cfdf5f1accb50b3765377c379379cd5aa512c38bf24a57e4173ef592305d16314a0f4', 'testnet': True, 'ccc': { 'colordb_path': self.path }, } self.pwallet = PersistentWallet(self.path, self.config) self.pwallet.init_model() self.model = self.pwallet.get_model() self.wc = WalletController(self.model) self.ewc = EWalletController(self.model, self.wc) self.econfig = {"offer_expiry_interval": 30, "ep_expiry_interval": 30} self.comm0 = MockComm() self.comm1 = MockComm() self.comm0.add_peer(self.comm1) self.comm1.add_peer(self.comm0) self.agent0 = EAgent(self.ewc, self.econfig, self.comm0) self.agent1 = EAgent(self.ewc, self.econfig, self.comm1) self.cspec = "obc:03524a4d6492e8d43cb6f3906a99be5a1bcd93916241f759812828b301f25a6c:0:153267"
def setUp(self): self.pwallet = PersistentWallet(None, True) self.pwallet.init_model() self.model = self.pwallet.get_model() adm = self.model.get_asset_definition_manager() # make sure you have the asset 'testobc' in your testnet.wallet !! self.asset = adm.get_asset_by_moniker('testobc') self.color_spec = self.asset.get_color_set().get_data()[0] self.comm0 = MockComm() self.comm1 = MockComm() self.comm0.add_peer(self.comm1) self.comm1.add_peer(self.comm0) self.wc = WalletController(self.model) self.ewc = EWalletController(self.model, self.wc) self.econfig = {"offer_expiry_interval": 30, "ep_expiry_interval": 30} self.agent0 = EAgent(self.ewc, self.econfig, self.comm0) self.agent1 = EAgent(self.ewc, self.econfig, self.comm1) self.cv0 = {'color_spec': "", 'value': 100} self.cv1 = {'color_spec': self.color_spec, 'value': 200} self.offer0 = MyEOffer(None, self.cv0, self.cv1) self.offer1 = MyEOffer(None, self.cv1, self.cv0)
def _init_p2ptrade(self): ewctrl = EWalletController(self.model, self.controller) config = {"offer_expiry_interval": 30, "ep_expiry_interval": 30} comm = HTTPComm(config, 'http://p2ptrade.btx.udoidio.info/messages') return EAgent(ewctrl, config, comm)