# assume

Description: assume cheatcode documentation

Note: This document was authored using MDX

  Source: https://github.com/NomicFoundation/hardhat-website/tree/main/src/content/docs/docs/reference/cheatcodes/Fuzzer/assume.mdx

{/* This document contains content copied/adapted from the Foundry Book (MIT licensed). See LICENSE in the parent directory. */}

### Signature

```solidity
function assume(bool) external;
```

### Description

If the boolean expression evaluates to false, the fuzzer will discard the current fuzz inputs and start a new fuzz run.

The `assume` cheatcode should mainly be used for very narrow checks.
Broad checks will slow down tests as it will take a while to find valid values, and the test may fail if you hit the max number of rejects.

You can configure the rejection thresholds by setting `fuzz.maxTestRejects` in your [Solidity tests configuration](https://hardhat.org/docs/reference/configuration#solidity-tests-configuration).

For broad checks, such as ensuring a `uint256` falls within a certain range, you can bound your input with the modulo operator or Forge Standard's [`bound`](https://getfoundry.sh/reference/forge-std/bound) method.

More information on filtering via `assume` can be found [here][filtering-guide].

### Examples

```solidity
// Good example of using assume
function testSomething(uint256 a) public {
  vm.assume(a != 1);
  require(a != 1);
  // [PASS]
}
```

```solidity
// In this case assume is not a great fit, so you should bound inputs manually
function testSomethingElse(uint256 a) public {
  a = bound(a, 100, 1e36);
  require(a >= 100 && a <= 1e36);
  // [PASS]
}
```

### SEE ALSO

Forge Standard Library

[`bound`](https://getfoundry.sh/reference/forge-std/bound)

[filtering-guide]: https://altsysrq.github.io/proptest-book/proptest/tutorial/filtering.html#filtering
