コード例 #1
0
    def test_get_transaction(self):
        """Test validity of transaction data."""
        db = rocksdb.DB(DB_PATH,
                        rocksdb.Options(create_if_missing=True,
                                        max_open_files=10000),
                        read_only=True)
        with open('tests/resources/tx_data.txt', 'r') as f:
            compare_data = json.loads(f.read())

        tx_hash = '0x57f281bf8792353cdab545fe439410f0f6478e272e1dcc5748d87299d32373e7'
        gatherer = DatabaseGatherer(db)
        gathered_data = gatherer.get_transaction_by_hash(tx_hash)

        self.assertEqual(compare_data, gathered_data)
コード例 #2
0
def read_transaction(tx_hash: str, db: Any = None) -> None:
    """
    Get transaction by its hash.

    Args:
        tx_hash: Hash of the transaction.
        db: Read-only database instance.
    """
    gatherer = DatabaseGatherer(db)
    transaction = gatherer.get_transaction_by_hash(tx_hash.lower())
    if transaction is None:
        return 'Transaction with hash {} not found'.format(tx_hash), 404

    return transaction