Minor updates for context clarity

This commit is contained in:
coderofstuff 2023-09-22 19:41:50 -06:00
parent 0bd5a9aa4f
commit b724d7cc9a
2 changed files with 5 additions and 5 deletions

View File

@ -22,7 +22,7 @@ func FormatKas(amount uint64) string {
// KasToSompi takes in a string representation of the Kas value to convert to Sompi
func KasToSompi(amount string) (uint64, error) {
err := validateAmountFormat(amount)
err := validateKASAmountFormat(amount)
if err != nil {
return 0, err
@ -52,12 +52,12 @@ func KasToSompi(amount string) (uint64, error) {
return convertedAmount, err
}
func validateAmountFormat(amount string) error {
func validateKASAmountFormat(amount string) error {
// Check whether it's an integer, or a float with max 8 digits
match, err := regexp.MatchString("^([1-9]\\d{0,11}|0)(\\.\\d{0,8})?$", amount)
if !match {
return errors.Errorf("Invalid send amount")
return errors.Errorf("Invalid amount")
}
if err != nil {

View File

@ -57,7 +57,7 @@ func TestValidateAmountFormat(t *testing.T) {
}
for _, testCase := range validCases {
err := validateAmountFormat(testCase)
err := validateKASAmountFormat(testCase)
if err != nil {
t.Error(err)
@ -81,7 +81,7 @@ func TestValidateAmountFormat(t *testing.T) {
}
for _, testCase := range invalidCases {
err := validateAmountFormat(testCase)
err := validateKASAmountFormat(testCase)
if err == nil {
t.Errorf("Expected an error but succeeded validation for test case %s", testCase)