Skip to content

[#420] Ensure `NettestEnv` is not evaluated before the tests are run

Diogo Castro requested to merge diogo/#420-nettestenv-cache-v2 into master

Description

Problem: we found some very specific scenarios where using unsafePerformIO to create a NettestEnv in Morley.Nettest.Tasty can lead to crashes in the CI.

See issue for details: #420 (closed)

The conclusion was that we should somehow ensure that IO NettestEnv is not run while the TestTree is being built/traversed, but only when the tests have started running.

Solution: The idea is to force the user to evaluate IO NettestEnv inside the test case, instead of evaluating it ourselves in Morley.Nettest.Tasty.

This MR also fixes a couple other small problems:

  1. Replaced withNettestEnv with whenNetworkEnabled to reduce some duplication
  2. Ensure tests that use whenNetworkEnabled don't run at the same time as tests that use nettestScenario/nettestScenarioCaps.
  3. In !613 (merged), I accidentally introduced a bug and now only 20 out of the 233 contracts are being tested. This MR fixes that.

Related issue(s)

Resolves #420 (closed)

Checklist for your Merge Request

Related changes (conditional)

  • Tests (see short guidelines)

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:
    • I updated changelog files of all affected packages released to Hackage if my changes are externally visible.

Stylistic guide (mandatory)

Edited by Diogo Castro

Merge request reports