Skip to content

bug: invariant test log/traces not shown #2962

@mds1

Description

@mds1

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (56dc746 2022-08-26T00:07:43.474069Z)

What command(s) is the bug in?

forge test

Operating System

No response

Describe the bug

Using the test contract, I am unable to view any of the console.logs for successful tests. Like fuzz tests, we should the trace of the last successful run if all runs pass.

contract NonceCounter {
  uint256 public nonce = 1;

  function increment() public {
    nonce++;
  }
}

contract Test3 is Test {
  NonceCounter nonceCounter;
  uint256 lastNonce;

  function setUp() public {
    nonceCounter = new NonceCounter();
  }

  function invariant_NonceGoUp() external {
    console2.log('lastNonce: ', lastNonce);

    uint256 currentNonce = nonceCounter.nonce();
    console2.log('currentNonce: ', nonceCounter.nonce());

    require(currentNonce > lastNonce, "Invariant violated: Nonce did not increase");
    lastNonce = currentNonce;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions