Compare commits

..

No commits in common. "master" and "lash/events-up" have entirely different histories.

6 changed files with 102 additions and 58 deletions

View File

@ -12,8 +12,8 @@ import (
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/config" "git.grassecon.net/grassrootseconomics/sarafu-vise-events/config"
"git.grassecon.net/grassrootseconomics/common/hex" "git.grassecon.net/grassrootseconomics/common/hex"
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db" storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/internal/testutil"
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event" apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
apimocks "git.grassecon.net/grassrootseconomics/sarafu-api/testutil/mocks"
viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event" viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
) )
@ -28,14 +28,14 @@ func TestCustodialRegistration(t *testing.T) {
storageService := mocks.NewMemStorageService(ctx) storageService := mocks.NewMemStorageService(ctx)
userDb := storageService.Db userDb := storageService.Db
alice, err := hex.NormalizeHex(apimocks.AliceChecksum) alice, err := hex.NormalizeHex(testutil.AliceChecksum)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
userDb.SetSession(alice) userDb.SetSession(alice)
userDb.SetPrefix(db.DATATYPE_USERDATA) userDb.SetPrefix(db.DATATYPE_USERDATA)
err = userDb.Put(ctx, storedb.PackKey(storedb.DATA_PUBLIC_KEY_REVERSE, []byte{}), []byte(apimocks.AliceSession)) err = userDb.Put(ctx, storedb.PackKey(storedb.DATA_PUBLIC_KEY_REVERSE, []byte{}), []byte(testutil.AliceSession))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -44,13 +44,13 @@ func TestCustodialRegistration(t *testing.T) {
ca := cache.NewCache() ca := cache.NewCache()
pr, _ := storageService.GetPersister(ctx) pr, _ := storageService.GetPersister(ctx)
pr = pr.WithContent(st, ca) pr = pr.WithContent(st, ca)
err = pr.Save(apimocks.AliceSession) err = pr.Save(testutil.AliceSession)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
ev := &apievent.EventCustodialRegistration{ ev := &apievent.EventCustodialRegistration{
Account: apimocks.AliceChecksum, Account: testutil.AliceChecksum,
} }
// Use dev service or mock service instead // Use dev service or mock service instead

View File

@ -19,7 +19,6 @@ import (
"git.grassecon.net/grassrootseconomics/sarafu-api/models" "git.grassecon.net/grassrootseconomics/sarafu-api/models"
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/lookup" "git.grassecon.net/grassrootseconomics/sarafu-vise-events/lookup"
"git.grassecon.net/grassrootseconomics/common/hex" "git.grassecon.net/grassrootseconomics/common/hex"
apimocks "git.grassecon.net/grassrootseconomics/sarafu-api/testutil/mocks"
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/internal/testutil" "git.grassecon.net/grassrootseconomics/sarafu-vise-events/internal/testutil"
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application" "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event" viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
@ -98,11 +97,11 @@ func TestHandleMsg(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
api := &apimocks.MockApi{} api := &testutil.MockApi{}
api.TransactionsContent = []dataserviceapi.Last10TxResponse{ api.TransactionsContent = []dataserviceapi.Last10TxResponse{
dataserviceapi.Last10TxResponse{ dataserviceapi.Last10TxResponse{
Sender: apimocks.AliceChecksum, Sender: testutil.AliceChecksum,
Recipient: apimocks.BobChecksum, Recipient: testutil.BobChecksum,
TransferValue: strconv.Itoa(txValue), TransferValue: strconv.Itoa(txValue),
ContractAddress: tokenAddress, ContractAddress: tokenAddress,
TxHash: txHash, TxHash: txHash,
@ -132,14 +131,14 @@ func TestHandleMsg(t *testing.T) {
eu := viseevent.NewEventsUpdater(api, storageService) eu := viseevent.NewEventsUpdater(api, storageService)
userDb := storageService.Db userDb := storageService.Db
alice, err := hex.NormalizeHex(apimocks.AliceChecksum) alice, err := hex.NormalizeHex(testutil.AliceChecksum)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
userDb.SetSession(alice) userDb.SetSession(alice)
userDb.SetPrefix(db.DATATYPE_USERDATA) userDb.SetPrefix(db.DATATYPE_USERDATA)
err = userDb.Put(ctx, storedb.PackKey(storedb.DATA_PUBLIC_KEY_REVERSE, []byte{}), []byte(apimocks.AliceSession)) err = userDb.Put(ctx, storedb.PackKey(storedb.DATA_PUBLIC_KEY_REVERSE, []byte{}), []byte(testutil.AliceSession))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -160,7 +159,7 @@ func TestHandleMsg(t *testing.T) {
"to": "%s", "to": "%s",
"value": "%d" "value": "%d"
} }
}`, txBlock, tokenAddress, txTimestamp, txHash, apimocks.AliceChecksum, apimocks.BobChecksum, txValue) }`, txBlock, tokenAddress, txTimestamp, txHash, testutil.AliceChecksum, testutil.BobChecksum, txValue)
msg := &testMsg{ msg := &testMsg{
data: []byte(data), data: []byte(data),
} }
@ -169,7 +168,7 @@ func TestHandleMsg(t *testing.T) {
userStore := store.UserDataStore{ userStore := store.UserDataStore{
Db: userDb, Db: userDb,
} }
v, err := userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_ACTIVE_SYM) v, err := userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_ACTIVE_SYM)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -177,7 +176,7 @@ func TestHandleMsg(t *testing.T) {
t.Fatalf("expected '%s', got %s", tokenSymbol, v) t.Fatalf("expected '%s', got %s", tokenSymbol, v)
} }
v, err = userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_ACTIVE_BAL) v, err = userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_ACTIVE_BAL)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -188,7 +187,7 @@ func TestHandleMsg(t *testing.T) {
t.Fatalf("expected '%d', got %s", tokenBalance, v) t.Fatalf("expected '%d', got %s", tokenBalance, v)
} }
v, err = userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_TRANSACTIONS) v, err = userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_TRANSACTIONS)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -201,7 +200,7 @@ func TestHandleMsg(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
ctx = context.WithValue(ctx, "SessionId", apimocks.AliceSession) ctx = context.WithValue(ctx, "SessionId", testutil.AliceSession)
rrs, err := mh.GetVoucherList(ctx, "", []byte{}) rrs, err := mh.GetVoucherList(ctx, "", []byte{})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -211,7 +210,7 @@ func TestHandleMsg(t *testing.T) {
t.Fatalf("expected '%v', got '%v'", expect, rrs.Content) t.Fatalf("expected '%v', got '%v'", expect, rrs.Content)
} }
// userDb.SetPrefix(event.DATATYPE_USERSUB) // userDb.SetPrefix(event.DATATYPE_USERSUB)
// userDb.SetSession(apimocks.AliceSession) // userDb.SetSession(testutil.AliceSession)
// k := append([]byte("vouchers"), []byte("sym")...) // k := append([]byte("vouchers"), []byte("sym")...)
// v, err = userDb.Get(ctx, k) // v, err = userDb.Get(ctx, k)
// if err != nil { // if err != nil {

