def get_transactions_by_bindex(block_index: str, db: Any = None) -> None: """ Get transactions of a block by its index. Args: block_index: Index of the block. db: Read-only database instance. """ gatherer = DatabaseGatherer(db) transactions = gatherer.get_transactions_of_block_by_index(block_index) if transactions is None: return 'Block with index {} not found'.format(block_index), 404 return transactions
def test_get_transactions_of_block_by_index(self): """Test validity of transactions of a block selected by index.""" db = rocksdb.DB(DB_PATH, rocksdb.Options(create_if_missing=True, max_open_files=10000), read_only=True) with open('tests/resources/block_index_transactions.txt', 'r') as f: compare_data = json.loads(f.read()) block_index = '25829' gatherer = DatabaseGatherer(db) gathered_data = gatherer.get_transactions_of_block_by_index( block_index) self.assertEqual(compare_data, gathered_data)