From b69df980d133fd0f0b1a41430ec8cb9f1c469b0b Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Fri, 11 Aug 2017 14:10:06 +0200 Subject: [PATCH] Check proofs with latest commit --- client/commands/query/query_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client/commands/query/query_test.go b/client/commands/query/query_test.go index 3fcef7781..a958c1def 100644 --- a/client/commands/query/query_test.go +++ b/client/commands/query/query_test.go @@ -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) }