public async Task TestBadgerRounds() { var dbPath = GetPath(); var cacheSize = 0; var(store, participants) = await InitBadgerStore(cacheSize, dbPath, logger); var round = new RoundInfo(); var events = new Dictionary <string, Event>(); foreach (var p in participants) { var ev = new Event(new[] { new byte[] { } }, new BlockSignature[] {}, new[] { "", "" }, p.PubKey, 0); events[p.Hex] = ev; round.AddEvent(ev.Hex(), true); } StoreError err; using (var tx = store.BeginTx()) { err = await store.SetRound(0, round); Assert.Null(err); tx.Commit(); } var c = store.LastRound(); Assert.Equal(0, c); RoundInfo storedRound; (storedRound, err) = await store.GetRound(0); Assert.Null(err); storedRound.ShouldCompareTo(round); var witnesses = await store.RoundWitnesses(0); var expectedWitnesses = round.Witnesses(); Assert.Equal(expectedWitnesses.Length, witnesses.Length); foreach (var w in expectedWitnesses) { Assert.Contains(w, witnesses); } }
public async Task TestInmemRounds() { var(store, participants) = InitInmemStore(10); var round = new RoundInfo(); var events = new Dictionary <string, Event>(); foreach (var p in participants) { var ev = new Event(new[] { new byte[] { } }, new BlockSignature[] { }, new[] { "", "" }, p.PubKey, 0); events[p.Hex] = ev; round.AddEvent(ev.Hex(), true); } // Store Round var err = await store.SetRound(0, round); Assert.Null(err); RoundInfo storedRound; (storedRound, err) = await store.GetRound(0); Assert.Null(err); round.ShouldCompareTo(storedRound); // Check LastRound var c = store.LastRound(); Assert.Equal(0, c); // Check witnesses var witnesses = await store.RoundWitnesses(0); var expectedWitnesses = round.Witnesses(); Assert.Equal(expectedWitnesses.Length, witnesses.Length); foreach (var w in expectedWitnesses) { Assert.Contains(w, witnesses); } }