@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/abci/example/kvstore"
"github.com/tendermint/tendermint/abci/example/kvstore"
"github.com/tendermint/tendermint/lite2/provider"
"github.com/tendermint/tendermint/lite2/provider/http"
"github.com/tendermint/tendermint/lite2/provider/http"
litehttp "github.com/tendermint/tendermint/lite2/provider/http"
litehttp "github.com/tendermint/tendermint/lite2/provider/http"
rpcclient "github.com/tendermint/tendermint/rpc/client"
rpcclient "github.com/tendermint/tendermint/rpc/client"
@ -33,6 +34,7 @@ func TestNewProvider(t *testing.T) {
func TestMain ( m * testing . M ) {
func TestMain ( m * testing . M ) {
app := kvstore . NewApplication ( )
app := kvstore . NewApplication ( )
app . RetainBlocks = 5
node := rpctest . StartTendermint ( app )
node := rpctest . StartTendermint ( app )
code := m . Run ( )
code := m . Run ( )
@ -73,8 +75,25 @@ func TestProvider(t *testing.T) {
assert . Nil ( t , sh . ValidateBasic ( chainID ) )
assert . Nil ( t , sh . ValidateBasic ( chainID ) )
// historical queries now work :)
// historical queries now work :)
lower := sh . Height - 5
lower := sh . Height - 3
sh , err = p . SignedHeader ( lower )
sh , err = p . SignedHeader ( lower )
assert . Nil ( t , err , "%+v" , err )
assert . Nil ( t , err , "%+v" , err )
assert . Equal ( t , lower , sh . Height )
assert . Equal ( t , lower , sh . Height )
// fetching missing heights (both future and pruned) should return appropriate errors
_ , err = p . SignedHeader ( 1000 )
require . Error ( t , err )
assert . Equal ( t , provider . ErrSignedHeaderNotFound , err )
_ , err = p . ValidatorSet ( 1000 )
require . Error ( t , err )
assert . Equal ( t , provider . ErrValidatorSetNotFound , err )
_ , err = p . SignedHeader ( 1 )
require . Error ( t , err )
assert . Equal ( t , provider . ErrSignedHeaderNotFound , err )
_ , err = p . ValidatorSet ( 1 )
require . Error ( t , err )
assert . Equal ( t , provider . ErrValidatorSetNotFound , err )
}
}