Check proofs with latest commit

This commit is contained in:
Alexis Sellier 2017-08-11 14:10:06 +02:00
parent 6a642e33b8
commit b69df980d1
1 changed files with 8 additions and 4 deletions

View File

@ -61,18 +61,22 @@ func TestAppProofs(t *testing.T) {
require.Nil(err, "%+v", err)
cert := certifiers.NewStatic("my-chain", seed.Validators)
latest, err := source.GetLatestCommit()
require.Nil(err, "%+v", err)
rootHash := latest.Header.AppHash
// Test existing key.
var data eyes.Data
bs, height, proofExists, _, err := getWithProof(k, cl, cert)
require.Nil(err, "%+v", err)
require.NotNil(proofExists)
require.True(uint64(br.Height) < height)
require.True(height >= uint64(latest.Header.Height))
err = wire.ReadBinaryBytes(bs, &data)
require.Nil(err, "%+v", err)
assert.EqualValues(v, data.Value)
err = proofExists.Verify(k, bs, proofExists.RootHash)
err = proofExists.Verify(k, bs, rootHash)
assert.Nil(err, "%+v", err)
// Test non-existing key.
@ -82,9 +86,9 @@ func TestAppProofs(t *testing.T) {
require.Nil(bs)
require.Nil(proofExists)
require.NotNil(proofNotExists)
err = proofNotExists.Verify(missing, proofNotExists.RootHash)
err = proofNotExists.Verify(missing, rootHash)
assert.Nil(err, "%+v", err)
err = proofNotExists.Verify(k, proofNotExists.RootHash)
err = proofNotExists.Verify(k, rootHash)
assert.NotNil(err)
}