use the TokenAddress instead of ContractAddress
This commit is contained in:
parent
5479580230
commit
383ef51134
4
go.mod
4
go.mod
@ -5,13 +5,13 @@ go 1.23.4
|
|||||||
require (
|
require (
|
||||||
git.defalsify.org/vise.git v0.3.2-0.20250528124150-03bf7bfc1b66
|
git.defalsify.org/vise.git v0.3.2-0.20250528124150-03bf7bfc1b66
|
||||||
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e
|
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623063234-c1797e7a32b5
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623070026-d945964b0b46
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250408094335-e2d1f65bb306
|
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250408094335-e2d1f65bb306
|
||||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250129070628-5a539172c694
|
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250129070628-5a539172c694
|
||||||
github.com/alecthomas/assert/v2 v2.2.2
|
github.com/alecthomas/assert/v2 v2.2.2
|
||||||
github.com/gofrs/uuid v4.4.0+incompatible
|
github.com/gofrs/uuid v4.4.0+incompatible
|
||||||
github.com/grassrootseconomics/ethutils v1.3.1
|
github.com/grassrootseconomics/ethutils v1.3.1
|
||||||
github.com/grassrootseconomics/ussd-data-service v1.5.0-beta
|
github.com/grassrootseconomics/ussd-data-service v1.6.0-beta
|
||||||
github.com/jackc/pgx/v5 v5.7.1
|
github.com/jackc/pgx/v5 v5.7.1
|
||||||
github.com/peteole/testdata-loader v0.3.0
|
github.com/peteole/testdata-loader v0.3.0
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
|
4
go.sum
4
go.sum
@ -4,6 +4,8 @@ git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953
|
|||||||
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
git.grassecon.net/grassrootseconomics/common v0.9.0-beta.1.0.20250417111317-2953f4c2f32e/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623063234-c1797e7a32b5 h1:VnRe01kHkZUBK/QjE7iV6gElSqSwQnAkWV3yCHtuYrI=
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623063234-c1797e7a32b5 h1:VnRe01kHkZUBK/QjE7iV6gElSqSwQnAkWV3yCHtuYrI=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623063234-c1797e7a32b5/go.mod h1:H97hR+VOnZvR5BiGVb0ScCPwH/IoKBOlKM+yrQNVpq0=
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623063234-c1797e7a32b5/go.mod h1:H97hR+VOnZvR5BiGVb0ScCPwH/IoKBOlKM+yrQNVpq0=
|
||||||
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623070026-d945964b0b46 h1:0+XkSRe7XSHa9WHXKpGPuC0myDszjchr4syH006lQ28=
|
||||||
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.9.0-beta.1.0.20250623070026-d945964b0b46/go.mod h1:y/vsN8UO0wSxZk3gv0y5df4RPKMJI6TIxjVcVCPF8T8=
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250408094335-e2d1f65bb306 h1:Jo+yWysWw/N5BJQtAyEMN8ePVvAyPHv+JG4lQti+1N4=
|
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250408094335-e2d1f65bb306 h1:Jo+yWysWw/N5BJQtAyEMN8ePVvAyPHv+JG4lQti+1N4=
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250408094335-e2d1f65bb306/go.mod h1:FdLwYtzsjOIcDiW4uDgDYnB4Wdzq12uJUe0QHSSPbSo=
|
git.grassecon.net/grassrootseconomics/visedriver v0.9.0-beta.2.0.20250408094335-e2d1f65bb306/go.mod h1:FdLwYtzsjOIcDiW4uDgDYnB4Wdzq12uJUe0QHSSPbSo=
|
||||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250129070628-5a539172c694 h1:DjJlBSz0S13acft5XZDWk7ZYnzElym0xLMYEVgyNJ+E=
|
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250129070628-5a539172c694 h1:DjJlBSz0S13acft5XZDWk7ZYnzElym0xLMYEVgyNJ+E=
|
||||||
@ -99,6 +101,8 @@ github.com/grassrootseconomics/ethutils v1.3.1 h1:LlQO90HjJkl7ejC8fv6jP7RJUrAm1j
|
|||||||
github.com/grassrootseconomics/ethutils v1.3.1/go.mod h1:Wuv1VEZrkLIXqTSEYI3Nh9HG/ZHOUQ+U+xvWJ8QtjgQ=
|
github.com/grassrootseconomics/ethutils v1.3.1/go.mod h1:Wuv1VEZrkLIXqTSEYI3Nh9HG/ZHOUQ+U+xvWJ8QtjgQ=
|
||||||
github.com/grassrootseconomics/ussd-data-service v1.5.0-beta h1:BSSQL/yPEvTVku9ja/ENZyZdwZkEaiTzzOUfg72bTy4=
|
github.com/grassrootseconomics/ussd-data-service v1.5.0-beta h1:BSSQL/yPEvTVku9ja/ENZyZdwZkEaiTzzOUfg72bTy4=
|
||||||
github.com/grassrootseconomics/ussd-data-service v1.5.0-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
github.com/grassrootseconomics/ussd-data-service v1.5.0-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
||||||
|
github.com/grassrootseconomics/ussd-data-service v1.6.0-beta h1:pY6zns6ifXyClRxP+JJaWrged3oRE7tTS2xaftF9clA=
|
||||||
|
github.com/grassrootseconomics/ussd-data-service v1.6.0-beta/go.mod h1:9sGnorpKaK76FmOGXoh/xv7x5siSFNYdXxQo9BKW4DI=
|
||||||
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 h1:U4kkNYryi/qfbBF8gh7Vsbuz+cVmhf5kt6pE9bYYyLo=
|
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 h1:U4kkNYryi/qfbBF8gh7Vsbuz+cVmhf5kt6pE9bYYyLo=
|
||||||
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4/go.mod h1:zpZDgZFzeq9s0MIeB1P50NIEWDFFHSFBohI/NbaTD/Y=
|
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4/go.mod h1:zpZDgZFzeq9s0MIeB1P50NIEWDFFHSFBohI/NbaTD/Y=
|
||||||
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
||||||
|
@ -2044,7 +2044,7 @@ func (h *MenuHandlers) ManageVouchers(ctx context.Context, sym string, input []b
|
|||||||
defaultSym := firstVoucher.TokenSymbol
|
defaultSym := firstVoucher.TokenSymbol
|
||||||
defaultBal := firstVoucher.Balance
|
defaultBal := firstVoucher.Balance
|
||||||
defaultDec := firstVoucher.TokenDecimals
|
defaultDec := firstVoucher.TokenDecimals
|
||||||
defaultAddr := firstVoucher.ContractAddress
|
defaultAddr := firstVoucher.TokenAddress
|
||||||
|
|
||||||
// Scale down the balance
|
// Scale down the balance
|
||||||
scaledBalance := store.ScaleDownBalance(defaultBal, defaultDec)
|
scaledBalance := store.ScaleDownBalance(defaultBal, defaultDec)
|
||||||
|
@ -2107,7 +2107,7 @@ func TestManageVouchers(t *testing.T) {
|
|||||||
name: "Set default voucher when no active voucher is set",
|
name: "Set default voucher when no active voucher is set",
|
||||||
vouchersResp: []dataserviceapi.TokenHoldings{
|
vouchersResp: []dataserviceapi.TokenHoldings{
|
||||||
{
|
{
|
||||||
ContractAddress: "0x123",
|
TokenAddress: "0x123",
|
||||||
TokenSymbol: "TOKEN1",
|
TokenSymbol: "TOKEN1",
|
||||||
TokenDecimals: "18",
|
TokenDecimals: "18",
|
||||||
Balance: "100",
|
Balance: "100",
|
||||||
@ -2122,8 +2122,8 @@ func TestManageVouchers(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Check and update active voucher balance",
|
name: "Check and update active voucher balance",
|
||||||
vouchersResp: []dataserviceapi.TokenHoldings{
|
vouchersResp: []dataserviceapi.TokenHoldings{
|
||||||
{ContractAddress: "0xd4c288865Ce", TokenSymbol: "SRF", TokenDecimals: "6", Balance: "100"},
|
{TokenAddress: "0xd4c288865Ce", TokenSymbol: "SRF", TokenDecimals: "6", Balance: "100"},
|
||||||
{ContractAddress: "0x41c188d63Qa", TokenSymbol: "MILO", TokenDecimals: "4", Balance: "200"},
|
{TokenAddress: "0x41c188d63Qa", TokenSymbol: "MILO", TokenDecimals: "4", Balance: "200"},
|
||||||
},
|
},
|
||||||
storedActiveVoucher: "SRF",
|
storedActiveVoucher: "SRF",
|
||||||
expectedVoucherSymbols: []byte("1:SRF\n2:MILO"),
|
expectedVoucherSymbols: []byte("1:SRF\n2:MILO"),
|
||||||
@ -2258,10 +2258,10 @@ func TestSetVoucher(t *testing.T) {
|
|||||||
TokenSymbol: "SRF",
|
TokenSymbol: "SRF",
|
||||||
Balance: "200",
|
Balance: "200",
|
||||||
TokenDecimals: "6",
|
TokenDecimals: "6",
|
||||||
ContractAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
TokenAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedData := fmt.Sprintf("%s,%s,%s,%s", tempData.TokenSymbol, tempData.Balance, tempData.TokenDecimals, tempData.ContractAddress)
|
expectedData := fmt.Sprintf("%s,%s,%s,%s", tempData.TokenSymbol, tempData.Balance, tempData.TokenDecimals, tempData.TokenAddress)
|
||||||
|
|
||||||
// store the expectedData
|
// store the expectedData
|
||||||
if err := store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(expectedData)); err != nil {
|
if err := store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(expectedData)); err != nil {
|
||||||
@ -2529,11 +2529,11 @@ func TestCheckTransactions(t *testing.T) {
|
|||||||
|
|
||||||
mockTXResponse := []dataserviceapi.Last10TxResponse{
|
mockTXResponse := []dataserviceapi.Last10TxResponse{
|
||||||
{
|
{
|
||||||
Sender: "0X13242618721", Recipient: "0x41c188d63Qa", TransferValue: "100", ContractAddress: "0X1324262343rfdGW23",
|
Sender: "0X13242618721", Recipient: "0x41c188d63Qa", TransferValue: "100", TokenAddress: "0X1324262343rfdGW23",
|
||||||
TxHash: "0x123wefsf34rf", DateBlock: time.Now(), TokenSymbol: "SRF", TokenDecimals: "6",
|
TxHash: "0x123wefsf34rf", DateBlock: time.Now(), TokenSymbol: "SRF", TokenDecimals: "6",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Sender: "0x41c188d63Qa", Recipient: "0X13242618721", TransferValue: "200", ContractAddress: "0X1324262343rfdGW23",
|
Sender: "0x41c188d63Qa", Recipient: "0X13242618721", TransferValue: "200", TokenAddress: "0X1324262343rfdGW23",
|
||||||
TxHash: "0xq34wresfdb44", DateBlock: time.Now(), TokenSymbol: "SRF", TokenDecimals: "6",
|
TxHash: "0xq34wresfdb44", DateBlock: time.Now(), TokenSymbol: "SRF", TokenDecimals: "6",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -2585,11 +2585,11 @@ func TestGetTransactionsList(t *testing.T) {
|
|||||||
|
|
||||||
mockTXResponse := []dataserviceapi.Last10TxResponse{
|
mockTXResponse := []dataserviceapi.Last10TxResponse{
|
||||||
{
|
{
|
||||||
Sender: "0X13242618721", Recipient: "0x41c188d63Qa", TransferValue: "1000", ContractAddress: "0X1324262343rfdGW23",
|
Sender: "0X13242618721", Recipient: "0x41c188d63Qa", TransferValue: "1000", TokenAddress: "0X1324262343rfdGW23",
|
||||||
TxHash: "0x123wefsf34rf", DateBlock: dateBlock, TokenSymbol: "SRF", TokenDecimals: "2",
|
TxHash: "0x123wefsf34rf", DateBlock: dateBlock, TokenSymbol: "SRF", TokenDecimals: "2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Sender: "0x41c188d63Qa", Recipient: "0X13242618721", TransferValue: "2000", ContractAddress: "0X1324262343rfdGW23",
|
Sender: "0x41c188d63Qa", Recipient: "0X13242618721", TransferValue: "2000", TokenAddress: "0X1324262343rfdGW23",
|
||||||
TxHash: "0xq34wresfdb44", DateBlock: dateBlock, TokenSymbol: "SRF", TokenDecimals: "2",
|
TxHash: "0xq34wresfdb44", DateBlock: dateBlock, TokenSymbol: "SRF", TokenDecimals: "2",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -2654,11 +2654,11 @@ func TestViewTransactionStatement(t *testing.T) {
|
|||||||
|
|
||||||
mockTXResponse := []dataserviceapi.Last10TxResponse{
|
mockTXResponse := []dataserviceapi.Last10TxResponse{
|
||||||
{
|
{
|
||||||
Sender: "0X13242618721", Recipient: "0x41c188d63Qa", TransferValue: "1000", ContractAddress: "0X1324262343rfdGW23",
|
Sender: "0X13242618721", Recipient: "0x41c188d63Qa", TransferValue: "1000", TokenAddress: "0X1324262343rfdGW23",
|
||||||
TxHash: "0x123wefsf34rf", DateBlock: dateBlock, TokenSymbol: "SRF", TokenDecimals: "2",
|
TxHash: "0x123wefsf34rf", DateBlock: dateBlock, TokenSymbol: "SRF", TokenDecimals: "2",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Sender: "0x41c188d63Qa", Recipient: "0X13242618721", TransferValue: "2000", ContractAddress: "0X1324262343rfdGW23",
|
Sender: "0x41c188d63Qa", Recipient: "0X13242618721", TransferValue: "2000", TokenAddress: "0X1324262343rfdGW23",
|
||||||
TxHash: "0xq34wresfdb44", DateBlock: dateBlock, TokenSymbol: "SRF", TokenDecimals: "2",
|
TxHash: "0xq34wresfdb44", DateBlock: dateBlock, TokenSymbol: "SRF", TokenDecimals: "2",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ func GetSwapFromVoucherData(ctx context.Context, store DataStore, sessionId stri
|
|||||||
TokenSymbol: string(symbol),
|
TokenSymbol: string(symbol),
|
||||||
Balance: string(balance),
|
Balance: string(balance),
|
||||||
TokenDecimals: string(decimal),
|
TokenDecimals: string(decimal),
|
||||||
ContractAddress: string(address),
|
TokenAddress: string(address),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ func TestGetSwapFromVoucherData(t *testing.T) {
|
|||||||
assert.Equal(t, "AMANI", result.TokenSymbol)
|
assert.Equal(t, "AMANI", result.TokenSymbol)
|
||||||
assert.Equal(t, "", result.Balance)
|
assert.Equal(t, "", result.Balance)
|
||||||
assert.Equal(t, "6", result.TokenDecimals)
|
assert.Equal(t, "6", result.TokenDecimals)
|
||||||
assert.Equal(t, "0xc7B78Ac9ACB9E025C8234621FC515bC58179dEAe", result.ContractAddress)
|
assert.Equal(t, "0xc7B78Ac9ACB9E025C8234621FC515bC58179dEAe", result.TokenAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetSwapToVoucherData(t *testing.T) {
|
func TestGetSwapToVoucherData(t *testing.T) {
|
||||||
@ -142,5 +142,5 @@ func TestGetSwapToVoucherData(t *testing.T) {
|
|||||||
assert.Equal(t, "cUSD", result.TokenSymbol)
|
assert.Equal(t, "cUSD", result.TokenSymbol)
|
||||||
assert.Equal(t, "", result.Balance)
|
assert.Equal(t, "", result.Balance)
|
||||||
assert.Equal(t, "6", result.TokenDecimals)
|
assert.Equal(t, "6", result.TokenDecimals)
|
||||||
assert.Equal(t, "0xc7B78Ac9ACB9E025C8234621", result.ContractAddress)
|
assert.Equal(t, "0xc7B78Ac9ACB9E025C8234621", result.TokenAddress)
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ func ProcessVouchers(holdings []dataserviceapi.TokenHoldings) VoucherMetadata {
|
|||||||
|
|
||||||
balances = append(balances, fmt.Sprintf("%d:%s", i+1, scaledBalance))
|
balances = append(balances, fmt.Sprintf("%d:%s", i+1, scaledBalance))
|
||||||
decimals = append(decimals, fmt.Sprintf("%d:%s", i+1, h.TokenDecimals))
|
decimals = append(decimals, fmt.Sprintf("%d:%s", i+1, h.TokenDecimals))
|
||||||
addresses = append(addresses, fmt.Sprintf("%d:%s", i+1, h.ContractAddress))
|
addresses = append(addresses, fmt.Sprintf("%d:%s", i+1, h.TokenAddress))
|
||||||
}
|
}
|
||||||
|
|
||||||
data.Symbols = strings.Join(symbols, "\n")
|
data.Symbols = strings.Join(symbols, "\n")
|
||||||
@ -55,7 +55,7 @@ func ProcessTokens(holdings []dataserviceapi.TokenHoldings) VoucherMetadata {
|
|||||||
for i, h := range holdings {
|
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))
|
||||||
decimals = append(decimals, fmt.Sprintf("%d:%d", i+1, h.TokenDecimals))
|
decimals = append(decimals, fmt.Sprintf("%d:%d", i+1, h.TokenDecimals))
|
||||||
addresses = append(addresses, fmt.Sprintf("%d:%s", i+1, h.ContractAddress))
|
addresses = append(addresses, fmt.Sprintf("%d:%s", i+1, h.TokenAddress))
|
||||||
}
|
}
|
||||||
|
|
||||||
data.Symbols = strings.Join(symbols, "\n")
|
data.Symbols = strings.Join(symbols, "\n")
|
||||||
@ -118,7 +118,7 @@ func GetVoucherData(ctx context.Context, store DataStore, sessionId string, inpu
|
|||||||
TokenSymbol: string(symbol),
|
TokenSymbol: string(symbol),
|
||||||
Balance: string(balance),
|
Balance: string(balance),
|
||||||
TokenDecimals: string(decimal),
|
TokenDecimals: string(decimal),
|
||||||
ContractAddress: string(address),
|
TokenAddress: string(address),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ func MatchVoucher(input, symbols, balances, decimals, addresses string) (symbol,
|
|||||||
|
|
||||||
// StoreTemporaryVoucher saves voucher metadata as temporary entries in the DataStore.
|
// StoreTemporaryVoucher saves voucher metadata as temporary entries in the DataStore.
|
||||||
func StoreTemporaryVoucher(ctx context.Context, store DataStore, sessionId string, data *dataserviceapi.TokenHoldings) error {
|
func StoreTemporaryVoucher(ctx context.Context, store DataStore, sessionId string, data *dataserviceapi.TokenHoldings) error {
|
||||||
tempData := fmt.Sprintf("%s,%s,%s,%s", data.TokenSymbol, data.Balance, data.TokenDecimals, data.ContractAddress)
|
tempData := fmt.Sprintf("%s,%s,%s,%s", data.TokenSymbol, data.Balance, data.TokenDecimals, data.TokenAddress)
|
||||||
|
|
||||||
if err := store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(tempData)); err != nil {
|
if err := store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(tempData)); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -175,7 +175,7 @@ func GetTemporaryVoucherData(ctx context.Context, store DataStore, sessionId str
|
|||||||
data.TokenSymbol = values[0]
|
data.TokenSymbol = values[0]
|
||||||
data.Balance = values[1]
|
data.Balance = values[1]
|
||||||
data.TokenDecimals = values[2]
|
data.TokenDecimals = values[2]
|
||||||
data.ContractAddress = values[3]
|
data.TokenAddress = values[3]
|
||||||
|
|
||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ func UpdateVoucherData(ctx context.Context, store DataStore, sessionId string, d
|
|||||||
storedb.DATA_ACTIVE_SYM: []byte(data.TokenSymbol),
|
storedb.DATA_ACTIVE_SYM: []byte(data.TokenSymbol),
|
||||||
storedb.DATA_ACTIVE_BAL: []byte(data.Balance),
|
storedb.DATA_ACTIVE_BAL: []byte(data.Balance),
|
||||||
storedb.DATA_ACTIVE_DECIMAL: []byte(data.TokenDecimals),
|
storedb.DATA_ACTIVE_DECIMAL: []byte(data.TokenDecimals),
|
||||||
storedb.DATA_ACTIVE_ADDRESS: []byte(data.ContractAddress),
|
storedb.DATA_ACTIVE_ADDRESS: []byte(data.TokenAddress),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write active data
|
// Write active data
|
||||||
|
@ -59,8 +59,8 @@ func TestMatchVoucher(t *testing.T) {
|
|||||||
|
|
||||||
func TestProcessVouchers(t *testing.T) {
|
func TestProcessVouchers(t *testing.T) {
|
||||||
holdings := []dataserviceapi.TokenHoldings{
|
holdings := []dataserviceapi.TokenHoldings{
|
||||||
{ContractAddress: "0xd4c288865Ce", TokenSymbol: "SRF", TokenDecimals: "6", Balance: "100000000"},
|
{TokenAddress: "0xd4c288865Ce", TokenSymbol: "SRF", TokenDecimals: "6", Balance: "100000000"},
|
||||||
{ContractAddress: "0x41c188d63Qa", TokenSymbol: "MILO", TokenDecimals: "4", Balance: "200000000"},
|
{TokenAddress: "0x41c188d63Qa", TokenSymbol: "MILO", TokenDecimals: "4", Balance: "200000000"},
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedResult := VoucherMetadata{
|
expectedResult := VoucherMetadata{
|
||||||
@ -101,7 +101,7 @@ func TestGetVoucherData(t *testing.T) {
|
|||||||
assert.Equal(t, "SRF", result.TokenSymbol)
|
assert.Equal(t, "SRF", result.TokenSymbol)
|
||||||
assert.Equal(t, "100", result.Balance)
|
assert.Equal(t, "100", result.Balance)
|
||||||
assert.Equal(t, "6", result.TokenDecimals)
|
assert.Equal(t, "6", result.TokenDecimals)
|
||||||
assert.Equal(t, "0xd4c288865Ce", result.ContractAddress)
|
assert.Equal(t, "0xd4c288865Ce", result.TokenAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStoreTemporaryVoucher(t *testing.T) {
|
func TestStoreTemporaryVoucher(t *testing.T) {
|
||||||
@ -113,7 +113,7 @@ func TestStoreTemporaryVoucher(t *testing.T) {
|
|||||||
TokenSymbol: "SRF",
|
TokenSymbol: "SRF",
|
||||||
Balance: "200",
|
Balance: "200",
|
||||||
TokenDecimals: "6",
|
TokenDecimals: "6",
|
||||||
ContractAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
TokenAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the function being tested
|
// Execute the function being tested
|
||||||
@ -137,7 +137,7 @@ func TestGetTemporaryVoucherData(t *testing.T) {
|
|||||||
TokenSymbol: "SRF",
|
TokenSymbol: "SRF",
|
||||||
Balance: "200",
|
Balance: "200",
|
||||||
TokenDecimals: "6",
|
TokenDecimals: "6",
|
||||||
ContractAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
TokenAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the data
|
// Store the data
|
||||||
@ -159,7 +159,7 @@ func TestUpdateVoucherData(t *testing.T) {
|
|||||||
TokenSymbol: "SRF",
|
TokenSymbol: "SRF",
|
||||||
Balance: "200",
|
Balance: "200",
|
||||||
TokenDecimals: "6",
|
TokenDecimals: "6",
|
||||||
ContractAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
TokenAddress: "0xd4c288865Ce0985a481Eef3be02443dF5E2e4Ea9",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Old temporary data
|
// Old temporary data
|
||||||
@ -167,7 +167,7 @@ func TestUpdateVoucherData(t *testing.T) {
|
|||||||
TokenSymbol: "OLD",
|
TokenSymbol: "OLD",
|
||||||
Balance: "100",
|
Balance: "100",
|
||||||
TokenDecimals: "8",
|
TokenDecimals: "8",
|
||||||
ContractAddress: "0xold",
|
TokenAddress: "0xold",
|
||||||
}
|
}
|
||||||
require.NoError(t, StoreTemporaryVoucher(ctx, store, sessionId, tempData))
|
require.NoError(t, StoreTemporaryVoucher(ctx, store, sessionId, tempData))
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ func TestUpdateVoucherData(t *testing.T) {
|
|||||||
storedb.DATA_ACTIVE_SYM: []byte(newData.TokenSymbol),
|
storedb.DATA_ACTIVE_SYM: []byte(newData.TokenSymbol),
|
||||||
storedb.DATA_ACTIVE_BAL: []byte(newData.Balance),
|
storedb.DATA_ACTIVE_BAL: []byte(newData.Balance),
|
||||||
storedb.DATA_ACTIVE_DECIMAL: []byte(newData.TokenDecimals),
|
storedb.DATA_ACTIVE_DECIMAL: []byte(newData.TokenDecimals),
|
||||||
storedb.DATA_ACTIVE_ADDRESS: []byte(newData.ContractAddress),
|
storedb.DATA_ACTIVE_ADDRESS: []byte(newData.TokenAddress),
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, expectedValue := range activeEntries {
|
for key, expectedValue := range activeEntries {
|
||||||
|
Loading…
Reference in New Issue
Block a user