diff --git a/menu_traversal_test.go b/menu_traversal_test.go index 9c1e839..7513436 100644 --- a/menu_traversal_test.go +++ b/menu_traversal_test.go @@ -137,3 +137,34 @@ func TestAccountRegistrationInvalidPin(t *testing.T) { } } } + +func TestSendWithInvalidRecipient(t *testing.T) { + en, fn := enginetest.TestEngine("session1234112") + defer fn() + ctx := context.Background() + sessions := testData + for _, session := range sessions { + groups := driver.FilterGroupsByName(session.Groups, "send_with_invalid_recipient") + for _, group := range groups { + for _, step := range group.Steps { + cont, err := en.Exec(ctx, []byte(step.Input)) + if err != nil { + t.Fatalf("Test case '%s' failed at input '%s': %v", group.Name, step.Input, err) + return + } + if !cont { + break + } + w := bytes.NewBuffer(nil) + if _, err := en.Flush(ctx, w); err != nil { + t.Fatalf("Test case '%s' failed during Flush: %v", group.Name, err) + } + + b := w.Bytes() + if !bytes.Equal(b, []byte(step.ExpectedContent)) { + t.Fatalf("expected:\n\t%s\ngot:\n\t%s\n", step.ExpectedContent, b) + } + } + } + } +} diff --git a/test_data.json b/test_data.json index 789f064..60a7a97 100644 --- a/test_data.json +++ b/test_data.json @@ -95,6 +95,39 @@ } ] + }, + { + "name": "send_with_invalid_recipient", + "steps": [ + { + "input": "", + "expectedContent": "Balance: 0.003 CELO\n\n1:Send\n2:My Vouchers\n3:My Account\n4:Help\n9:Quit" + }, + { + "input": "1", + "expectedContent": "Enter recipient's phone number:\n0:Back" + }, + { + "input": "000", + "expectedContent": "000 is not registered or invalid, please try again:\n1:retry\n9:Quit" + }, + { + "input": "1", + "expectedContent": "Enter recipient's phone number:\n0:Back" + }, + { + "input": "065656", + "expectedContent": "Maximum amount: 0.003 CELO\nEnter amount:\n0:Back" + }, + { + "input": "0.001", + "expectedContent": "065656 will receive 0.001 from 0xd6CF3C87b0D4aD5978448bBbD6Db9EC6D74D624b\nPlease enter your PIN to confirm:\n0:Back\n9:Quit" + }, + { + "input": "1234", + "expectedContent": "Your request has been sent. 065656 will receive 0.001 from 0xd6CF3C87b0D4aD5978448bBbD6Db9EC6D74D624b." + } + ] } ] }