Skip to content

Commit

Permalink
Document all tests that did not have documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Niols authored and facundominguez committed Aug 6, 2024
1 parent 47ded40 commit e247540
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ tests =
]

-- | Tests that the selection advances in presence of the LoE when a peer is
-- killed by something that is not LoE-aware, eg. the timeouts.
-- killed by something that is not LoE-aware, eg. the timeouts. This test
-- features an honest peer behaving normally and an adversarial peer behaving
-- such that it will get killed by timeouts. We check that, after the adversary
-- gets disconnected, the LoE gets updated to stop taking it into account. There
-- are two variants of the test: one with timeouts enabled, and one without. In
-- the case where timeouts are disabled, we check that we do in fact remain
-- stuck at the intersection between trunk and other chain.
--
-- NOTE: Same as 'LoP.prop_delayAttack' with timeouts instead of LoP.
prop_adversaryHitsTimeouts :: Bool -> Property
prop_adversaryHitsTimeouts timeoutsEnabled =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ tests =
testProperty "delaying attack fails with LoP" (prop_delayAttack True)
]

-- | Simple test in which we connect to only one peer, who advertises the tip of
-- the block tree trunk and then does nothing. If the given boolean,
-- @mustTimeout@, if @True@, then we wait just long enough for the LoP bucket to
-- empty; we expect to observe an 'EmptyBucket' exception in the ChainSync
-- client. If @mustTimeout@ is @False@, then we wait not quite as long, so the
-- LoP bucket should not be empty at the end of the test and we should observe
-- no exception in the ChainSync client.
prop_wait :: Bool -> Property
prop_wait mustTimeout =
forAllGenesisTest
Expand Down Expand Up @@ -89,6 +96,13 @@ prop_wait mustTimeout =
, psMinEndTime = Time $ timeout + offset
}

-- | Simple test in which we connect to only one peer, who advertises the tip of
-- the block tree trunk, serves all of its headers, and then does nothing.
-- Because the peer does not send its blocks, then the ChainSync client will end
-- up stuck, waiting behind the forecast horizon. We expect that the LoP will
-- then be disabled and that, therefore, one could wait forever in this state.
-- We disable the timeouts and check that, indeed, the ChainSync client observes
-- no exception.
prop_waitBehindForecastHorizon :: Property
prop_waitBehindForecastHorizon =
forAllGenesisTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ tests =
testProperty "one adversary" prop_longRangeAttack
]

-- | This test case features a long-range attack with one adversary. The honest
-- peer serves the block tree trunk, while the adversary serves its own chain,
-- forking off the trunk by at least @k@ blocks, but less good than the trunk.
-- The adversary serves the chain more rapidly than the honest peer. We check at
-- the end that the selection is honest. This property does not hold with Praos,
-- but should hold with Genesis.
prop_longRangeAttack :: Property
prop_longRangeAttack =
-- NOTE: `shrinkPeerSchedules` only makes sense for tests that expect the
Expand Down

0 comments on commit e247540

Please sign in to comment.