Skip to content

Commit

Permalink
add test to ensure that extension statuses for missing stems are fact…
Browse files Browse the repository at this point in the history
…ored

See crate-crypto/rust-verkle#50 for context
  • Loading branch information
gballet committed Jul 1, 2022
1 parent c815f6f commit 21d10bc
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func TestProofOfAbsenceEdgeCase(t *testing.T) {
}
}

func TestProofOfAbsenceOtherMultiple(t *testing.T) {
func TestProofOfAbsenceOtherMultipleLeaves(t *testing.T) {
// Create a stem that isn't the one that will be proven,
// but does look the same for most of its length.
root := New()
Expand All @@ -435,3 +435,26 @@ func TestProofOfAbsenceOtherMultiple(t *testing.T) {
t.Fatalf("invalid number of proof-of-absence stems: %d", len(proof.PoaStems))
}
}

func TestProofOfAbsenceNoneMultipleStems(t *testing.T) {
root := New()
key, _ := hex.DecodeString("0403030303030303030303030303030303030303030303030303030303030000")
root.Insert(key, testValue, nil)
root.ComputeCommitment()

ret1, _ := hex.DecodeString("0303030303030303030303030303030303030303030303030303030303030300")
ret2, _ := hex.DecodeString("0303030303030303030303030303030303030303030303030303030303030200")
proof, cs, zis, yis := MakeVerkleMultiProof(root, [][]byte{ret1, ret2}, map[string][]byte{string(ret1): nil, string(ret2): nil})
cfg, _ := GetConfig()
if !VerifyVerkleProof(proof, cs, zis, yis, cfg) {
t.Fatal("could not verify proof")
}

if len(proof.PoaStems) != 0 {
t.Fatalf("invalid number of proof-of-absence stems: %d", len(proof.PoaStems))
}

if len(proof.ExtStatus) != 1 {
t.Fatalf("invalid number of none extension statuses: %d ≠ 1", len(proof.ExtStatus))
}
}

0 comments on commit 21d10bc

Please sign in to comment.