Skip to content

Files

Latest commit

2d5fcdc · May 14, 2025

History

History

patch-testing

Patch Testing

Patch tests are done by creating a bin per test case, which is then used to autogenerate a harness to run as regular tests.

A single package (a member of a workspace) can contain multiple bins, and you can name the bins in the Cargo.toml.

For example, our P256 patch test package has the following Cargo.toml:

    [package]
    name = "p256"
    version.workspace = true
    edition.workspace = true
    publish.workspace = true

    [[bin]]
    name = "p256_low_sig_recovery"
    path = "bin/low_sig_recovery.rs"
    description = "Test a p256 low signature recovery"

    [[bin]]
    name = "p256_high_sig_recovery"
    path = "bin/high_sig_recovery.rs"
    description = "Test a p256 high signature recovery"

    [[bin]]
    name = "p256_low_sig_verify"
    path = "bin/low_sig_verify.rs"
    description = "Test a p256 low signature verification"

    [[bin]]
    name = "p256_high_sig_verify"
    path = "bin/high_sig_verify.rs"
    description = "Test a p256 high signature verification"

    [[bin]]
    name = "p256_recovery_fail"
    path = "bin/recovery_fail.rs"

    [[bin]]
    name = "p256_verify_fail"
    path = "bin/verify_fail.rs"

    [dependencies]
    sp1-zkvm = { workspace = true }
    p256 = { workspace = true }
    hex-literal = { workspace = true }
    ecdsa-core = { workspace = true }

The harness is generated by running the ./gen-tests.sh script in the patch-testing directory. This script will generate a harness for each bin in the package, and place it in the tests directory. You can optionally run all the tests in the same invocation by invoking the script with the following: RUN=1 ./gen-tests.sh.