Differential Test
Last updated
Was this helpful?
Last updated
Was this helpful?
Differential fuzzing is an extension of differential testing. Differential fuzzing programatically generates many values of
x
to find discrepancies and edge cases that manually chosen inputs might not reveal.
We are testing the correctness of Exp.sol against an implementation exp.py that we trust:
We need the eth_abi
package:
Writing the differential test:
The test contains two functions. In ffi_exp()
, we are collecting the output of exp.py via FFI:
cross references multiple implementations of the same function by comparing each one's output. Imagine we have a function specification F(X)
, and two implementations of that specification: f1(X)
and f2(X)
. We expect f1(x) == f2(x)
for all x that exist in an appropriate input space. If f1(x) != f2(x)
, we know that at least one function is incorrectly implementing F(X)
. This process of testing for equality and identifying discrepancies is the core of differential testing.