Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: modify verifying interface for integrating lfb #313

Merged
merged 3 commits into from
Sep 6, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: test case
  • Loading branch information
egonspace committed Sep 6, 2021
commit 2f2c692b397fa9ef68f1751a688db85baac5c297
34 changes: 26 additions & 8 deletions light/verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/line/ostracon/crypto/tmhash"
"github.com/line/ostracon/crypto/vrf"

"github.com/stretchr/testify/assert"

Expand Down Expand Up @@ -180,14 +181,18 @@ func TestVerifyAdjacentHeaders(t *testing.T) {
for i, tc := range testCases {
tc := tc
t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) {
err := light.VerifyAdjacent(
proofHash, err := vrf.ProofToHash(header.Proof.Bytes())
if err != nil {
assert.NoError(t, err)
}
voters := types.SelectVoter(tc.newVals, proofHash, types.DefaultVoterParams())
err = light.VerifyAdjacent(
header,
tc.newHeader,
tc.newVals,
voters,
tc.trustingPeriod,
tc.now,
maxClockDrift,
types.DefaultVoterParams(),
)
switch {
case tc.expErr != nil && assert.Error(t, err):
Expand Down Expand Up @@ -362,8 +367,12 @@ func TestVerifyAdjacentHeadersWithVoterSampling(t *testing.T) {
for i, tc := range testCases {
tc := tc
t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) {
err := light.VerifyAdjacent(header, tc.newHeader, tc.newVals, tc.trustingPeriod, tc.now,
maxClockDrift, voterParamsHalf)
proofHash, err := vrf.ProofToHash(tc.newHeader.Proof.Bytes())
if err != nil {
assert.NoError(t, err)
}
voters := types.SelectVoter(tc.newVals, proofHash, voterParamsHalf)
err = light.VerifyAdjacent(header, tc.newHeader, voters, tc.trustingPeriod, tc.now, maxClockDrift)
switch {
case tc.expErr != nil && assert.Error(t, err):
assert.Equal(t, tc.expErr, err)
Expand Down Expand Up @@ -492,9 +501,18 @@ func TestVerifyNonAdjacentHeaders(t *testing.T) {
for i, tc := range testCases {
tc := tc
t.Run(fmt.Sprintf("#%d", i), func(t *testing.T) {
err := light.VerifyNonAdjacent(header, vals, tc.newHeader, tc.newVals, tc.trustingPeriod,
tc.now, maxClockDrift,
light.DefaultTrustLevel, types.DefaultVoterParams())
proofHash, err := vrf.ProofToHash(header.Proof.Bytes())
if err != nil {
assert.NoError(t, err)
}
trustedVoters := types.SelectVoter(vals, proofHash, types.DefaultVoterParams())
proofHash, err = vrf.ProofToHash(tc.newHeader.Proof.Bytes())
if err != nil {
assert.NoError(t, err)
}
voters := types.SelectVoter(tc.newVals, proofHash, types.DefaultVoterParams())
err = light.VerifyNonAdjacent(header, trustedVoters, tc.newHeader, voters, tc.trustingPeriod, tc.now,
maxClockDrift, light.DefaultTrustLevel)

switch {
case tc.expErr != nil && assert.Error(t, err):
Expand Down