def test_get_transactions_of_block_by_hash(self): """Test validity of transactions of a block selected by hash.""" db = rocksdb.DB(DB_PATH, rocksdb.Options(create_if_missing=True, max_open_files=10000), read_only=True) with open('tests/resources/block_hash_transactions.txt', 'r') as f: compare_data = json.loads(f.read()) block_hash = '0x57f8464fa5d5f8fc4f4926963e2df38afc4f4c378e933f46c7b3f727bc0c5dcb' gatherer = DatabaseGatherer(db) gathered_data = gatherer.get_transactions_of_block_by_hash(block_hash) self.assertEqual(compare_data, gathered_data)
def get_transactions_by_bhash(block_hash: str, db: Any = None) -> None: """ Get transactions of a block by its hash. Args: block_hash: Hash of the block. db: Read-only database instance. """ gatherer = DatabaseGatherer(db) transactions = gatherer.get_transactions_of_block_by_hash(block_hash.lower()) if transactions is None: return 'Block with hash {} not found'.format(block_hash), 404 return transactions