[#687] Fix `getRunMode` and `whenEmulated`
Description
Problem: getRunMode
and whenEmulated
behave is counter-intuitively,
and haddock comments are fairly misleading:
Check at runtime whether are we executed against network or in emulation.
In practice, the result depends solely on the type of the scenario:
if it's ClevelandT
, getRunMode
returns NetworkMode
, and for
EmulatedT
, respectively EmulationMode
.
We would like the result to depend on the base monad (i.e. PureM
or
ClientM
) instead.
Solution: Fixing getRunMode
turns out to be a little tricky,
especially after !1027 (merged), since we don't have late binding, and it
makes it impossible to inject the emulated capability mid-scenario.
Hence, getRunMode
is replaced by ifEmulation
helper. PureM
can provide an EmulatedImpl
on demand, so we add cmiEmulatedImpl
,
which is Nothing
in ClientM
, and implement ifEmulation
in terms of
that. whenEmulation
and a new helper whenNetwork
are implemented via
ifEmulation
.
One quirk is that we need a way to get ClevelandCaps
polymorphically,
for that clevelandCapsL
is introduced. senderL
, moneybagL
,
getMiscCap
, getOpsCap
can then be defined in terms of
clevelandCapsL
.
Related issue(s)
Resolves #687 (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
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.