General Merkle Proof (#2298)

* first commit

finalize rebase

add protoc_merkle to Makefile

* in progress

* fix kvstore

* fix tests

* remove iavl dependency

* fix tx_test

* fix test_abci_cli

fix test_apps

* fix test_apps

* fix test_cover

* rm rebase residue

* address comment in progress

* finalize rebase
This commit is contained in:
Joon
2018-09-29 09:03:19 +09:00
committed by Ethan Buchman
parent fc073746a0
commit 71a34adfe5
38 changed files with 1867 additions and 749 deletions

View File

@ -166,10 +166,10 @@ func TestAppCalls(t *testing.T) {
if err := client.WaitForHeight(c, apph, nil); err != nil {
t.Error(err)
}
_qres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Trusted: true})
_qres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Prove: false})
qres := _qres.Response
if assert.Nil(err) && assert.True(qres.IsOK()) {
// assert.Equal(k, data.GetKey()) // only returned for proofs
assert.Equal(k, qres.Key)
assert.EqualValues(v, qres.Value)
}
@ -221,10 +221,12 @@ func TestAppCalls(t *testing.T) {
assert.Equal(block.Block.LastCommit, commit2.Commit)
// and we got a proof that works!
_pres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Trusted: false})
_pres, err := c.ABCIQueryWithOptions("/key", k, client.ABCIQueryOptions{Prove: true})
pres := _pres.Response
assert.Nil(err)
assert.True(pres.IsOK())
// XXX Test proof
}
}
@ -310,7 +312,7 @@ func TestTx(t *testing.T) {
// time to verify the proof
proof := ptx.Proof
if tc.prove && assert.EqualValues(t, tx, proof.Data) {
assert.True(t, proof.Proof.Verify(proof.Index, proof.Total, txHash, proof.RootHash))
assert.NoError(t, proof.Proof.Verify(proof.RootHash, txHash))
}
}
}
@ -348,7 +350,7 @@ func TestTxSearch(t *testing.T) {
// time to verify the proof
proof := ptx.Proof
if assert.EqualValues(t, tx, proof.Data) {
assert.True(t, proof.Proof.Verify(proof.Index, proof.Total, txHash, proof.RootHash))
assert.NoError(t, proof.Proof.Verify(proof.RootHash, txHash))
}
// query by height
@ -362,7 +364,7 @@ func TestTxSearch(t *testing.T) {
require.Len(t, result.Txs, 0)
// we query using a tag (see kvstore application)
result, err = c.TxSearch("app.creator='jae'", false, 1, 30)
result, err = c.TxSearch("app.creator='Cosmoshi Netowoko'", false, 1, 30)
require.Nil(t, err, "%+v", err)
if len(result.Txs) == 0 {
t.Fatal("expected a lot of transactions")