rpc/client: add constant to ValidUntilBlock

There are 2 problems:
1. `getvalidators` RPC can return empty list.
2. `+1` in single node can be too resrictive.
Proper solution for (1) may require requesting
standby validators. Here we add constant
to fix occasional test failures.
This commit is contained in:
Evgenii Stratonikov 2020-09-04 16:03:31 +03:00
parent 914b12af44
commit e0f406fd3a
2 changed files with 3 additions and 3 deletions

View file

@ -489,7 +489,7 @@ func (c *Client) CalculateValidUntilBlock() (uint32, error) {
expiresAt: blockCount + cacheTimeout, expiresAt: blockCount + cacheTimeout,
} }
} }
return blockCount + validatorsCount, nil return blockCount + validatorsCount + 1, nil
} }
// AddNetworkFee adds network fee for each witness script and optional extra // AddNetworkFee adds network fee for each witness script and optional extra

View file

@ -1321,14 +1321,14 @@ func TestCalculateValidUntilBlock(t *testing.T) {
validUntilBlock, err := c.CalculateValidUntilBlock() validUntilBlock, err := c.CalculateValidUntilBlock()
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, uint32(54), validUntilBlock) assert.Equal(t, uint32(55), validUntilBlock)
assert.Equal(t, 1, getBlockCountCalled) assert.Equal(t, 1, getBlockCountCalled)
assert.Equal(t, 1, getValidatorsCalled) assert.Equal(t, 1, getValidatorsCalled)
// check, whether caching is working // check, whether caching is working
validUntilBlock, err = c.CalculateValidUntilBlock() validUntilBlock, err = c.CalculateValidUntilBlock()
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, uint32(54), validUntilBlock) assert.Equal(t, uint32(55), validUntilBlock)
assert.Equal(t, 2, getBlockCountCalled) assert.Equal(t, 2, getBlockCountCalled)
assert.Equal(t, 1, getValidatorsCalled) assert.Equal(t, 1, getValidatorsCalled)
} }