def __init__(self): cfg_file = File.normalize(ARGS.config or 'rippled.cfg') self.config = ConfigFile.read(open(cfg_file)) if ARGS.database != ARGS.NONE: reader = DatabaseReader.DatabaseReader(self.config) else: reader = RippledReader.RippledReader(self.config) self.reader = reader self.complete = reader.complete names = { 'closed': reader.name_to_ledger_index('closed'), 'current': reader.name_to_ledger_index('current'), 'validated': reader.name_to_ledger_index('validated'), 'first': self.complete[0] if self.complete else None, 'last': self.complete[-1] if self.complete else None, } self.__dict__.update(names) self.ledgers = sorted(Range.join_ranges(*ARGS.ledgers, **names)) def make_cache(is_full): name = 'full' if is_full else 'summary' filepath = os.path.join(ARGS.cache, name) creator = lambda n: reader.get_ledger(n, is_full) return FileCache(filepath, creator) self._caches = [make_cache(False), make_cache(True)]
def test_trivial(self): self.assertEquals(ConfigFile.read(''), {})
def test_full(self): self.assertEquals(ConfigFile.read(FULL.splitlines()), RESULT)