fix rpc and txindex

This commit is contained in:
Marko Baricevic
2021-03-19 13:20:17 +00:00
parent da23d6f06f
commit c888fc2dcc
5 changed files with 10 additions and 8 deletions

View File

@@ -117,6 +117,7 @@ func TestBroadcastEvidence_DuplicateVoteEvidence(t *testing.T) {
config = rpctest.GetConfig()
chainID = config.ChainID()
)
pv, err := privval.LoadOrGenFilePV(config.PrivValidatorKeyFile(), config.PrivValidatorStateFile())
require.NoError(t, err)

View File

@@ -10,11 +10,11 @@ import (
)
// Waiter is informed of current height, decided whether to quit early
type Waiter func(delta uint64) (abort error)
type Waiter func(delta int64) (abort error)
// DefaultWaitStrategy is the standard backoff algorithm,
// but you can plug in another one
func DefaultWaitStrategy(delta uint64) (abort error) {
func DefaultWaitStrategy(delta int64) (abort error) {
if delta > 10 {
return fmt.Errorf("waiting for %d blocks... aborting", delta)
} else if delta > 0 {
@@ -36,13 +36,13 @@ func WaitForHeight(c StatusClient, h uint64, waiter Waiter) error {
if waiter == nil {
waiter = DefaultWaitStrategy
}
delta := uint64(1)
delta := int64(1)
for delta > 0 {
s, err := c.Status(context.Background())
if err != nil {
return err
}
delta = h - s.SyncInfo.LatestBlockHeight
delta = int64(h) - int64(s.SyncInfo.LatestBlockHeight)
// wait for the time, or abort early
if err := waiter(delta); err != nil {
return err

View File

@@ -51,7 +51,7 @@ func TestWaitForHeight(t *testing.T) {
// since we can't update in a background goroutine (test --race)
// we use the callback to update the status height
myWaiter := func(delta uint64) error {
myWaiter := func(delta int64) error {
// update the height for the next call
m.Call.Response = &ctypes.ResultStatus{SyncInfo: ctypes.SyncInfo{LatestBlockHeight: 15}}
return client.DefaultWaitStrategy(delta)
@@ -67,11 +67,11 @@ func TestWaitForHeight(t *testing.T) {
require.Nil(pre.Error)
prer, ok := pre.Response.(*ctypes.ResultStatus)
require.True(ok)
assert.Equal(int64(10), prer.SyncInfo.LatestBlockHeight)
assert.Equal(uint64(10), prer.SyncInfo.LatestBlockHeight)
post := r.Calls[4]
require.Nil(post.Error)
postr, ok := post.Response.(*ctypes.ResultStatus)
require.True(ok)
assert.Equal(int64(15), postr.SyncInfo.LatestBlockHeight)
assert.Equal(uint64(15), postr.SyncInfo.LatestBlockHeight)
}

View File

@@ -526,6 +526,7 @@ func TestTxSearch(t *testing.T) {
txCount := len(result.Txs)
// pick out the last tx to have something to search for in tests
fmt.Println(len(result.Txs))
find := result.Txs[len(result.Txs)-1]
anotherTxHash := types.Tx("a different tx").Hash()

View File

@@ -649,7 +649,7 @@ func secondaryKey(compositeKey, value string, height uint64, index uint32) []byt
nil,
compositeKey,
value,
height,
int64(height),
int64(index),
)
if err != nil {