consensus-test
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Consensus.HardFork.History

Description

Hard fork history tests.

This is the more interesting test of the hard fork history. We construct a mock chain, consisting of events (events are roughly, but not quite, "blocks"). For every event we record its slot number, epoch number, wall clock, etc. Since we are constructing this chain as a whole, from genesis to its tip, constructing these events is trivial. We then split this chain in half, and construct a Summary from the first half. We then use that summary to do conversions for any event on the chain. Since every event records all information, we can easily verify whether the answers we are getting back are correct. Moreover, since the summary is constructed from only the first part of the chain, but is used to do conversions across the entire chain, we verify that predictions about the "future" also work as correctly (including that the conversions say "outside range" if and only if the model expects them to be).

Synopsis

Documentation

testsTestTree Source #

Tests for summarize

General approach:

  • Generate a chain of events
  • Each event records its own RelativeTime, SlotNo, and EpochNo
  • We then construct a Summary from a prefix of this chain
  • We then pick an arbitrary event from the (full) chain: a. If that event is on the prefix of the chain, or within the safe zone, we expect to be able to do any slotepoch or slottime conversion, and we can easily verify the result by comparing it to the values the Event itself reports. b. If the event is outside of safe zone, we expect the conversion to throw a PastHorizonException.