|
1 | 1 | package merkle_tree |
2 | | - |
3 | | -import ( |
4 | | - "encoding/hex" |
5 | | - "fmt" |
6 | | - "os" |
7 | | - "testing" |
8 | | -) |
9 | | - |
10 | | -const BatchFilePath = "lib/test_files/merkle_tree_batch.bin" |
11 | | - |
12 | | -const RootFilePath = "lib/test_files/merkle_root.bin" |
13 | | - |
14 | | -func TestVerifyMerkleTreeBatch(t *testing.T) { |
15 | | - batchByteValue, err := os.ReadFile(BatchFilePath) |
16 | | - if err != nil { |
17 | | - t.Fatalf("Error reading batch file: %v", err) |
18 | | - } |
19 | | - |
20 | | - rootByteValue, err := os.ReadFile(RootFilePath) |
21 | | - if err != nil { |
22 | | - t.Fatalf("Error reading batch file: %v", err) |
23 | | - } |
24 | | - |
25 | | - merkle_root := make([]byte, hex.DecodedLen(len(rootByteValue))) |
26 | | - _, err = hex.Decode(merkle_root, rootByteValue) |
27 | | - if err != nil { |
28 | | - fmt.Println("Error decoding hex string:", err) |
29 | | - return |
30 | | - } |
31 | | - |
32 | | - var merkleRoot [32]byte |
33 | | - copy(merkleRoot[:], merkle_root) |
34 | | - |
35 | | - verified, err := VerifyMerkleTreeBatch(batchByteValue, merkleRoot) |
36 | | - if err != nil || !verified { |
37 | | - t.Errorf("Batch did not verify Merkle Root") |
38 | | - } |
39 | | - |
40 | | -} |
| 2 | +// |
| 3 | +// import ( |
| 4 | +// "encoding/hex" |
| 5 | +// "fmt" |
| 6 | +// "os" |
| 7 | +// "testing" |
| 8 | +// ) |
| 9 | +// |
| 10 | +// const BatchFilePath = "lib/test_files/merkle_tree_batch.bin" |
| 11 | +// |
| 12 | +// const RootFilePath = "lib/test_files/merkle_root.bin" |
| 13 | + |
| 14 | +// func TestVerifyMerkleTreeBatch(t *testing.T) { |
| 15 | +// batchByteValue, err := os.ReadFile(BatchFilePath) |
| 16 | +// if err != nil { |
| 17 | +// t.Fatalf("Error reading batch file: %v", err) |
| 18 | +// } |
| 19 | +// |
| 20 | +// rootByteValue, err := os.ReadFile(RootFilePath) |
| 21 | +// if err != nil { |
| 22 | +// t.Fatalf("Error reading batch file: %v", err) |
| 23 | +// } |
| 24 | +// |
| 25 | +// merkle_root := make([]byte, hex.DecodedLen(len(rootByteValue))) |
| 26 | +// _, err = hex.Decode(merkle_root, rootByteValue) |
| 27 | +// if err != nil { |
| 28 | +// fmt.Println("Error decoding hex string:", err) |
| 29 | +// return |
| 30 | +// } |
| 31 | +// |
| 32 | +// var merkleRoot [32]byte |
| 33 | +// copy(merkleRoot[:], merkle_root) |
| 34 | +// |
| 35 | +// verified, err := VerifyMerkleTreeBatch(batchByteValue, merkleRoot) |
| 36 | +// if err != nil || !verified { |
| 37 | +// t.Errorf("Batch did not verify Merkle Root") |
| 38 | +// } |
| 39 | +// |
| 40 | +// } |
0 commit comments