Beispiel #1
0
    def test_block_header(self):
        bts = self.bts
        test_block_id = self.test_block_id
        block = BlockHeader(test_block_id, steem_instance=bts)
        self.assertEqual(block.identifier, test_block_id)
        self.assertTrue(isinstance(block.time(), datetime))
        self.assertTrue(isinstance(block, dict))

        block2 = BlockHeader(test_block_id + 1, steem_instance=bts)
        self.assertTrue(block2.time() > block.time())
        with self.assertRaises(exceptions.BlockDoesNotExistsException):
            BlockHeader(0, steem_instance=bts)
Beispiel #2
0
    def test_block_header(self, node_param):
        if node_param == "non_appbase":
            bts = self.bts
        else:
            bts = self.appbase
        block = BlockHeader(self.test_block_id, steem_instance=bts)
        self.assertEqual(block.identifier, self.test_block_id)
        self.assertTrue(isinstance(block.time(), datetime))
        self.assertTrue(isinstance(block, dict))

        block2 = BlockHeader(self.test_block_id + 1, steem_instance=bts)
        self.assertTrue(block2.time() > block.time())
        with self.assertRaises(exceptions.BlockDoesNotExistsException):
            BlockHeader(0, steem_instance=bts)
Beispiel #3
0
    def test_export(self, node_param):
        if node_param == "normal":
            bts = self.bts
            block_num = 2000000
        else:
            bts = self.testnet
            block_num = 2

        if bts.rpc.get_use_appbase():
            block = bts.rpc.get_block({"block_num": block_num}, api="block")
            if block and "block" in block:
                block = block["block"]
        else:
            block = bts.rpc.get_block(block_num)

        b = Block(block_num, steem_instance=bts)
        keys = list(block.keys())
        json_content = b.json()

        for k in keys:
            if k not in "json_metadata":
                if isinstance(block[k], dict) and isinstance(
                        json_content[k], list):
                    self.assertEqual(list(block[k].values()), json_content[k])
                else:
                    self.assertEqual(block[k], json_content[k])

        if bts.rpc.get_use_appbase():
            block = bts.rpc.get_block_header({"block_num": block_num},
                                             api="block")
            if "header" in block:
                block = block["header"]
        else:
            block = bts.rpc.get_block_header(block_num)

        b = BlockHeader(block_num, steem_instance=bts)
        keys = list(block.keys())
        json_content = b.json()

        for k in keys:
            if k not in "json_metadata":
                if isinstance(block[k], dict) and isinstance(
                        json_content[k], list):
                    self.assertEqual(list(block[k].values()), json_content[k])
                else:
                    self.assertEqual(block[k], json_content[k])
Beispiel #4
0
                        else:
                            block_num_est_method = "beem"
                            if last_vops_timestamp is not None and abs(
                                (vop["trigger_date"] -
                                 last_vops_timestamp).total_seconds()) < 6:
                                print("diff  to last vops %.2s" %
                                      (vop["trigger_date"] -
                                       last_vops_timestamp).total_seconds())
                            block_num = b.get_estimated_block_num(
                                vop["trigger_date"])

                            last_vops_block_num = block_num
                            last_vops_timestamp = vop["trigger_date"]
                            try:
                                block = BlockHeader(block_num,
                                                    steem_instance=stm)
                                timestamp = block['timestamp'].replace(
                                    tzinfo=None)
                            except:
                                timestamp = vop["trigger_date"]
                        print("Vops estimate %s took %.2f s - %s" %
                              (str(vop["trigger_date"]),
                               time.time() - start_time, block_num_est_method))

                        table2 = connection["transactions"]
                        data = dict(trx=vop["parent_trx"],
                                    user=vop["user"],
                                    tr_type=vop["tr_type"],
                                    block_num=block_num,
                                    tr_var1=vop["tr_var1"],
                                    tr_var2=vop["tr_var2"],