Compare commits
3 Commits
4889e6d18b
...
0be570ae2d
Author | SHA1 | Date | |
---|---|---|---|
0be570ae2d | |||
6a36bc43b5 | |||
1d27a88908 |
@ -829,6 +829,7 @@ func (h *Handlers) ValidateAmount(ctx context.Context, sym string, input []byte)
|
||||
}
|
||||
|
||||
flag_invalid_amount, _ := h.flagManager.GetFlag("flag_invalid_amount")
|
||||
flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||
|
||||
store := h.userdataStore
|
||||
publicKey, _ := store.ReadEntry(ctx, sessionId, utils.DATA_PUBLIC_KEY)
|
||||
@ -838,10 +839,15 @@ func (h *Handlers) ValidateAmount(ctx context.Context, sym string, input []byte)
|
||||
balanceRes, err := h.accountService.CheckBalance(string(publicKey))
|
||||
balanceStr := balanceRes.Result.Balance
|
||||
|
||||
if !balanceRes.Ok {
|
||||
res.FlagSet = append(res.FlagSet, flag_api_error)
|
||||
return res, nil
|
||||
}
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.Content = balanceStr
|
||||
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||
|
||||
// Parse the balance
|
||||
balanceParts := strings.Split(balanceStr, " ")
|
||||
|
@ -1468,6 +1468,7 @@ func TestValidateAmount(t *testing.T) {
|
||||
t.Logf(err.Error())
|
||||
}
|
||||
flag_invalid_amount, _ := fm.parser.GetFlag("flag_invalid_amount")
|
||||
flag_api_error, _ := fm.GetFlag("flag_api_call_error")
|
||||
mockDataStore := new(mocks.MockUserDataStore)
|
||||
mockCreateAccountService := new(mocks.MockAccountService)
|
||||
|
||||
@ -1502,7 +1503,8 @@ func TestValidateAmount(t *testing.T) {
|
||||
},
|
||||
publicKey: []byte("0xrqeqrequuq"),
|
||||
expectedResult: resource.Result{
|
||||
Content: "0.001",
|
||||
Content: "0.001",
|
||||
FlagReset: []uint32{flag_api_error},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1520,8 +1522,9 @@ func TestValidateAmount(t *testing.T) {
|
||||
},
|
||||
publicKey: []byte("0xrqeqrequuq"),
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{flag_invalid_amount},
|
||||
Content: "0.02",
|
||||
FlagSet: []uint32{flag_invalid_amount},
|
||||
FlagReset: []uint32{flag_api_error},
|
||||
Content: "0.02",
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -1539,8 +1542,9 @@ func TestValidateAmount(t *testing.T) {
|
||||
},
|
||||
publicKey: []byte("0xrqeqrequuq"),
|
||||
expectedResult: resource.Result{
|
||||
FlagSet: []uint32{flag_invalid_amount},
|
||||
Content: "0.02ms",
|
||||
FlagSet: []uint32{flag_invalid_amount},
|
||||
FlagReset: []uint32{flag_api_error},
|
||||
Content: "0.02ms",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ MOUT back 0
|
||||
HALT
|
||||
LOAD validate_amount 64
|
||||
RELOAD validate_amount
|
||||
CATCH api_failure flag_api_call_error 1
|
||||
CATCH invalid_amount flag_invalid_amount 1
|
||||
INCMP _ 0
|
||||
LOAD get_recipient 12
|
||||
|
Loading…
Reference in New Issue
Block a user