-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: check SR from batch proofs matches the SR from the DS
- Loading branch information
1 parent
d299684
commit 41a0d4d
Showing
9 changed files
with
135 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package prover_test | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"testing" | ||
|
||
"github.com/0xPolygon/cdk/aggregator/prover" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
const ( | ||
dir = "../../test/vectors/proofs" | ||
) | ||
|
||
type TestStateRoot struct { | ||
Publics []string `mapstructure:"publics"` | ||
} | ||
|
||
func TestCalculateStateRoots(t *testing.T) { | ||
var expectedStateRoots = map[string]string{ | ||
"1871.json": "0x0ed594d8bc0bb38f3190ff25fb1e5b4fe1baf0e2e0c1d7bf3307f07a55d3a60f", | ||
"1872.json": "0xb6aac97ebb0eb2d4a3bdd40cfe49b6a22d42fe7deff1a8fae182a9c11cc8a7b1", | ||
"1873.json": "0x6f88be87a2ad2928a655bbd38c6f1b59ca8c0f53fd8e9e9d5806e90783df701f", | ||
"1874.json": "0x6f88be87a2ad2928a655bbd38c6f1b59ca8c0f53fd8e9e9d5806e90783df701f", | ||
"1875.json": "0xf4a439c5642a182d9e27c8ab82c64b44418ba5fa04c175a013bed452c19908c9"} | ||
|
||
// Read all files in the directory | ||
files, err := os.ReadDir(dir) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
for _, file := range files { | ||
if file.IsDir() { | ||
continue | ||
} | ||
|
||
// Read the file | ||
data, err := os.ReadFile(fmt.Sprintf("%s/%s", dir, file.Name())) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Get the state root from the batch proof | ||
fileStateRoot, err := prover.GetStateRootFromProof(string(data)) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Get the expected state root | ||
expectedStateRoot, ok := expectedStateRoots[file.Name()] | ||
if !ok { | ||
log.Fatal("Expected state root not found") | ||
} | ||
|
||
// Compare the state roots | ||
require.Equal(t, expectedStateRoot, fileStateRoot.String(), "State roots do not match") | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.