Fix tests
This commit is contained in:
parent
4f7565ba7b
commit
c039b610f1
|
@ -91,8 +91,8 @@
|
|||
"ptypes/duration",
|
||||
"ptypes/timestamp"
|
||||
]
|
||||
revision = "b4deda0973fb4c70b50d226b1af49f3da59f5265"
|
||||
version = "v1.1.0"
|
||||
revision = "925541529c1fa6821df4e44ce2723319eb2be768"
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -423,6 +423,6 @@
|
|||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "8c5f7f7b1a226e774353514c70f779e97d3311598076f510258b9ddcf87ed1f7"
|
||||
inputs-digest = "c25289282b94abc7f0c390e592e5e1636b7f26cb4773863ac39cde7fdc7b5bdf"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
[[constraint]]
|
||||
name = "github.com/golang/protobuf"
|
||||
version = "~1.1.0"
|
||||
version = "~1.0.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/gorilla/websocket"
|
||||
|
|
|
@ -6,8 +6,8 @@ import (
|
|||
cmn "github.com/tendermint/tmlibs/common"
|
||||
. "github.com/tendermint/tmlibs/test"
|
||||
|
||||
"testing"
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type testItem []byte
|
||||
|
@ -39,16 +39,16 @@ func TestSimpleProof(t *testing.T) {
|
|||
proof := proofs[i]
|
||||
|
||||
// Verify success
|
||||
ok := proof.Verify(i, total, itemHash, rootHash)
|
||||
if !ok {
|
||||
t.Errorf("Verification failed for index %v.", i)
|
||||
err := proof.Verify(rootHash, i, total, itemHash)
|
||||
if err != nil {
|
||||
t.Errorf("Verification failed: %v.", err)
|
||||
}
|
||||
|
||||
// Wrong item index should make it fail
|
||||
{
|
||||
ok = proof.Verify((i+1)%total, total, itemHash, rootHash)
|
||||
if ok {
|
||||
t.Errorf("Expected verification to fail for wrong index %v.", i)
|
||||
err = proof.Verify(rootHash, (i+1)%total, total, itemHash)
|
||||
if err == nil {
|
||||
t.Errorf("Expected verification to fail for wrong index %v", i)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,9 +56,9 @@ func TestSimpleProof(t *testing.T) {
|
|||
origAunts := proof.Aunts
|
||||
proof.Aunts = append(proof.Aunts, cmn.RandBytes(32))
|
||||
{
|
||||
ok = proof.Verify(i, total, itemHash, rootHash)
|
||||
if ok {
|
||||
t.Errorf("Expected verification to fail for wrong trail length.")
|
||||
err = proof.Verify(rootHash, i, total, itemHash)
|
||||
if err == nil {
|
||||
t.Errorf("Expected verification to fail for wrong trail length")
|
||||
}
|
||||
}
|
||||
proof.Aunts = origAunts
|
||||
|
@ -66,22 +66,22 @@ func TestSimpleProof(t *testing.T) {
|
|||
// Trail too short should make it fail
|
||||
proof.Aunts = proof.Aunts[0 : len(proof.Aunts)-1]
|
||||
{
|
||||
ok = proof.Verify(i, total, itemHash, rootHash)
|
||||
if ok {
|
||||
t.Errorf("Expected verification to fail for wrong trail length.")
|
||||
err = proof.Verify(rootHash, i, total, itemHash)
|
||||
if err == nil {
|
||||
t.Errorf("Expected verification to fail for wrong trail length")
|
||||
}
|
||||
}
|
||||
proof.Aunts = origAunts
|
||||
|
||||
// Mutating the itemHash should make it fail.
|
||||
ok = proof.Verify(i, total, MutateByteSlice(itemHash), rootHash)
|
||||
if ok {
|
||||
err = proof.Verify(rootHash, i, total, MutateByteSlice(itemHash))
|
||||
if err == nil {
|
||||
t.Errorf("Expected verification to fail for mutated leaf hash")
|
||||
}
|
||||
|
||||
// Mutating the rootHash should make it fail.
|
||||
ok = proof.Verify(i, total, itemHash, MutateByteSlice(rootHash))
|
||||
if ok {
|
||||
err = proof.Verify(MutateByteSlice(rootHash), i, total, itemHash)
|
||||
if err == nil {
|
||||
t.Errorf("Expected verification to fail for mutated root hash")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue