def test_invalid_info_len(self): created = base.create(self.btctxstore, self.wif, "info", []) # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) self.assertIsNone(info.read(self.btctxstore, repacked))
def test_invalid_peer_type(self): created = base.create(self.btctxstore, self.wif, "peers", None) # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) self.assertIsNone(peers.read(self.btctxstore, repacked))
def create(btctxstore, node_wif, capacity, transport, unl, is_public): storage = Storage(**capacity) network = Network(transport, unl, is_public) plat = Platform(platform.system(), platform.release(), platform.version(), platform.machine()) info = Info(__version__, storage, network, plat) return base.create(btctxstore, node_wif, "info", info)
def test_invalid_storage_value_types(self): _info = ["0.0.0", [None, 0, 0], None, None] created = base.create(self.btctxstore, self.wif, "info", _info) # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) self.assertIsNone(info.read(self.btctxstore, repacked))
def test_invalid_version_value(self): _info = ["invalidversion", None, None, None] created = base.create(self.btctxstore, self.wif, "info", _info) # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) self.assertIsNone(info.read(self.btctxstore, repacked))
def test_invalid_platform_len(self): _info = ["0.0.0", [2, 1, 1], [["127.0.0.1", 1337], "unl", True], []] created = base.create(self.btctxstore, self.wif, "info", _info) # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) self.assertIsNone(info.read(self.btctxstore, repacked))
def test_invalid_network_ip(self): _info = ["0.0.0", [2, 1, 1], [["invalid", None], "unl", True], None] created = base.create(self.btctxstore, self.wif, "info", _info) # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) self.assertIsNone(info.read(self.btctxstore, repacked))
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_invalid_message(self): created = base.create(self.btctxstore, self.wif, None, None) # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) repacked[0] = "invalidnodeid" self.assertIsNone(peers.read(self.btctxstore, repacked))
def test_read_invalid_signature(self): created = base.create(self.btctxstore, self.wif, None, None) # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) repacked[4] = "x" * 65 self.assertIsNone(base.read(self.btctxstore, repacked))
def test_read_invalid_version_value(self): created = base.create(self.btctxstore, self.wif, None, None) # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) repacked[1] = -1 self.assertIsNone(base.read(self.btctxstore, repacked))
def test_read_invalid_nodeid_type(self): created = base.create(self.btctxstore, self.wif, None, None) # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) repacked[0] = None self.assertIsNone(base.read(self.btctxstore, repacked))
def test_create_read(self): # test create created = base.create(self.btctxstore, self.wif, "token", "body") # repack to eliminate namedtuples and simulate io repacked = umsgpack.unpackb(umsgpack.packb(created)) # test read read = base.read(self.btctxstore, repacked) self.assertIsNotNone(read) self.assertEqual(created, read)
def create(btctxstore, node_wif, capacity, transport, is_public): storage = Storage(**capacity) network = Network(transport, is_public) info = Info(__version__, storage, network) return base.create(btctxstore, node_wif, "info", info)
def create(btctxstore, node_wif, peers): peers = reduce(lambda a, b: a + b, peers, b"") return base.create(btctxstore, node_wif, "peers", peers)
def create(btctxstore, wif, name): return base.create(btctxstore, wif, "signal", name)