question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Testing: Assert on dev revert strings (ape test)

See original GitHub issue

Overview

be able to assert using ape.reverts on the dev revert message (it’s like a special comment in the contract source file).

this feature requires #347 transaction tracing in order to see what line of code the failure occurred on. could also just show the failed line of code directly with the assert, but the dev revert string is useful for coverage testing

Specification

with ape.reverts(dev_message="This is a dev message"):
   ...

The dev_message should be a mutually exclusive parameter from the existing expected_message.

Dependencies

#347 Look at how brownie did it as an example! https://eth-brownie.readthedocs.io/en/stable/api-test.html#brownie.test.plugin.RevertContextManager

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
helloibiscommented, Nov 29, 2022
0reactions
helloibiscommented, Aug 5, 2022

Status update: once https://github.com/ApeWorX/ape/issues/937 is completed this will be able to be finished as well

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing — ape documentation - ApeWorX
Testing Transaction Failures. Similar to pytest. raises() , you can use ape. reverts() to assert that contract transactions fail and revert.
Read more >
How to write test classes with assert for this method public ...
How to write test classes with assert for this method public static void myFirstMethod() { List<String>listOfStrings = new List<String>{'Anjana' ...
Read more >
Asserting reverts when testing Solidity smart contracts with ...
To test this, we will verify that the contract reverts when we don't send any ether or when we send more than the...
Read more >
Basics of Javascript Test Driven Development (TDD) with Jest
The grid of test results below shows how each type of message can be unit tested. Message Type, Query, Command. Incoming, Assert result....
Read more >
How to test Go function containing log.Fatal() - Stack Overflow
How would I go about testing that the correct messages have been logged? As log.Fatal calls os.Exit(1) the tests fail. package main import...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found