Add timeout parameter to node-canary

This commit is contained in:
Pedro Pombeiro 2018-10-27 17:39:06 +02:00 committed by Pedro Pombeiro
parent 87f1af0743
commit 5d0ed0303e
1 changed files with 5 additions and 2 deletions

View File

@ -38,6 +38,7 @@ var (
staticEnodeAddr = flag.String("staticnode", "", "static node enode address to test (e.g. enode://3f04db09bedc8d85a198de94c84da73aa7782fafc61b28c525ec5cca5a6cc16be7ebbb5cd001780f71d8408d35a2f6326faa1e524d9d8875294172ebec988743@172.16.238.10:30303)")
mailserverEnodeAddr = flag.String("mailserver", "", "mailserver enode address to test (e.g. enode://1da276e34126e93babf24ec88aac1a7602b4cbb2e11b0961d0ab5e989ca9c261aa7f7c1c85f15550a5f1e5a5ca2305b53b9280cf5894d5ecf7d257b173136d40@167.99.209.61:30504)")
publicChannel = flag.String("channel", "status", "The public channel name to retrieve historic messages from (used with 'mailserver' flag)")
timeout = flag.Int("timeout", 10, "Timeout when connecting to node or fetching messages from mailserver, in seconds")
period = flag.Int("period", 24*60*60, "How far in the past to request messages from mailserver, in seconds")
minPow = flag.Float64("shh.pow", params.WhisperMinimumPoW, "PoW for messages to be added to queue, in float format")
ttl = flag.Int("shh.ttl", params.WhisperTTL, "Time to live for messages, in seconds")
@ -116,7 +117,8 @@ func verifyMailserverBehavior(mailserverNode *discv5.Node) {
}
// add mailserver peer to client
clientErrCh := helpers.WaitForPeerAsync(clientNode.Server(), *mailserverEnodeAddr, p2p.PeerEventTypeAdd, 5*time.Second)
clientErrCh := helpers.WaitForPeerAsync(clientNode.Server(), *mailserverEnodeAddr, p2p.PeerEventTypeAdd, time.Duration(*timeout)*time.Second)
err = clientNode.AddPeer(*mailserverEnodeAddr)
if err != nil {
logger.Error("Failed to add mailserver peer to client", "error", err)
@ -172,6 +174,7 @@ func verifyMailserverBehavior(mailserverNode *discv5.Node) {
Limit: 1,
Topic: topic,
SymKeyID: mailServerKeyID,
Timeout: time.Duration(*timeout) * time.Second,
})
if err != nil {
logger.Error("Error requesting historic messages from mailserver", "error", err)
@ -180,7 +183,7 @@ func verifyMailserverBehavior(mailserverNode *discv5.Node) {
requestID := common.BytesToHash(requestIDBytes)
// wait for mailserver response
resp, err := waitForMailServerResponse(mailServerResponseWatcher, requestID, 10*time.Second)
resp, err := waitForMailServerResponse(mailServerResponseWatcher, requestID, time.Duration(*timeout)*time.Second)
if err != nil {
logger.Error("Error waiting for mailserver response", "error", err)
os.Exit(3)