> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inco.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Cheatcodes reference

> Fully simulate the Inco environment all from solidity tests

## Execute the operations

Inco's infrastructure is monitoring the operations requested over encrypted variables by the smart contracts.\
Inco executes them asynchronously after the blocks containing the ops are mined. Under the hood, the Inco singleton instance on each
supported chain is emitting events to request the operations (that includes encrypts, trivial encrypts, all logical and mathematical operations,
and decryption requests). The solidity-based mock is using Foundry's `vm.recordLogs()` function to record the pending ops.
<Warning> As the events recording are consumed whenever read, there would be conflicts if you try to use `recordLogs` in your tests.</Warning>
To simulate Inco processing the operations, which assigns to its internal value store its encrypted value to each handle, use the following cheatcode:

```Solidity theme={null}
processAllOperations();
```

This cheatcode must be called before reading the value of any encrypted variable, and performing assert statements.
`processAllOperations` also executes any pending decryption callback.

## Simulate Inputs

Encrypted inputs are normally generated using Inco's JS SDK. Simulate them with the following cheatcodes:

### For euint256

```Solidity theme={null}
fakePrepareEuint256Ciphertext(uint256 value) returns (bytes memory ciphertext);

// example usage
token.transfer(bob, fakePrepareEuint256Ciphertext(1 ether));
```

### For ebool

```Solidity theme={null}
fakePrepareEboolCiphertext(bool value) returns (bytes memory ciphertext);

// example usage
someContract.setActive(fakePrepareEboolCiphertext(true));
```

### For eaddress

```Solidity theme={null}
fakePrepareEaddressCiphertext(address value) returns (bytes memory ciphertext);

// example usage
token.setOwner(fakePrepareEaddressCiphertext(alice));
```

## Simulate decryption

Allowed accounts can request reading the values of e-variables using JS SDK. In the tests, you can read any value bypassing the access control checks.

### For euint256

```Solidity theme={null}
getUint256Value(euint256 input) (uint256);

// example usage
assertEq(getUint256Value(token.balanceOf(alice)), 9 * GWEI);
```

### For ebool

```Solidity theme={null}
getBoolValue(ebool input) (bool);

// example usage
assertEq(getBoolValue(someContract.isActive()), true);
```

### For eaddress

```Solidity theme={null}
getAddressValue(eaddress input) (address);

// example usage
assertEq(getAddressValue(token.owner()), alice);
```

To fully test how one of your user could see its encrypted data, we recommend combining an assertion over the decrypted value with an access control check.

```Solidity theme={null}
// example, we check that alice can read her balance
assertTrue(token.balanceOf(alice).isAllowed(alice));
```
