From a10f89b13d5b6f90adf5e8bf6764f1cbf134b858 Mon Sep 17 00:00:00 2001 From: "Richard T. Carback III" <rick.carback@gmail.com> Date: Fri, 9 Sep 2022 21:24:54 +0000 Subject: [PATCH] Fix issue where auth and wait timeouts were confused --- cmd/root.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 574bc8f24..33ae2745e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -166,7 +166,7 @@ var rootCmd = &cobra.Command{ time.Sleep(10 * time.Second) // Accept auth request for this recipient - waitSecs := viper.GetUint(authTimeoutFlag) + authSecs := viper.GetUint(authTimeoutFlag) authConfirmed := false jww.INFO.Printf("Preexisting E2e partners: %+v", user.GetE2E().GetAllPartnerIDs()) if user.GetE2E().HasAuthenticatedChannel(recipientID) { @@ -189,7 +189,7 @@ var rootCmd = &cobra.Command{ "unexpected request:"+ " %s", reqID) } - case <-time.After(time.Duration(waitSecs) * + case <-time.After(time.Duration(authSecs) * time.Second): fmt.Print("timed out on auth request") reqDone = true @@ -245,15 +245,15 @@ var rootCmd = &cobra.Command{ scnt := uint(0) // Wait until authConfirmed - for !authConfirmed && scnt < waitSecs { + for !authConfirmed && scnt < authSecs { time.Sleep(1 * time.Second) scnt++ } - if scnt == waitSecs { + if scnt == authSecs { jww.FATAL.Panicf("Could not confirm "+ "authentication channel for %s, "+ "waited %d seconds.", recipientID, - waitSecs) + authSecs) } jww.INFO.Printf("Authentication channel confirmation"+ " took %d seconds", scnt) @@ -359,6 +359,7 @@ var rootCmd = &cobra.Command{ // TODO: Actually check for how many messages we've received expectedCnt := viper.GetUint(receiveCountFlag) receiveCnt := uint(0) + waitSecs := viper.GetUint(waitTimeoutFlag) waitTimeout := time.Duration(waitSecs) * time.Second done := false -- GitLab