From f95b11e07ac4dbb43c71518e03f6fad702606e28 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Tue, 9 Jul 2019 17:55:55 +0400 Subject: [PATCH] fix HeightAndHashPresent func --- lite/verifying/provider.go | 2 +- lite/verifying/provider_test.go | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lite/verifying/provider.go b/lite/verifying/provider.go index 7079193a6..3e421c25b 100644 --- a/lite/verifying/provider.go +++ b/lite/verifying/provider.go @@ -47,7 +47,7 @@ type TrustOptions struct { // HeightAndHashPresent returns true if TrustHeight and TrustHash are present. func (opts TrustOptions) HeightAndHashPresent() bool { - return opts.TrustHeight > 0 && opts.TrustHash != 0 + return opts.TrustHeight > 0 && len(opts.TrustHash) > 0 } // Provider implements a persistent caching Provider that auto-validates. It diff --git a/lite/verifying/provider_test.go b/lite/verifying/provider_test.go index dd881ce11..7b910663c 100644 --- a/lite/verifying/provider_test.go +++ b/lite/verifying/provider_test.go @@ -11,6 +11,7 @@ import ( dbm "github.com/tendermint/tendermint/libs/db" log "github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/lite" + pks "github.com/tendermint/tendermint/lite/internal/privkeys" "github.com/tendermint/tendermint/types" ) @@ -21,7 +22,7 @@ func TestProviderValidPath(t *testing.T) { // Set up the validators to generate test blocks. var vote int64 = 10 - keys := lite.GenPrivKeys(5) + keys := pks.GenPrivKeys(5) nkeys := keys.Extend(1) // Construct a bunch of commits, each with one more height than the last. @@ -93,9 +94,9 @@ func TestProviderDynamicVerification(t *testing.T) { // gen the 2 val sets chainID := "dynamic-verifier" power := int64(10) - keys1 := lite.GenPrivKeys(5) + keys1 := pks.GenPrivKeys(5) vals1 := keys1.ToValidators(power, 0) - keys2 := lite.GenPrivKeys(5) + keys2 := pks.GenPrivKeys(5) vals2 := keys2.ToValidators(power, 0) // make some commits with the first @@ -148,7 +149,7 @@ func TestVerifingProviderHistorical(t *testing.T) { // Set up the validators to generate test blocks. var vote int64 = 10 - keys := lite.GenPrivKeys(5) + keys := pks.GenPrivKeys(5) nkeys := keys.Extend(1) // Construct a bunch of commits, each with one more height than the last. @@ -230,7 +231,7 @@ func TestConcurrentProvider(t *testing.T) { // Set up the validators to generate test blocks. var vote int64 = 10 - keys := lite.GenPrivKeys(5) + keys := pks.GenPrivKeys(5) nkeys := keys.Extend(1) // Construct a bunch of commits, each with one more height than the last.