Example #1
0
    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))
Example #2
0
    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))
Example #3
0
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)
Example #4
0
    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))
Example #5
0
    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))
Example #6
0
    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))
Example #7
0
    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))
Example #8
0
    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))
Example #9
0
    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))
Example #10
0
    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))
Example #11
0
    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))
Example #12
0
    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))
Example #13
0
    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)
Example #14
0
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)
Example #15
0
def create(btctxstore, node_wif, peers):
    peers = reduce(lambda a, b: a + b, peers, b"")
    return base.create(btctxstore, node_wif, "peers", peers)
Example #16
0
def create(btctxstore, wif, name):
    return base.create(btctxstore, wif, "signal", name)