Пример #1
0
    def test_complex_methods(self):
        from pypoptools.pypopminer import MockMiner, PublicationData
        m = MockMiner()

        last_known_btc_hash = m.btcTip.getHash()
        m.mineBtcBlocks(1)

        endorsed_block = m.vbkTip
        vbk_pop_tx = m.createVbkPopTxEndorsingVbkBlock(endorsed_block,
                                                       last_known_btc_hash)
        self.assertEqual(vbk_pop_tx.publishedBlock.getHash(),
                         endorsed_block.getHash())
        self.assertEqual(len(vbk_pop_tx.blockOfProofContext), 1)

        last_known_vbk_hash = m.vbkTip.getHash()
        m.mineVbkBlocks(1, [vbk_pop_tx], True)

        endorsed_block = m.vbkTip
        vtb = m.endorseVbkBlock(endorsed_block, last_known_btc_hash)
        self.assertEqual(vtb.transaction.publishedBlock.getHash(),
                         endorsed_block.getHash())
        self.assertEqual(len(vtb.transaction.blockOfProofContext), 2)

        pub_data = PublicationData()
        pub_data.identifier = 1337
        pub_data.header = "0011223344"
        pub_data.payoutInfo = "0014aaddff"
        pop_data = m.endorseAltBlock(pub_data, last_known_vbk_hash)
        self.assertEqual(len(pop_data.atvs), 1)
        self.assertEqual(len(pop_data.vtbs), 2)
        self.assertEqual(len(pop_data.context), 2)
Пример #2
0
    def test_mock_miner_can_produce_publications(self):
        from pypoptools.pypopminer import MockMiner, PublicationData
        m = MockMiner()
        self.assertEqual(m.vbkTip.previousBlock, "000000000000000000000000")
        self.assertEqual(m.vbkTip.height, 0)

        endorsed = m.mineVbkBlocks(100)
        self.assertEqual(endorsed.height, 100)
        m.endorseVbkBlock(endorsed, m.btcTip.getHash())

        p = PublicationData()
        p.identifier = 1337
        p.header = "0011223344"
        p.payoutInfo = "0014aaddff"
        payloads = m.endorseAltBlock(p, endorsed.getHash())
        print(repr(payloads))
        self.assertEqual(len(payloads.vtbs), 1)
        self.assertEqual(m.vbkTip.height, 102)