Compare commits
No commits in common. "db5d55d8e310552bd006560e04eb720ad23f04a3" and "e379129b3d30f804d2dc895501cc8a2e4ae5eae4" have entirely different histories.
db5d55d8e3
...
e379129b3d
@ -199,16 +199,10 @@ func (h *MenuHandlers) SetLanguage(ctx context.Context, sym string, input []byte
|
||||
// handles the account creation when no existing account is present for the session and stores associated data in the user data store.
|
||||
func (h *MenuHandlers) createAccountNoExist(ctx context.Context, sessionId string, res *resource.Result) error {
|
||||
flag_account_created, _ := h.flagManager.GetFlag("flag_account_created")
|
||||
flag_account_creation_failed, _ := h.flagManager.GetFlag("flag_account_creation_failed")
|
||||
|
||||
r, err := h.accountService.CreateAccount(ctx)
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, flag_account_creation_failed)
|
||||
logg.ErrorCtxf(ctx, "failed to create an account", "error", err)
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
res.FlagReset = append(res.FlagReset, flag_account_creation_failed)
|
||||
|
||||
trackingId := r.TrackingId
|
||||
publicKey := r.PublicKey
|
||||
|
||||
@ -436,14 +430,6 @@ func (h *MenuHandlers) ResetInvalidPIN(ctx context.Context, sym string, input []
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// ResetApiCallFailure resets the api call failure flag
|
||||
func (h *MenuHandlers) ResetApiCallFailure(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
var res resource.Result
|
||||
flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// ConfirmPinChange validates user's new PIN. If input matches the temporary PIN, saves it as the new account PIN.
|
||||
func (h *MenuHandlers) ConfirmPinChange(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
var res resource.Result
|
||||
@ -1454,7 +1440,7 @@ func (h *MenuHandlers) CheckAccountStatus(ctx context.Context, sym string, input
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, flag_api_error)
|
||||
logg.ErrorCtxf(ctx, "failed on TrackAccountStatus", "error", err)
|
||||
return res, nil
|
||||
return res, err
|
||||
}
|
||||
|
||||
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||
@ -1620,7 +1606,6 @@ func (h *MenuHandlers) ValidateRecipient(ctx context.Context, sym string, input
|
||||
}
|
||||
flag_invalid_recipient, _ := h.flagManager.GetFlag("flag_invalid_recipient")
|
||||
flag_invalid_recipient_with_invite, _ := h.flagManager.GetFlag("flag_invalid_recipient_with_invite")
|
||||
flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||
|
||||
recipient := string(input)
|
||||
|
||||
@ -1694,13 +1679,10 @@ func (h *MenuHandlers) ValidateRecipient(ctx context.Context, sym string, input
|
||||
logg.InfoCtxf(ctx, "Resolving with fqdn alias", "alias", fqdn)
|
||||
AliasAddress, err = h.accountService.CheckAliasAddress(ctx, fqdn)
|
||||
if err == nil {
|
||||
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||
AliasAddressResult = AliasAddress.Address
|
||||
continue
|
||||
} else {
|
||||
res.FlagSet = append(res.FlagSet, flag_api_error)
|
||||
logg.ErrorCtxf(ctx, "failed to resolve alias", "alias", recipient, "error_alias_check", err)
|
||||
return res, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2022,7 +2004,6 @@ func (h *MenuHandlers) ManageVouchers(ctx context.Context, sym string, input []b
|
||||
}
|
||||
|
||||
flag_no_active_voucher, _ := h.flagManager.GetFlag("flag_no_active_voucher")
|
||||
flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||
|
||||
publicKey, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY)
|
||||
if err != nil {
|
||||
@ -2033,10 +2014,9 @@ func (h *MenuHandlers) ManageVouchers(ctx context.Context, sym string, input []b
|
||||
// Fetch vouchers from API
|
||||
vouchersResp, err := h.accountService.FetchVouchers(ctx, string(publicKey))
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, flag_api_error)
|
||||
res.FlagSet = append(res.FlagSet, flag_no_active_voucher)
|
||||
return res, nil
|
||||
}
|
||||
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||
|
||||
if len(vouchersResp) == 0 {
|
||||
res.FlagSet = append(res.FlagSet, flag_no_active_voucher)
|
||||
@ -2251,7 +2231,6 @@ func (h *MenuHandlers) GetVoucherDetails(ctx context.Context, sym string, input
|
||||
res.FlagSet = append(res.FlagSet, flag_api_error)
|
||||
return res, nil
|
||||
}
|
||||
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||
|
||||
res.Content = fmt.Sprintf(
|
||||
"Name: %s\nSymbol: %s\nCommodity: %s\nLocation: %s", voucherData.TokenName, voucherData.TokenSymbol, voucherData.TokenCommodity, voucherData.TokenLocation,
|
||||
@ -2286,7 +2265,6 @@ func (h *MenuHandlers) CheckTransactions(ctx context.Context, sym string, input
|
||||
logg.ErrorCtxf(ctx, "failed on FetchTransactions", "error", err)
|
||||
return res, err
|
||||
}
|
||||
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||
|
||||
// Return if there are no transactions
|
||||
if len(transactionsResp) == 0 {
|
||||
@ -2528,8 +2506,6 @@ func (h *MenuHandlers) RequestCustomAlias(ctx context.Context, sym string, input
|
||||
return res, nil
|
||||
}
|
||||
|
||||
flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||
|
||||
store := h.userdataStore
|
||||
aliasHint, err := store.ReadEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE)
|
||||
if err != nil {
|
||||
@ -2553,12 +2529,9 @@ func (h *MenuHandlers) RequestCustomAlias(ctx context.Context, sym string, input
|
||||
sanitizedInput := sanitizeAliasHint(string(input))
|
||||
aliasResult, err := h.accountService.RequestAlias(ctx, string(pubKey), sanitizedInput)
|
||||
if err != nil {
|
||||
res.FlagSet = append(res.FlagSet, flag_api_error)
|
||||
logg.ErrorCtxf(ctx, "failed to retrieve alias", "alias", string(aliasHint), "error_alias_request", err)
|
||||
return res, nil
|
||||
return res, fmt.Errorf("Failed to retrieve alias: %s", err.Error())
|
||||
}
|
||||
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||
|
||||
alias := aliasResult.Alias
|
||||
logg.InfoCtxf(ctx, "Suggested alias ", "alias", alias)
|
||||
|
||||
|
@ -226,8 +226,6 @@ func TestCreateAccount(t *testing.T) {
|
||||
}
|
||||
|
||||
flag_account_created, err := fm.GetFlag("flag_account_created")
|
||||
flag_account_creation_failed, _ := fm.GetFlag("flag_account_creation_failed")
|
||||
|
||||
if err != nil {
|
||||
t.Logf(err.Error())
|
||||
}
|
||||
@ -244,8 +242,7 @@ func TestCreateAccount(t *testing.T) {
|
||||
PublicKey: "0xD3adB33f",
|
||||
},
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{flag_account_created},
|
||||
FlagReset: []uint32{flag_account_creation_failed},
|
||||
FlagSet: []uint32{flag_account_created},
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -623,15 +620,9 @@ func TestSaveGender(t *testing.T) {
|
||||
|
||||
func TestSaveTemporaryPin(t *testing.T) {
|
||||
sessionId := "session123"
|
||||
|
||||
ctx, userdatastore := InitializeTestStore(t)
|
||||
ctx, store := InitializeTestStore(t)
|
||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||
|
||||
_, logdb := InitializeTestLogdbStore(t)
|
||||
logDb := store.LogDb{
|
||||
Db: logdb,
|
||||
}
|
||||
|
||||
fm, err := NewFlagManager(flagsPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@ -642,8 +633,7 @@ func TestSaveTemporaryPin(t *testing.T) {
|
||||
// Create the MenuHandlers instance with the mock flag manager
|
||||
h := &MenuHandlers{
|
||||
flagManager: fm,
|
||||
userdataStore: userdatastore,
|
||||
logDb: logDb,
|
||||
userdataStore: store,
|
||||
}
|
||||
|
||||
// Define test cases
|
||||
@ -684,15 +674,9 @@ func TestSaveTemporaryPin(t *testing.T) {
|
||||
|
||||
func TestCheckIdentifier(t *testing.T) {
|
||||
sessionId := "session123"
|
||||
ctx, userdatastore := InitializeTestStore(t)
|
||||
ctx, store := InitializeTestStore(t)
|
||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||
|
||||
_, logdb := InitializeTestLogdbStore(t)
|
||||
|
||||
logDb := store.LogDb{
|
||||
Db: logdb,
|
||||
}
|
||||
|
||||
// Define test cases
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -712,15 +696,14 @@ func TestCheckIdentifier(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := userdatastore.WriteEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY, []byte(tt.publicKey))
|
||||
err := store.WriteEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY, []byte(tt.publicKey))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Create the MenuHandlers instance with the mock store
|
||||
h := &MenuHandlers{
|
||||
userdataStore: userdatastore,
|
||||
logDb: logDb,
|
||||
userdataStore: store,
|
||||
}
|
||||
|
||||
// Call the method
|
||||
@ -2042,11 +2025,6 @@ func TestManageVouchers(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
flag_no_active_voucher, err := fm.GetFlag("flag_no_active_voucher")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
flag_api_error, err := fm.GetFlag("flag_api_call_error")
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -2070,8 +2048,7 @@ func TestManageVouchers(t *testing.T) {
|
||||
expectedVoucherSymbols: []byte(""),
|
||||
expectedUpdatedAddress: []byte(""),
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{flag_no_active_voucher},
|
||||
FlagReset: []uint32{flag_api_error},
|
||||
FlagSet: []uint32{flag_no_active_voucher},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2087,7 +2064,7 @@ func TestManageVouchers(t *testing.T) {
|
||||
expectedVoucherSymbols: []byte("1:TOKEN1"),
|
||||
expectedUpdatedAddress: []byte("0x123"),
|
||||
expectedResult: resource.Result{
|
||||
FlagReset: []uint32{flag_api_error, flag_no_active_voucher},
|
||||
FlagReset: []uint32{flag_no_active_voucher},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -2100,7 +2077,7 @@ func TestManageVouchers(t *testing.T) {
|
||||
expectedVoucherSymbols: []byte("1:SRF\n2:MILO"),
|
||||
expectedUpdatedAddress: []byte("0xd4c288865Ce"),
|
||||
expectedResult: resource.Result{
|
||||
FlagReset: []uint32{flag_api_error, flag_no_active_voucher},
|
||||
FlagReset: []uint32{flag_no_active_voucher},
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -2252,8 +2229,6 @@ func TestGetVoucherDetails(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Logf(err.Error())
|
||||
}
|
||||
|
||||
flag_api_error, _ := fm.GetFlag("flag_api_call_error")
|
||||
mockAccountService := new(mocks.MockAccountService)
|
||||
|
||||
sessionId := "session123"
|
||||
@ -2281,8 +2256,8 @@ func TestGetVoucherDetails(t *testing.T) {
|
||||
"Name: %s\nSymbol: %s\nCommodity: %s\nLocation: %s", tokenDetails.TokenName, tokenDetails.TokenSymbol, tokenDetails.TokenCommodity, tokenDetails.TokenLocation,
|
||||
)
|
||||
mockAccountService.On("VoucherData", string(tokA_AAddress)).Return(tokenDetails, nil)
|
||||
|
||||
res, err := h.GetVoucherDetails(ctx, "SessionId", []byte(""))
|
||||
expectedResult.FlagReset = append(expectedResult.FlagReset, flag_api_error)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, expectedResult, res)
|
||||
}
|
||||
|
@ -129,7 +129,6 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
|
||||
ls.DbRs.AddLocalFunc("get_suggested_alias", appHandlers.GetSuggestedAlias)
|
||||
ls.DbRs.AddLocalFunc("confirm_new_alias", appHandlers.ConfirmNewAlias)
|
||||
ls.DbRs.AddLocalFunc("check_account_created", appHandlers.CheckAccountCreated)
|
||||
ls.DbRs.AddLocalFunc("reset_api_call_failure", appHandlers.ResetApiCallFailure)
|
||||
|
||||
ls.first = appHandlers.Init
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Failed to connect to the custodial service .Please try again.
|
||||
Failed to connect to the custodial service.Please try again.
|
@ -1,7 +1,5 @@
|
||||
LOAD reset_api_call_failure 6
|
||||
RELOAD reset_api_call_failure
|
||||
MOUT retry 1
|
||||
MOUT quit 9
|
||||
HALT
|
||||
INCMP ^ 1
|
||||
INCMP _ 1
|
||||
INCMP quit 9
|
||||
|
@ -1 +0,0 @@
|
||||
Imeshindwa kuunganisha kwenye huduma ya uangalizi. Tafadhali jaribu tena.
|
@ -1,6 +1,5 @@
|
||||
LOAD check_transactions 0
|
||||
RELOAD check_transactions
|
||||
CATCH api_failure flag_api_call_error 1
|
||||
CATCH no_transfers flag_no_transfers 1
|
||||
LOAD authorize_account 6
|
||||
MOUT back 0
|
||||
|
@ -2,7 +2,6 @@ LOAD clear_temporary_value 2
|
||||
RELOAD clear_temporary_value
|
||||
LOAD manage_vouchers 160
|
||||
RELOAD manage_vouchers
|
||||
CATCH api_failure flag_api_call_error 1
|
||||
LOAD check_balance 128
|
||||
RELOAD check_balance
|
||||
CATCH api_failure flag_api_call_error 1
|
||||
|
@ -5,5 +5,4 @@ HALT
|
||||
INCMP _ 0
|
||||
LOAD request_custom_alias 0
|
||||
RELOAD request_custom_alias
|
||||
CATCH api_failure flag_api_call_error 1
|
||||
INCMP confirm_new_alias *
|
||||
|
@ -5,7 +5,6 @@ MOUT back 0
|
||||
HALT
|
||||
LOAD validate_recipient 50
|
||||
RELOAD validate_recipient
|
||||
CATCH api_failure flag_api_call_error 1
|
||||
CATCH invalid_recipient flag_invalid_recipient 1
|
||||
CATCH invite_recipient flag_invalid_recipient_with_invite 1
|
||||
INCMP _ 0
|
||||
|
@ -1,7 +1,5 @@
|
||||
CATCH no_voucher flag_no_active_voucher 1
|
||||
LOAD get_voucher_details 0
|
||||
RELOAD get_voucher_details
|
||||
CATCH api_failure flag_api_call_error 1
|
||||
MAP get_voucher_details
|
||||
MOUT back 0
|
||||
HALT
|
||||
|
Loading…
Reference in New Issue
Block a user