You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.4 KiB

lint: Enable Golint (#4212) * Fix many golint errors * Fix golint errors in the 'lite' package * Don't export Pool.store * Fix typo * Revert unwanted changes * Fix errors in counter package * Fix linter errors in kvstore package * Fix linter error in example package * Fix error in tests package * Fix linter errors in v2 package * Fix linter errors in consensus package * Fix linter errors in evidence package * Fix linter error in fail package * Fix linter errors in query package * Fix linter errors in core package * Fix linter errors in node package * Fix linter errors in mempool package * Fix linter error in conn package * Fix linter errors in pex package * Rename PEXReactor export to Reactor * Fix linter errors in trust package * Fix linter errors in upnp package * Fix linter errors in p2p package * Fix linter errors in proxy package * Fix linter errors in mock_test package * Fix linter error in client_test package * Fix linter errors in coretypes package * Fix linter errors in coregrpc package * Fix linter errors in rpcserver package * Fix linter errors in rpctypes package * Fix linter errors in rpctest package * Fix linter error in json2wal script * Fix linter error in wal2json script * Fix linter errors in kv package * Fix linter error in state package * Fix linter error in grpc_client * Fix linter errors in types package * Fix linter error in version package * Fix remaining errors * Address review comments * Fix broken tests * Reconcile package coregrpc * Fix golangci bot error * Fix new golint errors * Fix broken reference * Enable golint linter * minor changes to bring golint into line * fix failing test * fix pex reactor naming * address PR comments
5 years ago
  1. package client
  2. import (
  3. "os"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. "github.com/stretchr/testify/require"
  7. "github.com/tendermint/tendermint/abci/example/kvstore"
  8. rpcclient "github.com/tendermint/tendermint/rpc/client"
  9. rpctest "github.com/tendermint/tendermint/rpc/test"
  10. "github.com/tendermint/tendermint/types"
  11. )
  12. func TestMain(m *testing.M) {
  13. app := kvstore.NewApplication()
  14. node := rpctest.StartTendermint(app)
  15. code := m.Run()
  16. rpctest.StopTendermint(node)
  17. os.Exit(code)
  18. }
  19. func TestProvider(t *testing.T) {
  20. assert, require := assert.New(t), require.New(t)
  21. cfg := rpctest.GetConfig()
  22. defer os.RemoveAll(cfg.RootDir)
  23. rpcAddr := cfg.RPC.ListenAddress
  24. genDoc, err := types.GenesisDocFromFile(cfg.GenesisFile())
  25. if err != nil {
  26. panic(err)
  27. }
  28. chainID := genDoc.ChainID
  29. t.Log("chainID:", chainID)
  30. p := NewHTTPProvider(chainID, rpcAddr)
  31. require.NotNil(t, p)
  32. // let it produce some blocks
  33. err = rpcclient.WaitForHeight(p.(*provider).client, 6, nil)
  34. require.Nil(err)
  35. // let's get the highest block
  36. fc, err := p.LatestFullCommit(chainID, 1, 1<<63-1)
  37. require.Nil(err, "%+v", err)
  38. sh := fc.Height()
  39. assert.True(sh < 5000)
  40. // let's check this is valid somehow
  41. assert.Nil(fc.ValidateFull(chainID))
  42. // historical queries now work :)
  43. lower := sh - 5
  44. fc, err = p.LatestFullCommit(chainID, lower, lower)
  45. assert.Nil(err, "%+v", err)
  46. assert.Equal(lower, fc.Height())
  47. }