mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-24 06:25:55 +00:00
Minor updates for context clarity
This commit is contained in:
parent
0bd5a9aa4f
commit
b724d7cc9a
@ -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 {
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user