View File

@ -20,7 +20,6 @@ import (
"git.grassecon.net/grassrootseconomics/common/hex" "git.grassecon.net/grassrootseconomics/common/hex"
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/internal/testutil" "git.grassecon.net/grassrootseconomics/sarafu-vise-events/internal/testutil"
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event" apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
apimocks "git.grassecon.net/grassrootseconomics/sarafu-api/testutil/mocks"
viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event" viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
"git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks" "git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks"
) )
@ -46,11 +45,11 @@ func TestTokenTransfer(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
api := &apimocks.MockApi{} api := &testutil.MockApi{}
api.TransactionsContent = []dataserviceapi.Last10TxResponse{ api.TransactionsContent = []dataserviceapi.Last10TxResponse{
dataserviceapi.Last10TxResponse{ dataserviceapi.Last10TxResponse{
Sender: apimocks.AliceChecksum, Sender: testutil.AliceChecksum,
Recipient: apimocks.BobChecksum, Recipient: testutil.BobChecksum,
TransferValue: strconv.Itoa(txValue), TransferValue: strconv.Itoa(txValue),
ContractAddress: tokenAddress, ContractAddress: tokenAddress,
TxHash: txHash, TxHash: txHash,
@ -81,7 +80,7 @@ func TestTokenTransfer(t *testing.T) {
eu := viseevent.NewEventsUpdater(api, storageService) eu := viseevent.NewEventsUpdater(api, storageService)
userDb := storageService.Db userDb := storageService.Db
alice, err := hex.NormalizeHex(apimocks.AliceChecksum) alice, err := hex.NormalizeHex(testutil.AliceChecksum)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -89,7 +88,7 @@ func TestTokenTransfer(t *testing.T) {
// TODO: deduplicate test setup // TODO: deduplicate test setup
userDb.SetSession(alice) userDb.SetSession(alice)
userDb.SetPrefix(db.DATATYPE_USERDATA) userDb.SetPrefix(db.DATATYPE_USERDATA)
err = userDb.Put(ctx, storedb.PackKey(storedb.DATA_PUBLIC_KEY_REVERSE, []byte{}), []byte(apimocks.AliceSession)) err = userDb.Put(ctx, storedb.PackKey(storedb.DATA_PUBLIC_KEY_REVERSE, []byte{}), []byte(testutil.AliceSession))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -98,8 +97,8 @@ func TestTokenTransfer(t *testing.T) {
} }
ev := &apievent.EventTokenTransfer{ ev := &apievent.EventTokenTransfer{
From: apimocks.BobChecksum, From: testutil.BobChecksum,
To: apimocks.AliceChecksum, To: testutil.AliceChecksum,
Value: txValue, Value: txValue,
} }
@ -109,7 +108,7 @@ func TestTokenTransfer(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
v, err := userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_ACTIVE_SYM) v, err := userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_ACTIVE_SYM)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -117,7 +116,7 @@ func TestTokenTransfer(t *testing.T) {
t.Fatalf("expected '%s', got %s", tokenSymbol, v) t.Fatalf("expected '%s', got %s", tokenSymbol, v)
} }
v, err = userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_ACTIVE_BAL) v, err = userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_ACTIVE_BAL)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -128,7 +127,7 @@ func TestTokenTransfer(t *testing.T) {
t.Fatalf("expected '%s', got %s", expect, v) t.Fatalf("expected '%s', got %s", expect, v)
} }
v, err = userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_TRANSACTIONS) v, err = userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_TRANSACTIONS)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -140,7 +139,7 @@ func TestTokenTransfer(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
ctx = context.WithValue(ctx, "SessionId", apimocks.AliceSession) ctx = context.WithValue(ctx, "SessionId", testutil.AliceSession)
rrs, err := mh.GetVoucherList(ctx, "", []byte{}) rrs, err := mh.GetVoucherList(ctx, "", []byte{})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -157,11 +156,11 @@ func TestTokenMint(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
api := &apimocks.MockApi{} api := &testutil.MockApi{}
api.TransactionsContent = []dataserviceapi.Last10TxResponse{ api.TransactionsContent = []dataserviceapi.Last10TxResponse{
dataserviceapi.Last10TxResponse{ dataserviceapi.Last10TxResponse{
Sender: apimocks.AliceChecksum, Sender: testutil.AliceChecksum,
Recipient: apimocks.BobChecksum, Recipient: testutil.BobChecksum,
TransferValue: strconv.Itoa(txValue), TransferValue: strconv.Itoa(txValue),
ContractAddress: tokenAddress, ContractAddress: tokenAddress,
TxHash: txHash, TxHash: txHash,
@ -193,14 +192,14 @@ func TestTokenMint(t *testing.T) {
eu := viseevent.NewEventsUpdater(api, storageService) eu := viseevent.NewEventsUpdater(api, storageService)
userDb := storageService.Db userDb := storageService.Db
alice, err := hex.NormalizeHex(apimocks.AliceChecksum) alice, err := hex.NormalizeHex(testutil.AliceChecksum)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
userDb.SetSession(alice) userDb.SetSession(alice)
userDb.SetPrefix(db.DATATYPE_USERDATA) userDb.SetPrefix(db.DATATYPE_USERDATA)
err = userDb.Put(ctx, storedb.PackKey(storedb.DATA_PUBLIC_KEY_REVERSE, []byte{}), []byte(apimocks.AliceSession)) err = userDb.Put(ctx, storedb.PackKey(storedb.DATA_PUBLIC_KEY_REVERSE, []byte{}), []byte(testutil.AliceSession))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -209,7 +208,7 @@ func TestTokenMint(t *testing.T) {
} }
ev := &apievent.EventTokenMint{ ev := &apievent.EventTokenMint{
To: apimocks.AliceChecksum, To: testutil.AliceChecksum,
Value: txValue, Value: txValue,
} }
@ -219,7 +218,7 @@ func TestTokenMint(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
v, err := userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_ACTIVE_SYM) v, err := userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_ACTIVE_SYM)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -227,7 +226,7 @@ func TestTokenMint(t *testing.T) {
t.Fatalf("expected '%s', got %s", tokenSymbol, v) t.Fatalf("expected '%s', got %s", tokenSymbol, v)
} }
v, err = userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_ACTIVE_BAL) v, err = userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_ACTIVE_BAL)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -238,7 +237,7 @@ func TestTokenMint(t *testing.T) {
t.Fatalf("expected '%d', got %s", tokenBalance, v) t.Fatalf("expected '%d', got %s", tokenBalance, v)
} }
v, err = userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_TRANSACTIONS) v, err = userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_TRANSACTIONS)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -250,7 +249,7 @@ func TestTokenMint(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
ctx = context.WithValue(ctx, "SessionId", apimocks.AliceSession) ctx = context.WithValue(ctx, "SessionId", testutil.AliceSession)
rrs, err := mh.GetVoucherList(ctx, "", []byte{}) rrs, err := mh.GetVoucherList(ctx, "", []byte{})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)

