From b1e4b63c6a3bd25998311aca149e08fa49ab7753 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Wed, 11 Dec 2024 19:28:53 +0300 Subject: [PATCH] Add a space after the colon for vouchers --- common/vouchers.go | 4 ++-- common/vouchers_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/vouchers.go b/common/vouchers.go index 6cff91d..790e3ca 100644 --- a/common/vouchers.go +++ b/common/vouchers.go @@ -24,7 +24,7 @@ func ProcessVouchers(holdings []dataserviceapi.TokenHoldings) VoucherMetadata { var symbols, balances, decimals, addresses []string for i, h := range holdings { - symbols = append(symbols, fmt.Sprintf("%d:%s", i+1, h.TokenSymbol)) + symbols = append(symbols, fmt.Sprintf("%d: %s", i+1, h.TokenSymbol)) // Scale down the balance scaledBalance := ScaleDownBalance(h.Balance, h.TokenDecimals) @@ -103,7 +103,7 @@ func MatchVoucher(input, symbols, balances, decimals, addresses string) (symbol, logg.Tracef("found", "symlist", symList, "syms", symbols, "input", input) for i, sym := range symList { - parts := strings.SplitN(sym, ":", 2) + parts := strings.SplitN(sym, ": ", 2) if input == parts[0] || strings.EqualFold(input, parts[1]) { symbol = parts[1] diff --git a/common/vouchers_test.go b/common/vouchers_test.go index ba6cd60..2ebb4a0 100644 --- a/common/vouchers_test.go +++ b/common/vouchers_test.go @@ -34,7 +34,7 @@ func InitializeTestDb(t *testing.T) (context.Context, *UserDataStore) { } func TestMatchVoucher(t *testing.T) { - symbols := "1:SRF\n2:MILO" + symbols := "1: SRF\n2: MILO" balances := "1:100\n2:200" decimals := "1:6\n2:4" addresses := "1:0xd4c288865Ce\n2:0x41c188d63Qa" @@ -65,7 +65,7 @@ func TestProcessVouchers(t *testing.T) { } expectedResult := VoucherMetadata{ - Symbols: "1:SRF\n2:MILO", + Symbols: "1: SRF\n2: MILO", Balances: "1:100\n2:20000", Decimals: "1:6\n2:4", Addresses: "1:0xd4c288865Ce\n2:0x41c188d63Qa", @@ -90,7 +90,7 @@ func TestGetVoucherData(t *testing.T) { // Test voucher data mockData := map[DataTyp][]byte{ - DATA_VOUCHER_SYMBOLS: []byte("1:SRF\n2:MILO"), + DATA_VOUCHER_SYMBOLS: []byte("1: SRF\n2: MILO"), DATA_VOUCHER_BALANCES: []byte("1:100\n2:200"), DATA_VOUCHER_DECIMALS: []byte("1:6\n2:4"), DATA_VOUCHER_ADDRESSES: []byte("1:0xd4c288865Ce\n2:0x41c188d63Qa"),