Beispiel #1
0
    async def test_test_inbound_chain(self):
        block1 = Block()
        block1.index = 0
        block1.hash = '3000000000000000'
        block1.prev_hash = ''

        block2 = Block()
        block2.index = 1
        block2.hash = '4000000000000000'
        blocks = [block1, block2]
        blockchain = await Blockchain.init_async(blocks)

        block1 = Block()
        block1.index = 0
        block1.hash = '3'
        block1.prev_hash = ''

        block2 = Block()
        block2.index = 1
        block2.hash = '5'

        block3 = Block()
        block3.index = 2
        block3.hash = '5'
        inbound_blocks = [block1, block2, block3]
        inbound_blockchain = await Blockchain.init_async(inbound_blocks)

        self.assertTrue(await
                        blockchain.test_inbound_blockchain(inbound_blockchain))
Beispiel #2
0
    async def test_is_consecutive(self):
        block1 = Block()
        block1.index = 0
        block1.hash = '3'
        block1.prev_hash = ''

        block2 = Block()
        block2.index = 1
        block2.hash = '4'
        block2.prev_hash = '3'
        blockchain = await Blockchain.init_async([block1, block2])
        self.assertTrue(await blockchain.is_consecutive)
Beispiel #3
0
    async def test_get_difficulty(self):
        block1 = Block()
        block1.index = 0
        block1.hash = '3000000000000000'
        block1.prev_hash = ''

        block2 = Block()
        block2.index = 1
        block2.hash = '4000000000000000'
        blocks = [block1, block2]
        blockchain = await Blockchain.init_async(blocks)
        result = await blockchain.get_difficulty()
        self.assertEqual(
            result,
            231584178474632390847141970017375815706539969331281128078907097565294011351038
        )