forked from yetanotherco/aligned_layer
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmina_test.go
More file actions
71 lines (58 loc) · 1.78 KB
/
mina_test.go
File metadata and controls
71 lines (58 loc) · 1.78 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package mina_test
import (
"os"
"testing"
"github.com/yetanotherco/aligned_layer/operator/mina"
)
const ProofFilePath = "../../scripts/test_files/mina/devnet_mina_state.proof"
const PubInputFilePath = "../../scripts/test_files/mina/devnet_mina_state.pub"
func TestMinaStateProofVerifies(t *testing.T) {
proofBytes, err := os.ReadFile(ProofFilePath)
if err != nil {
t.Errorf("could not open mina state proof file")
}
pubInputBytes, err := os.ReadFile(PubInputFilePath)
if err != nil {
t.Errorf("could not open mina state pub input file")
}
verified, err := mina.VerifyMinaState(proofBytes, pubInputBytes)
if err != nil || !verified {
t.Errorf("proof did not verify")
}
}
func TestEmptyMinaStateProofDoesNotVerify(t *testing.T) {
proofBytes, err := os.ReadFile(ProofFilePath)
if err != nil {
t.Errorf("could not open mina state proof file")
}
emptyProofBuffer := make([]byte, len(proofBytes))
pubInputBytes, err := os.ReadFile(PubInputFilePath)
if err != nil {
t.Errorf("could not open mina state pub input file")
}
verified, err := mina.VerifyMinaState(emptyProofBuffer, pubInputBytes)
if err != nil {
t.Errorf("verification failed with error")
}
if verified {
t.Errorf("proof should not verify")
}
}
func TestMinaStateProofWithEmptyPubInputDoesNotVerify(t *testing.T) {
proofBytes, err := os.ReadFile(ProofFilePath)
if err != nil {
t.Errorf("could not open mina state proof file")
}
pubInputBytes, err := os.ReadFile(PubInputFilePath)
if err != nil {
t.Errorf("could not open mina state pub input file")
}
emptyPubInputBuffer := make([]byte, len(pubInputBytes))
verified, err := mina.VerifyMinaState(proofBytes, emptyPubInputBuffer)
if err != nil {
t.Errorf("verification failed with error")
}
if verified {
t.Errorf("proof should not verify")
}
}