Improve reconnections + fixing unit tests

This commit is contained in:
Juan Leni
2019-04-03 14:15:50 +02:00
parent 37cc8db430
commit ab033fbc81
7 changed files with 56 additions and 43 deletions
+7 -2
View File
@@ -296,18 +296,23 @@ func NewNode(config *cfg.Config,
}
}
pubKey := privValidator.GetPubKey()
if pubKey == nil {
return nil, fmt.Errorf("could not retrieve pubkey")
}
// Decide whether to fast-sync or not
// We don't fast-sync when the only validator is us.
fastSync := config.FastSync
if state.Validators.Size() == 1 {
addr, _ := state.Validators.GetByIndex(0)
privValAddr := privValidator.GetPubKey().Address()
privValAddr := pubKey.Address()
if bytes.Equal(privValAddr, addr) {
fastSync = false
}
}
pubKey := privValidator.GetPubKey()
addr := pubKey.Address()
// Log whether this node is a validator or an observer
if state.Validators.HasAddress(addr) {
+2 -3
View File
@@ -138,7 +138,7 @@ func TestNodeSetPrivValTCP(t *testing.T) {
types.NewMockPV(),
dialer,
)
privval.SignerServiceEndpointTimeoutReadWrite(100 * time.Millisecond)(pvsc)
privval.SignerDialerEndpointTimeoutReadWrite(100 * time.Millisecond)(pvsc)
go func() {
err := pvsc.Start()
@@ -180,7 +180,7 @@ func TestNodeSetPrivValIPC(t *testing.T) {
types.NewMockPV(),
dialer,
)
privval.SignerServiceEndpointTimeoutReadWrite(100 * time.Millisecond)(pvsc)
privval.SignerDialerEndpointTimeoutReadWrite(100 * time.Millisecond)(pvsc)
go func() {
err := pvsc.Start()
@@ -191,7 +191,6 @@ func TestNodeSetPrivValIPC(t *testing.T) {
n, err := DefaultNewNode(config, log.TestingLogger())
require.NoError(t, err)
assert.IsType(t, &privval.SignerClient{}, n.PrivValidator())
}
// testFreeAddr claims a free port so we don't block on listener being ready.