-
Notifications
You must be signed in to change notification settings - Fork 45
/
Starter.t.sol
38 lines (28 loc) · 1.1 KB
/
Starter.t.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
pragma solidity ^0.8.17;
import "../contract/Starter.sol";
import "../circuits/target/contract.sol";
import "forge-std/console.sol";
import "forge-std/Test.sol";
import {NoirHelper} from "foundry-noir-helper/NoirHelper.sol";
contract StarterTest is Test {
Starter public starter;
UltraVerifier public verifier;
NoirHelper public noirHelper;
function setUp() public {
noirHelper = new NoirHelper();
verifier = new UltraVerifier();
starter = new Starter(verifier);
}
function test_verifyProof() public {
noirHelper.withInput("x", 1).withInput("y", 1).withInput("return", 1);
(bytes32[] memory publicInputs, bytes memory proof) = noirHelper.generateProofAndClean(2);
starter.verifyEqual(proof, publicInputs);
}
function test_wrongProof() public {
noirHelper.clean();
noirHelper.withInput("x", 1).withInput("y", 5).withInput("return", 5);
(bytes32[] memory publicInputs, bytes memory proof) = noirHelper.generateProofAndClean(2);
vm.expectRevert();
starter.verifyEqual(proof, publicInputs);
}
}