Skip to content

Commit

Permalink
[FAB-5523] Configuration timeouts are ignored
Browse files Browse the repository at this point in the history
Change-Id: Iea8240107312a9bd5b9446154a15ac1be61dde2c
Signed-off-by: Divyank Katira <Divyank.Katira@securekey.com>
  • Loading branch information
d1vyank committed Jul 28, 2017
1 parent f405d0f commit 77507d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pkg/config/config.go
Expand Up @@ -141,13 +141,13 @@ func (c *Config) TimeoutOrDefault(conn apiconfig.ConnectionType) time.Duration {
var timeout time.Duration
switch conn {
case apiconfig.Endorser:
timeout = myViper.GetDuration("connection.timeout.peer.endorser")
timeout = myViper.GetDuration("client.connection.timeout.peer.endorser")
case apiconfig.EventHub:
timeout = myViper.GetDuration("connection.timeout.peer.eventhub")
timeout = myViper.GetDuration("client.connection.timeout.peer.eventhub")
case apiconfig.EventReg:
timeout = myViper.GetDuration("connection.timeout.peer.eventreg")
timeout = myViper.GetDuration("client.connection.timeout.peer.eventreg")
case apiconfig.Orderer:
timeout = myViper.GetDuration("connection.timeout.orderer")
timeout = myViper.GetDuration("client.connection.timeout.orderer")
}
if timeout == 0 {
timeout = defaultTimeout
Expand Down
10 changes: 5 additions & 5 deletions pkg/config/config_test.go
Expand Up @@ -210,10 +210,10 @@ func TestTLSACAConfig(t *testing.T) {
}

func TestTimeouts(t *testing.T) {
myViper.Set("connection.timeout.peer.endorser", "2s")
myViper.Set("connection.timeout.peer.eventhub", "2m")
myViper.Set("connection.timeout.peer.eventreg", "2h")
myViper.Set("connection.timeout.orderer", "2ms")
myViper.Set("client.connection.timeout.peer.endorser", "2s")
myViper.Set("client.connection.timeout.peer.eventhub", "2m")
myViper.Set("client.connection.timeout.peer.eventreg", "2h")
myViper.Set("client.connection.timeout.orderer", "2ms")

t1 := configImpl.TimeoutOrDefault(api.Endorser)
if t1 != time.Second*2 {
Expand All @@ -232,7 +232,7 @@ func TestTimeouts(t *testing.T) {
t.Fatalf("Timeout not read correctly. Got: %s", t4)
}
// Test default
myViper.Set("connection.timeout.orderer", "")
myViper.Set("client.connection.timeout.orderer", "")
t5 := configImpl.TimeoutOrDefault(api.Orderer)
if t5 != time.Second*5 {
t.Fatalf("Timeout not read correctly. Got: %s", t5)
Expand Down

0 comments on commit 77507d9

Please sign in to comment.