Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed May 30, 2024
1 parent b4f964e commit e76921f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ To generate fixtures for local testing run:

```shell
$ cd operator
$ RUST_LOG=info TENDERMINT_RPC_URL="https://rpc.celestia-mocha.com/" cargo run --release --bin fixture -- --trusted-block 500 --target-block 1000
$ RUST_LOG=info TENDERMINT_RPC_URL="https://rpc.celestia-mocha.com/" cargo run --bin fixture --release -- --trusted-block 500 --target-block 1000
```

You can check that the generated fixture proofs verify by running the forge tests:
Expand Down
15 changes: 15 additions & 0 deletions contracts/test/SP1Tendermint.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ contract SP1TendermintTest is Test {
assert(tendermint.latestHeight() == fixture.targetHeight);
}

// Confirm that submitting an empty proof fails.
function testFail_InvalidTendermint() public {
SP1TendermintFixtureJson memory fixture = loadFixture("fixture.json");

Expand All @@ -92,6 +93,7 @@ contract SP1TendermintTest is Test {
tendermint.verifyTendermintProof(fakeProof, fixture.publicValues);
}

// Confirm that submitting an empty proof with the mock verifier passes.
function test_ValidMockTendermint() public {
SP1TendermintFixtureJson memory fixture = loadFixture(
"mock_fixture.json"
Expand All @@ -102,4 +104,17 @@ contract SP1TendermintTest is Test {
assert(mockTendermint.latestHeader() == fixture.targetHeaderHash);
assert(mockTendermint.latestHeight() == fixture.targetHeight);
}

// Confirm that submitting a non-empty proof with the mock verifier fails. This indicates that
// the user has passed in the wrong proof.
function testFail_Invalid_MockTendermint() public {
SP1TendermintFixtureJson memory fixture = loadFixture(
"mock_fixture.json"
);

mockTendermint.verifyTendermintProof(bytes("aa"), fixture.publicValues);

assert(mockTendermint.latestHeader() == fixture.targetHeaderHash);
assert(mockTendermint.latestHeight() == fixture.targetHeight);
}
}
4 changes: 2 additions & 2 deletions operator/bin/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ async fn main() -> anyhow::Result<()> {
// Save the proof data to the file path.
let fixture_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(args.fixture_path);

// TODO: Change to prover.prover_type
// TODO: Change to prover.id
let sp1_prover_type = env::var("SP1_PROVER");
if sp1_prover_type.is_ok() && sp1_prover_type.unwrap() == "mock" {
if sp1_prover_type.as_deref() == Ok("mock") {
std::fs::write(
fixture_path.join("mock_fixture.json"),
serde_json::to_string_pretty(&fixture).unwrap(),
Expand Down

0 comments on commit e76921f

Please sign in to comment.