Skip to content

Commit

Permalink
smt store test nits
Browse files Browse the repository at this point in the history
  • Loading branch information
roysc committed Apr 20, 2022
1 parent bb15cd3 commit e103a63
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions store/v2alpha1/smt/ics23_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

ics23 "github.com/confio/ics23/go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/db/memdb"
store "github.com/cosmos/cosmos-sdk/store/v2alpha1/smt"
Expand Down Expand Up @@ -33,26 +34,26 @@ func TestProofICS23(t *testing.T) {
nonexist := proof.GetNonexist()
assert.Nil(t, nonexist)
exist := proof.GetExist()
assert.NotNil(t, exist)
require.NotNil(t, exist)
assert.Equal(t, 0, len(exist.Path))
assert.NoError(t, exist.Verify(ics23.SmtSpec, s.Root(), path01[:], val1))

// Non-membership
proof, err = s.GetProofICS23(key00) // When leaf is leftmost node
assert.NoError(t, err)
nonexist = proof.GetNonexist()
assert.NotNil(t, nonexist)
require.NotNil(t, nonexist)
assert.Nil(t, nonexist.Left)
assert.Equal(t, path00[:], nonexist.Key)
assert.NotNil(t, nonexist.Right)
require.NotNil(t, nonexist.Right)
assert.Equal(t, 0, len(nonexist.Right.Path))
assert.NoError(t, nonexist.Verify(ics23.SmtSpec, s.Root(), path00[:]))

proof, err = s.GetProofICS23(key10) // When rightmost
assert.NoError(t, err)
nonexist = proof.GetNonexist()
assert.NotNil(t, nonexist)
assert.NotNil(t, nonexist.Left)
require.NotNil(t, nonexist)
require.NotNil(t, nonexist.Left)
assert.Equal(t, 0, len(nonexist.Left.Path))
assert.Nil(t, nonexist.Right)
assert.NoError(t, nonexist.Verify(ics23.SmtSpec, s.Root(), path10[:]))
Expand All @@ -63,11 +64,11 @@ func TestProofICS23(t *testing.T) {
proof, err = s.GetProofICS23(key10) // In between two keys
assert.NoError(t, err)
nonexist = proof.GetNonexist()
assert.NotNil(t, nonexist)
require.NotNil(t, nonexist)
assert.Equal(t, path10[:], nonexist.Key)
assert.NotNil(t, nonexist.Left)
require.NotNil(t, nonexist.Left)
assert.Equal(t, 1, len(nonexist.Left.Path))
assert.NotNil(t, nonexist.Right)
require.NotNil(t, nonexist.Right)
assert.Equal(t, 1, len(nonexist.Right.Path))
assert.NoError(t, nonexist.Verify(ics23.SmtSpec, s.Root(), path10[:]))

Expand All @@ -78,9 +79,9 @@ func TestProofICS23(t *testing.T) {
assert.NoError(t, err)
nonexist = proof.GetNonexist()
assert.Equal(t, path10[:], nonexist.Key)
assert.NotNil(t, nonexist.Left)
require.NotNil(t, nonexist.Left)
assert.Equal(t, 1, len(nonexist.Left.Path))
assert.NotNil(t, nonexist.Right)
require.NotNil(t, nonexist.Right)
assert.Equal(t, 1, len(nonexist.Right.Path))
assert.NoError(t, nonexist.Verify(ics23.SmtSpec, s.Root(), path10[:]))

Expand Down

0 comments on commit e103a63

Please sign in to comment.