In the package that comes the Inco library, an extension to the usual Test
Foundry contract is provided.
You can import it like this:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8;
import {IncoTest} from "@inco/lightning/src/test/IncoTest.sol";
contract YourTest is IncoTest {
function testSomething() public {
// Your test code here
}
}
IncoTest
extends Foundry’s Test
contract, and exposes useful Inco-specific cheatcodes to test your contract.
If you are extending the setUp
function, remember to call super.setUp()
at the beginning of your function.
Example
// SPDX-License-Identifier: MIT
pragma solidity ^0.8;
import {SimpleConfidentialToken} from "../SimpleConfidentialToken.sol";
import {IncoTest} from "@inco/lightning/src/test/IncoTest.sol";
import {GWEI} from "@inco/shared/src/TypeUtils.sol";
contract TestSimpleConfidentialToken is IncoTest {
SimpleConfidentialToken token;
function setUp() public override {
super.setUp();
token = new SimpleConfidentialToken();
token.transfer(alice, fakePrepareEuint256Ciphertext(10 * GWEI));
}
function testTransfer() public {
vm.prank(alice);
token.transfer(bob, fakePrepareEuint256Ciphertext(1 * GWEI));
processAllOperations();
uint256 decryptedBobBalance = getUint256Value(token.balanceOf(bob));
uint256 decryptedAliceBalance = getUint256Value(token.balanceOf(alice));
assertEq(decryptedBobBalance, 1 * GWEI);
assertEq(decryptedAliceBalance, 9 * GWEI);
}
}
Once you are happy with the state of your contract, you can deploy it as-is without any changes and Inco will react to its ops (as long as you are on a supported network, currently only Base-Sepolia).
Read on for the reference of the available cheatcodes.