9
go.mod
View File

@ -5,8 +5,8 @@ go 1.23.4
require ( require (
git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05 git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250114072912-a4976e6c52a0 git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250113213645-7c697394b5e7
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250114083924-55356a0c64f5 git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250114070250-ce9a263b40a3
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b
github.com/grassrootseconomics/eth-tracker v1.3.0-rc github.com/grassrootseconomics/eth-tracker v1.3.0-rc
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta github.com/grassrootseconomics/ussd-data-service v1.2.0-beta
@ -16,7 +16,6 @@ require (
require ( require (
github.com/alecthomas/participle/v2 v2.0.0 // indirect github.com/alecthomas/participle/v2 v2.0.0 // indirect
github.com/barbashov/iso639-3 v0.0.0-20211020172741-1f4ffb2d8d1c // indirect github.com/barbashov/iso639-3 v0.0.0-20211020172741-1f4ffb2d8d1c // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fxamacker/cbor/v2 v2.4.0 // indirect github.com/fxamacker/cbor/v2 v2.4.0 // indirect
github.com/grassrootseconomics/eth-custodial v1.3.0-beta // indirect github.com/grassrootseconomics/eth-custodial v1.3.0-beta // indirect
github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 // indirect github.com/graygnuorg/go-gdbm v0.0.0-20220711140707-71387d66dce4 // indirect
@ -29,14 +28,10 @@ require (
github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a // indirect github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a // indirect
github.com/nats-io/nkeys v0.4.7 // indirect github.com/nats-io/nkeys v0.4.7 // indirect
github.com/nats-io/nuid v1.0.1 // indirect github.com/nats-io/nuid v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/x448/float16 v0.8.4 // indirect github.com/x448/float16 v0.8.4 // indirect
golang.org/x/crypto v0.32.0 // indirect golang.org/x/crypto v0.32.0 // indirect
golang.org/x/sync v0.10.0 // indirect golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.29.0 // indirect golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.21.0 // indirect golang.org/x/text v0.21.0 // indirect
gopkg.in/leonelquinteros/gotext.v1 v1.3.1 // indirect gopkg.in/leonelquinteros/gotext.v1 v1.3.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
) )

16
go.sum
View File

@ -2,10 +2,10 @@ git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d h1:bPAOVZOX4frSG
git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck= git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05 h1:BenzGx6aDHKDwE23/mWIFD2InYIXyzHroZWV3MF5WUk= git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05 h1:BenzGx6aDHKDwE23/mWIFD2InYIXyzHroZWV3MF5WUk=
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60= git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250114072912-a4976e6c52a0 h1:qsZS8TPzmq/5CslDUNld6vgZr9etbWk3Lw5qYauzPbk= git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250113213645-7c697394b5e7 h1:P+Bi5jcQbnCrLnKNC5k8XDTBsocyZTVifqDyZY6d0w8=
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250114072912-a4976e6c52a0/go.mod h1:X9aQF93xw3vcW2QftJfzLewvbotRM0U00DRtdmFw294= git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250113213645-7c697394b5e7/go.mod h1:X9aQF93xw3vcW2QftJfzLewvbotRM0U00DRtdmFw294=
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250114083924-55356a0c64f5 h1:20zXYGv2MrCscYtQeK3M5R1nSVMUc9J1ivHcgdG4q/A= git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250114070250-ce9a263b40a3 h1:E4TKaXKJbPKbN6UtbqaJbB90aSo64FzwgOhZV9n3XKI=
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250114083924-55356a0c64f5/go.mod h1:1WryKcUnFI1J4Jl3wZJ4DX/7lnew+0PDY8xWvqc46UI= git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250114070250-ce9a263b40a3/go.mod h1:1WryKcUnFI1J4Jl3wZJ4DX/7lnew+0PDY8xWvqc46UI=
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b h1:6SieNUSEKbkjzquuwazs/lVG56zdEWF10zQQEMRJfMs= git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b h1:6SieNUSEKbkjzquuwazs/lVG56zdEWF10zQQEMRJfMs=
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b/go.mod h1:E6W7ZOa7ZvVr0Bc5ot0LNSwpSPYq4hXlAIvEPy3AJ7U= git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b/go.mod h1:E6W7ZOa7ZvVr0Bc5ot0LNSwpSPYq4hXlAIvEPy3AJ7U=
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk= github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
@ -43,10 +43,6 @@ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4=
github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a h1:0Q3H0YXzMHiciXtRcM+j0jiCe8WKPQHoRgQiRTnfcLY= github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a h1:0Q3H0YXzMHiciXtRcM+j0jiCe8WKPQHoRgQiRTnfcLY=
github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a/go.mod h1:CdTTBOYzS5E4mWS1N8NWP6AHI19MP0A2B18n3hLzRMk= github.com/mattn/kinako v0.0.0-20170717041458-332c0a7e205a/go.mod h1:CdTTBOYzS5E4mWS1N8NWP6AHI19MP0A2B18n3hLzRMk=
github.com/nats-io/nats.go v1.37.0 h1:07rauXbVnnJvv1gfIyghFEo6lUcYRY0WXc3x7x0vUxE= github.com/nats-io/nats.go v1.37.0 h1:07rauXbVnnJvv1gfIyghFEo6lUcYRY0WXc3x7x0vUxE=
@ -62,8 +58,6 @@ github.com/peteole/testdata-loader v0.3.0/go.mod h1:Mt0ZbRtb56u8SLJpNP+BnQbENljM
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
@ -82,8 +76,6 @@ golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/leonelquinteros/gotext.v1 v1.3.1 h1:8d9/fdTG0kn/B7NNGV1BsEyvektXFAbkMsTZS2sFSCc= gopkg.in/leonelquinteros/gotext.v1 v1.3.1 h1:8d9/fdTG0kn/B7NNGV1BsEyvektXFAbkMsTZS2sFSCc=
gopkg.in/leonelquinteros/gotext.v1 v1.3.1/go.mod h1:X1WlGDeAFIYsW6GjgMm4VwUwZ2XjI7Zan2InxSUQWrU= gopkg.in/leonelquinteros/gotext.v1 v1.3.1/go.mod h1:X1WlGDeAFIYsW6GjgMm4VwUwZ2XjI7Zan2InxSUQWrU=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

59
internal/testutil/api.go Normal file
View File

@ -0,0 +1,59 @@
package testutil
import (
"context"
"git.defalsify.org/vise.git/logging"
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
)
var (
logg = logging.NewVanilla().WithDomain("sarafu-vise-events.testutil")
)
const (
AliceChecksum = "0xeae046BF396e91f5A8D74f863dC57c107c8a4a70"
BobChecksum = "0xB3117202371853e24B725d4169D87616A7dDb127"
AliceSession = "5553425"
)
type MockApi struct {
TransactionsContent []dataserviceapi.Last10TxResponse
VouchersContent []dataserviceapi.TokenHoldings
VoucherDataContent *models.VoucherDataResult
}
func(m MockApi) CheckBalance(ctx context.Context, publicKey string) (*models.BalanceResult, error) {
return nil, nil
}
func(m MockApi) CreateAccount(ctx context.Context) (*models.AccountResult, error) {
return nil, nil
}
func(m MockApi) TrackAccountStatus(ctx context.Context, publicKey string) (*models.TrackStatusResult, error) {
return nil, nil
}
func(m MockApi) FetchVouchers(ctx context.Context, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
logg.DebugCtxf(ctx, "mockapi fetchvouchers", "key", publicKey)
return m.VouchersContent, nil
}
func(m MockApi) FetchTransactions(ctx context.Context, publicKey string) ([]dataserviceapi.Last10TxResponse, error) {
logg.DebugCtxf(ctx, "mockapi fetchtransactions", "key", publicKey)
return m.TransactionsContent, nil
}
func(m MockApi) VoucherData(ctx context.Context, address string) (*models.VoucherDataResult, error) {
return m.VoucherDataContent, nil
}
func(m MockApi) CheckAliasAddress(ctx context.Context, alias string) (*dataserviceapi.AliasAddress, error) {
return nil, nil
}
func(m MockApi) TokenTransfer(ctx context.Context, amount, from, to, tokenAddress string) (*models.TokenTransferResponse, error) {
return nil, nil
}