def test_invalid_name(self): created = signal.create(self.btctxstore, self.wif, "test") # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) self.assertIsNone(signal.read(self.btctxstore, repacked, "wrongname"))
def test_invalid_token(self): created = base.create(self.btctxstore, self.wif, None, None) # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) repacked[2] = "invalidtoken" self.assertIsNone(signal.read(self.btctxstore, self.nodeid, repacked))
def test_create_read(self): # test create created = signal.create(self.btctxstore, self.wif, "test") # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) # test read read = signal.read(self.btctxstore, repacked, "test") self.assertIsNotNone(read) self.assertEqual(created, read)
def __call__(self, node, source_id, msg): request = signal.read(node.server.btctxstore, msg, "request_info") if request is not None: _respond(node, request.sender, self.store_config)
def handler(node, source_id, msg): request = signal.read(node.server.btctxstore, msg, "request_peers") if request is not None: peers = list(map(lambda n: n.id, node.get_neighbours())) msg = create(node.server.btctxstore, node.get_key(), peers) node.relay_message(request.sender, msg)