From bef62b97e7197e1ec37ca1a429aa78a375f60cf7 Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Mon, 27 Jan 2025 14:00:42 +0300 Subject: [PATCH] extract remaining pin attempts --- menutraversal_test/menu_traversal_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/menutraversal_test/menu_traversal_test.go b/menutraversal_test/menu_traversal_test.go index 7d9e4f0..b040606 100644 --- a/menutraversal_test/menu_traversal_test.go +++ b/menutraversal_test/menu_traversal_test.go @@ -67,6 +67,16 @@ func extractMaxAmount(response []byte) string { return "" } +func extractRemainingAttempts(response []byte) string { + // Regex to match "You have: remaining attempt(s)" + re := regexp.MustCompile(`(?m)You have:\s+(\d+)\s+remaining attempt\(s\)`) + match := re.FindSubmatch(response) + if match != nil { + return string(match[1]) // "" of remaining attempts + } + return "" +} + // Extracts the send amount value from the engine response. func extractSendAmount(response []byte) string { // Regex to match the pattern "will receive X.XX SYM from" @@ -365,9 +375,11 @@ func TestGroups(t *testing.T) { } b := w.Bytes() balance := extractBalance(b) + attempts := extractRemainingAttempts(b) expectedContent := []byte(tt.ExpectedContent) expectedContent = bytes.Replace(expectedContent, []byte("{balance}"), []byte(balance), -1) + expectedContent = bytes.Replace(expectedContent, []byte("{attempts}"), []byte(attempts), -1) tt.ExpectedContent = string(expectedContent)