Handle callstacks properly for pure errors
Description
Currently, there seem to be some issues in case an erroring value is passed to a nettest function. Let's see whether trying to resolve them is viable.
Steps to reproduce
Go to martoon/pure-error-callstack-issue
branch, see the change in the last commit.
Run the tests: make -C code/cleveland morley-test-hide-successes TEST_ARGUMENTS='-parbitrary'
Expected behaviour
The error message points to checkBalance
or some other reasonable place within the test scenario.
Actual behaviour
The error message points to some places within Morley.Nettest.Pure
.
✗ when parameter is an arbitrary value failed at src/Morley/Nettest/Pure.hs:66:19
after 1 test.
┏━━ morley-test/Test/Interpreter/StringCaller.hs ━━━
39 ┃ testImpl ::
40 ┃ (U.Contract, T.Contract 'TString 'TAddress)
41 ┃ -> (U.Contract, T.Contract 'TString 'TString)
42 ┃ -> TestTree
43 ┃ testImpl (uStringCaller, _stringCaller) (uFailOrStore, _failOrStoreAndTransfer) =
44 ┃ -- failOrStoreAndTransfer's pre-conditions:
45 ┃ -- balance is >= 1300
46 ┃ testGroup "calls failOrStoreAndTransfer, updates storage & balance, checks pre-conditions"
47 ┃ [ nettestScenarioCaps "when parameter is a constant" $
48 ┃ scenario uStringCaller uFailOrStore constStr
49 ┃
50 ┃ -- The test is trivial, so it's kinda useless to run it many times
51 ┃ , testProperty "when parameter is an arbitrary value" $
52 ┃ withTests 2 $ property $ do
53 ┃ mtext <- forAll genMText
┃ │ MTextUnsafe { unMText = "" }
54 ┃ nettestTestProp $ uncapsNettest (scenario uStringCaller uFailOrStore mtext)
55 ┃ ]
56 ┃ where
57 ┃ constStr = "caller"
┏━━ src/Morley/Nettest/Pure.hs ━━━
65 ┃ nettestTestProp :: (MonadIO m, MonadTest m) => NettestScenario PureM -> m ()
66 ┃ nettestTestProp = evalIO . scenarioToIO
┃ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
┃ │ ━━━ Exception (WithCallStack) ━━━
┃ │ CallStack (from HasCallStack):
┃ │ checkBalance, called at morley-test/Test/Interpreter/StringCaller.hs:113:5 in main:Test.Interpreter.StringCaller
┃ │ unsafeSubMutez: underflow
┃ │ CallStack (from HasCallStack):
┃ │ error, called at src/Tezos/Core.hs:156:29 in morley-1.14.0-EBOVmFPc8GjC6C2MW1gMCD:Tezos.Core
┃ │ unsafeSubMutez, called at src/Morley/Nettest/Instances.hs:23:9 in cleveland-0.1.0-9dy9fdbdYQUKmX1N67QTQT:Morley.Nettest.Instances
This failure can be reproduced by running:
> recheck (Size 0) (Seed 15998834580286146485 11404700594371883027) when parameter is an arbitrary value
Use '--hedgehog-replay "Size 0 Seed 15998834580286146485 11404700594371883027"' to reproduce.
1 out of 1 tests failed (0.01s)
Environment
- Revision: -
Edited by Konstantin Ivanov