Skip to content

[#537] Add predicate to expect any custom error

Description

Problem: sometimes we want to test a contract that might throw both simple text and pairs of text and some argument as errors (as per FA2 standard). We also might not care which one exactly. There's currently no simple way to test for such cases.

Solution: Add failedWithPredicate, which allows testing the error value (represented as a raw Expression) against some predicate. Implement failedWith in terms of failedWithPredicate. Add expectAnyCustomError function, which treats the failwith error as an untyped value and checks if it could in theory be typechecked as either string or pair string *. Discards the argument if it exists.

Related issue(s)

Resolves #537 (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 Nikolay Yakimov

Merge request reports

Loading