From 1bf8b75c57254bdd3d89d5c953f9e178cb511188 Mon Sep 17 00:00:00 2001 From: sanaz Date: Thu, 29 Jun 2023 11:32:36 -0700 Subject: [PATCH] revises the test docs and resolves linter bugs --- proof_test.go | 59 ++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/proof_test.go b/proof_test.go index f58be07..df8f195 100644 --- a/proof_test.go +++ b/proof_test.go @@ -709,39 +709,40 @@ func TestIsEmptyProofOverlapAbsenceProof(t *testing.T) { } } -func Test_ShortAbsenceProof(t *testing.T) { +// TestVerifyNamespace_ShortAbsenceProof_Valid checks whether VerifyNamespace can correctly verify short namespace absence proofs +func TestVerifyNamespace_ShortAbsenceProof_Valid(t *testing.T) { // create a Merkle tree with 8 leaves tree := exampleNMT(1, true, 1, 2, 3, 4, 6, 7, 8, 9) qNS := []byte{5} // does not belong to the tree root, err := tree.Root() assert.NoError(t, err) - // N_0_8 Tree Root - // / \ - // / \ - // N_0_4 N_4_8 Non-Leaf Nodes - // / \ / \ - // / \ / \ - // N_0_2 N_2_4 N_4_6 N_6_8 Non-Leaf Nodes - // / \ / \ / \ / \ - // N_0_1 N_1_2 N_2_3 N_3_4 N_4_5 N_5_6 N_6_7 N_7_8 Leaf Hashes - // 1 2 3 4 6 7 8 9 Leaf namespaces - // 0 1 2 3 4 5 6 7 Leaf indexes + // Node_0_8 Tree Root + // / \ + // / \ + // Node_0_4 Node_4_8 Non-Leaf Node + // / \ / \ + // / \ / \ + // Node_0_2 Node_2_4 Node_4_6 Node_6_8 Non-Leaf Node + // / \ / \ / \ / \ + // Node_0_1 Node_1_2 Node_2_3 Node_3_4 Node_4_5 Node_5_6 Node_6_7 Node_7_8 Leaf Hash + // 1 2 3 4 6 7 8 9 Leaf namespace + // 0 1 2 3 4 5 6 7 Leaf index // nodes needed for the full absence proof of qNS - N_4_5 := tree.leafHashes[4] - N_5_6 := tree.leafHashes[5] - N_6_8, err := tree.computeRoot(6, 8) + Node_4_5 := tree.leafHashes[4] + Node_5_6 := tree.leafHashes[5] + Node_6_8, err := tree.computeRoot(6, 8) assert.NoError(t, err) - N_0_4, err := tree.computeRoot(0, 4) + Node_0_4, err := tree.computeRoot(0, 4) assert.NoError(t, err) - // nodes needed for the short absence proof of qNS; the proof of inclusion of the parent of N_4_5 - N_4_6, err := tree.computeRoot(4, 6) + // nodes needed for the short absence proof of qNS; the proof of inclusion of the parent of Node_4_5 + Node_4_6, err := tree.computeRoot(4, 6) assert.NoError(t, err) - // nodes needed for another short absence parent of qNS; the proof of inclusion of the grandparent of N_4_5 - N_4_8, err := tree.computeRoot(4, 8) + // nodes needed for another short absence parent of qNS; the proof of inclusion of the grandparent of Node_4_5 + Node_4_8, err := tree.computeRoot(4, 8) assert.NoError(t, err) tests := []struct { @@ -755,25 +756,25 @@ func Test_ShortAbsenceProof(t *testing.T) { { name: "valid full absence proof", qNID: qNS, - leafHash: N_4_5, - nodes: [][]byte{N_0_4, N_5_6, N_6_8}, - start: 4, // N_4_5 is at index position 4 (from left to right) at its respective level + leafHash: Node_4_5, + nodes: [][]byte{Node_0_4, Node_5_6, Node_6_8}, + start: 4, // Node_4_5 is at index position 4 (from left to right) at its respective level end: 5, }, { name: "valid short absence proof: one level higher", qNID: qNS, - leafHash: N_4_6, - nodes: [][]byte{N_0_4, N_6_8}, - start: 2, // N_4_6 is at index position 2 (from left to right) at its respective level + leafHash: Node_4_6, + nodes: [][]byte{Node_0_4, Node_6_8}, + start: 2, // Node_4_6 is at index position 2 (from left to right) at its respective level end: 3, }, { name: "valid short absence proof: two levels higher", qNID: qNS, - leafHash: N_4_8, - nodes: [][]byte{N_0_4}, - start: 1, // N_4_8 is at index position 1 (from left to right) at its respective level + leafHash: Node_4_8, + nodes: [][]byte{Node_0_4}, + start: 1, // Node_4_8 is at index position 1 (from left to right) at its respective level end: 2, }, }