Compare commits
8 Commits
lash/event
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
d1acde4e01 | ||
a66a11abe6 | |||
|
b69115caaa | ||
|
7e2d6b8d09 | ||
|
76d6e40827 | ||
|
4cdd8a1082 | ||
|
2f88d79394 | ||
|
d9438cb815 |
9
.dockerignore
Normal file
9
.dockerignore
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
!/cmd
|
||||||
|
!/config
|
||||||
|
!/event
|
||||||
|
!/internal
|
||||||
|
!/lookup
|
||||||
|
!/LICENSE
|
||||||
|
!/go.*
|
||||||
|
!/.env.example
|
56
.github/workflows/docker.yaml
vendored
Normal file
56
.github/workflows/docker.yaml
vendored
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
name: release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Check out repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Cache Docker layers
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
|
- name: Login to GHCR Docker registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set outputs
|
||||||
|
run: |
|
||||||
|
echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV \
|
||||||
|
&& echo "RELEASE_SHORT_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: ./
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: true
|
||||||
|
build-args: |
|
||||||
|
BUILD=${{ env.RELEASE_SHORT_COMMIT }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
tags: |
|
||||||
|
ghcr.io/grassrootseconomics/sarafu-vise-events:latest
|
||||||
|
ghcr.io/grassrootseconomics/sarafu-vise-events:${{ env.RELEASE_TAG }}
|
38
Dockerfile
Normal file
38
Dockerfile
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
FROM golang:1.23.4-bookworm AS build
|
||||||
|
|
||||||
|
ENV CGO_ENABLED=1
|
||||||
|
|
||||||
|
ARG BUILDPLATFORM
|
||||||
|
ARG TARGETPLATFORM
|
||||||
|
ARG BUILD=dev
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
COPY . .
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
libgdbm-dev \
|
||||||
|
git \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
RUN echo "Building on $BUILDPLATFORM, building for $TARGETPLATFORM"
|
||||||
|
RUN go mod download
|
||||||
|
RUN go build -tags logtrace -o sarafu-vise-events -ldflags="-X main.build=${BUILD} -s -w" cmd/main.go
|
||||||
|
|
||||||
|
FROM debian:bookworm-slim
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
libgdbm-dev \
|
||||||
|
ca-certificates \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /service
|
||||||
|
|
||||||
|
COPY --from=build /build/sarafu-vise-events .
|
||||||
|
COPY --from=build /build/LICENSE .
|
||||||
|
COPY --from=build /build/.env.example .
|
||||||
|
RUN mv .env.example .env
|
||||||
|
|
||||||
|
CMD ["./sarafu-vise-events"]
|
24
cmd/main.go
24
cmd/main.go
@ -9,39 +9,41 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/logging"
|
"git.defalsify.org/vise.git/logging"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
sarafuconfig "git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/config"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/config"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/event/nats"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/event/nats"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/lookup"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/lookup"
|
||||||
viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logg = logging.NewVanilla()
|
logg = logging.NewVanilla()
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
var connStr string
|
override := sarafuconfig.NewOverride()
|
||||||
|
|
||||||
flag.StringVar(&connStr, "c", "", "connection string")
|
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||||
|
flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string")
|
||||||
|
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
|
||||||
|
flag.StringVar(override.StateConn, "state", "?", "state store connection string")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if connStr == "" {
|
sarafuconfig.Apply(override)
|
||||||
connStr = config.DbConn()
|
conns, err := sarafuconfig.GetConns()
|
||||||
}
|
|
||||||
connData, err := storage.ToConnData(connStr)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
logg.Infof("start command", "conn", connData)
|
logg.Infof("start command", "conn", conns)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
menuStorageService := storage.NewMenuStorageService(connData, "")
|
menuStorageService := storage.NewMenuStorageService(conns)
|
||||||
|
|
||||||
eu := viseevent.NewEventsUpdater(lookup.Api, menuStorageService)
|
eu := viseevent.NewEventsUpdater(lookup.Api, menuStorageService)
|
||||||
eh := eu.ToEventsHandler()
|
eh := eu.ToEventsHandler()
|
||||||
|
@ -2,26 +2,24 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
|
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
|
||||||
apiconfig "git.grassecon.net/grassrootseconomics/sarafu-api/config"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/env"
|
"git.grassecon.net/grassrootseconomics/visedriver/env"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
JetstreamURL string
|
JetstreamURL string
|
||||||
JetstreamClientName string
|
JetstreamClientName string
|
||||||
|
Apply = config.Apply
|
||||||
|
GetConns = config.GetConns
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultJetstreamURL string = "localhost:4222"
|
defaultJetstreamURL string = "localhost:4222"
|
||||||
defaultJetstreamClientName string = "omnom"
|
defaultJetstreamClientName string = "omnom"
|
||||||
)
|
)
|
||||||
|
|
||||||
func LoadConfig() error {
|
func LoadConfig() error {
|
||||||
err := viseconfig.LoadConfig()
|
err := config.LoadConfig()
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
err = apiconfig.LoadConfig()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -30,10 +28,6 @@ func LoadConfig() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DbConn() string {
|
|
||||||
return viseconfig.DbConn
|
|
||||||
}
|
|
||||||
|
|
||||||
func Language() string {
|
func Language() string {
|
||||||
return viseconfig.DefaultLanguage
|
return viseconfig.DefaultLanguage
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package event
|
package event
|
||||||
|
|
||||||
import (
|
import (
|
||||||
geEvent "github.com/grassrootseconomics/eth-tracker/pkg/event"
|
|
||||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||||
|
geEvent "github.com/grassrootseconomics/eth-tracker/pkg/event"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -4,20 +4,19 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"git.defalsify.org/vise.git/cache"
|
||||||
"git.defalsify.org/vise.git/db"
|
"git.defalsify.org/vise.git/db"
|
||||||
"git.defalsify.org/vise.git/state"
|
"git.defalsify.org/vise.git/state"
|
||||||
"git.defalsify.org/vise.git/cache"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
|
||||||
"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"
|
|
||||||
"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"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||||
|
apimocks "git.grassecon.net/grassrootseconomics/sarafu-api/testutil/mocks"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/config"
|
||||||
viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
||||||
|
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func TestCustodialRegistration(t *testing.T) {
|
func TestCustodialRegistration(t *testing.T) {
|
||||||
err := config.LoadConfig()
|
err := config.LoadConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -28,14 +27,14 @@ func TestCustodialRegistration(t *testing.T) {
|
|||||||
storageService := mocks.NewMemStorageService(ctx)
|
storageService := mocks.NewMemStorageService(ctx)
|
||||||
userDb := storageService.Db
|
userDb := storageService.Db
|
||||||
|
|
||||||
alice, err := hex.NormalizeHex(testutil.AliceChecksum)
|
alice, err := hex.NormalizeHex(apimocks.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(testutil.AliceSession))
|
err = userDb.Put(ctx, storedb.PackKey(storedb.DATA_PUBLIC_KEY_REVERSE, []byte{}), []byte(apimocks.AliceSession))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -44,13 +43,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(testutil.AliceSession)
|
err = pr.Save(apimocks.AliceSession)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ev := &apievent.EventCustodialRegistration{
|
ev := &apievent.EventCustodialRegistration{
|
||||||
Account: testutil.AliceChecksum,
|
Account: apimocks.AliceChecksum,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use dev service or mock service instead
|
// Use dev service or mock service instead
|
||||||
|
@ -5,13 +5,13 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"git.defalsify.org/vise.git/logging"
|
||||||
|
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/config"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/event"
|
||||||
|
geEvent "github.com/grassrootseconomics/eth-tracker/pkg/event"
|
||||||
nats "github.com/nats-io/nats.go"
|
nats "github.com/nats-io/nats.go"
|
||||||
"github.com/nats-io/nats.go/jetstream"
|
"github.com/nats-io/nats.go/jetstream"
|
||||||
geEvent "github.com/grassrootseconomics/eth-tracker/pkg/event"
|
|
||||||
"git.defalsify.org/vise.git/logging"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/event"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/config"
|
|
||||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -23,10 +23,10 @@ var (
|
|||||||
// Extends Router.
|
// Extends Router.
|
||||||
type NatsSubscription struct {
|
type NatsSubscription struct {
|
||||||
*event.Router
|
*event.Router
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
conn *nats.Conn
|
conn *nats.Conn
|
||||||
js jetstream.JetStream
|
js jetstream.JetStream
|
||||||
cs jetstream.Consumer
|
cs jetstream.Consumer
|
||||||
cctx jetstream.ConsumeContext
|
cctx jetstream.ConsumeContext
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ func NewNatsSubscription(handler *apievent.EventsHandler) *NatsSubscription {
|
|||||||
// Fails if connection fails or the "Jetstream" consumer cannot be set up.
|
// Fails if connection fails or the "Jetstream" consumer cannot be set up.
|
||||||
//
|
//
|
||||||
// Once connected, it will attempt to reconnect if disconnected.
|
// Once connected, it will attempt to reconnect if disconnected.
|
||||||
func(n *NatsSubscription) Connect(ctx context.Context, connStr string) error {
|
func (n *NatsSubscription) Connect(ctx context.Context, connStr string) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// enables set ctx in test, even if the connstr is invalid (js msg handler doesnt take context)
|
// enables set ctx in test, even if the connstr is invalid (js msg handler doesnt take context)
|
||||||
@ -59,8 +59,8 @@ func(n *NatsSubscription) Connect(ctx context.Context, connStr string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
n.cs, err = n.js.CreateConsumer(ctx, "TRACKER", jetstream.ConsumerConfig{
|
n.cs, err = n.js.CreateConsumer(ctx, "TRACKER", jetstream.ConsumerConfig{
|
||||||
Name: config.JetstreamClientName,
|
Name: config.JetstreamClientName,
|
||||||
Durable: config.JetstreamClientName,
|
Durable: config.JetstreamClientName,
|
||||||
FilterSubjects: []string{"TRACKER.*"},
|
FilterSubjects: []string{"TRACKER.*"},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -78,7 +78,7 @@ func(n *NatsSubscription) Connect(ctx context.Context, connStr string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Close cleanly brings down the nats and jetstream connection.
|
// Close cleanly brings down the nats and jetstream connection.
|
||||||
func(n *NatsSubscription) Close() error {
|
func (n *NatsSubscription) Close() error {
|
||||||
n.cctx.Stop()
|
n.cctx.Stop()
|
||||||
select {
|
select {
|
||||||
case <-n.cctx.Closed():
|
case <-n.cctx.Closed():
|
||||||
@ -88,7 +88,7 @@ func(n *NatsSubscription) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// jetstream message handler and acknowledger.
|
// jetstream message handler and acknowledger.
|
||||||
func(n *NatsSubscription) handleEvent(m jetstream.Msg) {
|
func (n *NatsSubscription) handleEvent(m jetstream.Msg) {
|
||||||
var ev geEvent.Event
|
var ev geEvent.Event
|
||||||
|
|
||||||
logg.DebugCtxf(n.ctx, "have msg", "msg", m)
|
logg.DebugCtxf(n.ctx, "have msg", "msg", m)
|
||||||
|
@ -9,33 +9,34 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
nats "github.com/nats-io/nats.go"
|
|
||||||
"github.com/nats-io/nats.go/jetstream"
|
|
||||||
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
|
||||||
"git.defalsify.org/vise.git/db"
|
"git.defalsify.org/vise.git/db"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/config"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
|
||||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/lookup"
|
|
||||||
"git.grassecon.net/grassrootseconomics/common/hex"
|
"git.grassecon.net/grassrootseconomics/common/hex"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
|
||||||
|
apimocks "git.grassecon.net/grassrootseconomics/sarafu-api/testutil/mocks"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/config"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/internal/testutil"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/internal/testutil"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/lookup"
|
||||||
"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"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||||
|
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks"
|
"git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks"
|
||||||
|
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||||
|
nats "github.com/nats-io/nats.go"
|
||||||
|
"github.com/nats-io/nats.go/jetstream"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
txBlock = 42
|
txBlock = 42
|
||||||
tokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a"
|
tokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a"
|
||||||
tokenSymbol = "FOO"
|
tokenSymbol = "FOO"
|
||||||
tokenName = "Foo Token"
|
tokenName = "Foo Token"
|
||||||
tokenDecimals = 6
|
tokenDecimals = 6
|
||||||
txValue = 1337
|
txValue = 1337
|
||||||
tokenBalance = 362436
|
tokenBalance = 362436
|
||||||
txTimestamp = 1730592500
|
txTimestamp = 1730592500
|
||||||
txHash = "0xabcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789"
|
txHash = "0xabcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789"
|
||||||
sinkAddress = "0xb42C5920014eE152F2225285219407938469BBfA"
|
sinkAddress = "0xb42C5920014eE152F2225285219407938469BBfA"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: jetstream, would have been nice of you to provide an easier way to make a mock msg
|
// TODO: jetstream, would have been nice of you to provide an easier way to make a mock msg
|
||||||
@ -43,51 +44,51 @@ type testMsg struct {
|
|||||||
data []byte
|
data []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func(m *testMsg) Ack() error {
|
func (m *testMsg) Ack() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func(m *testMsg) Nak() error {
|
func (m *testMsg) Nak() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func(m *testMsg) NakWithDelay(time.Duration) error {
|
func (m *testMsg) NakWithDelay(time.Duration) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func(m *testMsg) Data() []byte {
|
func (m *testMsg) Data() []byte {
|
||||||
return m.data
|
return m.data
|
||||||
}
|
}
|
||||||
|
|
||||||
func(m *testMsg) Reply() string {
|
func (m *testMsg) Reply() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func(m *testMsg) Subject() string {
|
func (m *testMsg) Subject() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func(m *testMsg) Term() error {
|
func (m *testMsg) Term() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func(m *testMsg) TermWithReason(string) error {
|
func (m *testMsg) TermWithReason(string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func(m *testMsg) DoubleAck(ctx context.Context) error {
|
func (m *testMsg) DoubleAck(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func(m *testMsg) Headers() nats.Header {
|
func (m *testMsg) Headers() nats.Header {
|
||||||
return nats.Header{}
|
return nats.Header{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func(m *testMsg) InProgress() error {
|
func (m *testMsg) InProgress() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func(m *testMsg) Metadata() (*jetstream.MsgMetadata, error) {
|
func (m *testMsg) Metadata() (*jetstream.MsgMetadata, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,32 +98,32 @@ func TestHandleMsg(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
api := &testutil.MockApi{}
|
api := &apimocks.MockApi{}
|
||||||
api.TransactionsContent = []dataserviceapi.Last10TxResponse{
|
api.TransactionsContent = []dataserviceapi.Last10TxResponse{
|
||||||
dataserviceapi.Last10TxResponse{
|
dataserviceapi.Last10TxResponse{
|
||||||
Sender: testutil.AliceChecksum,
|
Sender: apimocks.AliceChecksum,
|
||||||
Recipient: testutil.BobChecksum,
|
Recipient: apimocks.BobChecksum,
|
||||||
TransferValue: strconv.Itoa(txValue),
|
TransferValue: strconv.Itoa(txValue),
|
||||||
ContractAddress: tokenAddress,
|
ContractAddress: tokenAddress,
|
||||||
TxHash: txHash,
|
TxHash: txHash,
|
||||||
DateBlock: time.Unix(txTimestamp, 0),
|
DateBlock: time.Unix(txTimestamp, 0),
|
||||||
TokenSymbol: tokenSymbol,
|
TokenSymbol: tokenSymbol,
|
||||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
api.VoucherDataContent = &models.VoucherDataResult{
|
api.VoucherDataContent = &models.VoucherDataResult{
|
||||||
TokenSymbol: tokenSymbol,
|
TokenSymbol: tokenSymbol,
|
||||||
TokenName: tokenName,
|
TokenName: tokenName,
|
||||||
//TokenDecimals: strconv.Itoa(tokenDecimals),
|
//TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||||
TokenDecimals: tokenDecimals,
|
TokenDecimals: tokenDecimals,
|
||||||
SinkAddress: sinkAddress,
|
SinkAddress: sinkAddress,
|
||||||
}
|
}
|
||||||
api.VouchersContent = []dataserviceapi.TokenHoldings{
|
api.VouchersContent = []dataserviceapi.TokenHoldings{
|
||||||
dataserviceapi.TokenHoldings{
|
dataserviceapi.TokenHoldings{
|
||||||
ContractAddress: tokenAddress,
|
ContractAddress: tokenAddress,
|
||||||
TokenSymbol: tokenSymbol,
|
TokenSymbol: tokenSymbol,
|
||||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||||
Balance: strconv.Itoa(tokenBalance),
|
Balance: strconv.Itoa(tokenBalance),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
lookup.Api = api
|
lookup.Api = api
|
||||||
@ -131,14 +132,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(testutil.AliceChecksum)
|
alice, err := hex.NormalizeHex(apimocks.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(testutil.AliceSession))
|
err = userDb.Put(ctx, storedb.PackKey(storedb.DATA_PUBLIC_KEY_REVERSE, []byte{}), []byte(apimocks.AliceSession))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -159,7 +160,7 @@ func TestHandleMsg(t *testing.T) {
|
|||||||
"to": "%s",
|
"to": "%s",
|
||||||
"value": "%d"
|
"value": "%d"
|
||||||
}
|
}
|
||||||
}`, txBlock, tokenAddress, txTimestamp, txHash, testutil.AliceChecksum, testutil.BobChecksum, txValue)
|
}`, txBlock, tokenAddress, txTimestamp, txHash, apimocks.AliceChecksum, apimocks.BobChecksum, txValue)
|
||||||
msg := &testMsg{
|
msg := &testMsg{
|
||||||
data: []byte(data),
|
data: []byte(data),
|
||||||
}
|
}
|
||||||
@ -168,7 +169,7 @@ func TestHandleMsg(t *testing.T) {
|
|||||||
userStore := store.UserDataStore{
|
userStore := store.UserDataStore{
|
||||||
Db: userDb,
|
Db: userDb,
|
||||||
}
|
}
|
||||||
v, err := userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_ACTIVE_SYM)
|
v, err := userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_ACTIVE_SYM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -176,18 +177,18 @@ 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, testutil.AliceSession, storedb.DATA_ACTIVE_BAL)
|
v, err = userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_ACTIVE_BAL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
fmts := fmt.Sprintf("%%1.%df", tokenDecimals)
|
fmts := fmt.Sprintf("%%1.%df", tokenDecimals)
|
||||||
expect := fmt.Sprintf(fmts, float64(tokenBalance) / math.Pow(10, tokenDecimals))
|
expect := fmt.Sprintf(fmts, float64(tokenBalance)/math.Pow(10, tokenDecimals))
|
||||||
//if !bytes.Equal(v, []byte(strconv.Itoa(tokenBalance))) {
|
|
||||||
if !bytes.Equal(v, []byte(expect)) {
|
if !bytes.Equal(v, []byte(expect)) {
|
||||||
t.Fatalf("expected '%d', got %s", tokenBalance, v)
|
t.Fatalf("expected '%d', got %s", tokenBalance, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err = userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_TRANSACTIONS)
|
v, err = userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_TRANSACTIONS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -195,12 +196,11 @@ func TestHandleMsg(t *testing.T) {
|
|||||||
t.Fatal("no transaction data")
|
t.Fatal("no transaction data")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mh, err := application.NewMenuHandlers(nil, userStore, nil, testutil.ReplaceSeparatorFunc)
|
||||||
mh, err := application.NewMenuHandlers(nil, userStore, nil, nil, testutil.ReplaceSeparatorFunc)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ctx = context.WithValue(ctx, "SessionId", testutil.AliceSession)
|
ctx = context.WithValue(ctx, "SessionId", apimocks.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)
|
||||||
@ -209,14 +209,4 @@ func TestHandleMsg(t *testing.T) {
|
|||||||
if rrs.Content != expect {
|
if rrs.Content != expect {
|
||||||
t.Fatalf("expected '%v', got '%v'", expect, rrs.Content)
|
t.Fatalf("expected '%v', got '%v'", expect, rrs.Content)
|
||||||
}
|
}
|
||||||
// userDb.SetPrefix(event.DATATYPE_USERSUB)
|
|
||||||
// userDb.SetSession(testutil.AliceSession)
|
|
||||||
// k := append([]byte("vouchers"), []byte("sym")...)
|
|
||||||
// v, err = userDb.Get(ctx, k)
|
|
||||||
// if err != nil {
|
|
||||||
// t.Fatal(err)
|
|
||||||
// }
|
|
||||||
// if !bytes.Contains(v, []byte(fmt.Sprintf("1:%s", tokenSymbol))) {
|
|
||||||
// t.Fatalf("expected '1:%s', got %s", tokenSymbol, v)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ func NewRouter(handler *apievent.EventsHandler) *Router {
|
|||||||
//
|
//
|
||||||
// An error will be returned if no handler can be found, or if the resolved
|
// An error will be returned if no handler can be found, or if the resolved
|
||||||
// handler fails to successfully execute.
|
// handler fails to successfully execute.
|
||||||
func(r *Router) Route(ctx context.Context, gev *geEvent.Event) error {
|
func (r *Router) Route(ctx context.Context, gev *geEvent.Event) error {
|
||||||
logg.DebugCtxf(ctx, "have event", "ev", gev)
|
logg.DebugCtxf(ctx, "have event", "ev", gev)
|
||||||
evCC, ok := asCustodialRegistrationEvent(gev)
|
evCC, ok := asCustodialRegistrationEvent(gev)
|
||||||
if ok {
|
if ok {
|
||||||
|
@ -34,7 +34,6 @@ func formatTransaction(tag string, idx int, item any) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// waiter to check whether object is available on dependency endpoints.
|
// waiter to check whether object is available on dependency endpoints.
|
||||||
func updateWait(ctx context.Context) error {
|
func updateWait(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
|
@ -9,68 +9,68 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
|
||||||
"git.defalsify.org/vise.git/db"
|
"git.defalsify.org/vise.git/db"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/config"
|
"git.grassecon.net/grassrootseconomics/common/hex"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
|
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
|
||||||
|
apimocks "git.grassecon.net/grassrootseconomics/sarafu-api/testutil/mocks"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/config"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/internal/testutil"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/lookup"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
||||||
|
viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||||
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/lookup"
|
|
||||||
"git.grassecon.net/grassrootseconomics/common/hex"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/internal/testutil"
|
|
||||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
|
||||||
viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks"
|
"git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks"
|
||||||
|
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
txBlock = 42
|
txBlock = 42
|
||||||
tokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a"
|
tokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a"
|
||||||
tokenSymbol = "FOO"
|
tokenSymbol = "FOO"
|
||||||
tokenName = "Foo Token"
|
tokenName = "Foo Token"
|
||||||
tokenDecimals = 6
|
tokenDecimals = 6
|
||||||
txValue = 1337
|
txValue = 1337
|
||||||
tokenBalance = 362436
|
tokenBalance = 362436
|
||||||
txTimestamp = 1730592500
|
txTimestamp = 1730592500
|
||||||
txHash = "0xabcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789"
|
txHash = "0xabcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789"
|
||||||
sinkAddress = "0xb42C5920014eE152F2225285219407938469BBfA"
|
sinkAddress = "0xb42C5920014eE152F2225285219407938469BBfA"
|
||||||
bogusSym = "/-21380u"
|
bogusSym = "/-21380u"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func TestTokenTransfer(t *testing.T) {
|
func TestTokenTransfer(t *testing.T) {
|
||||||
err := config.LoadConfig()
|
err := config.LoadConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
api := &testutil.MockApi{}
|
api := &apimocks.MockApi{}
|
||||||
api.TransactionsContent = []dataserviceapi.Last10TxResponse{
|
api.TransactionsContent = []dataserviceapi.Last10TxResponse{
|
||||||
dataserviceapi.Last10TxResponse{
|
dataserviceapi.Last10TxResponse{
|
||||||
Sender: testutil.AliceChecksum,
|
Sender: apimocks.AliceChecksum,
|
||||||
Recipient: testutil.BobChecksum,
|
Recipient: apimocks.BobChecksum,
|
||||||
TransferValue: strconv.Itoa(txValue),
|
TransferValue: strconv.Itoa(txValue),
|
||||||
ContractAddress: tokenAddress,
|
ContractAddress: tokenAddress,
|
||||||
TxHash: txHash,
|
TxHash: txHash,
|
||||||
DateBlock: time.Unix(txTimestamp, 0),
|
DateBlock: time.Unix(txTimestamp, 0),
|
||||||
TokenSymbol: tokenSymbol,
|
TokenSymbol: tokenSymbol,
|
||||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
api.VoucherDataContent = &models.VoucherDataResult{
|
api.VoucherDataContent = &models.VoucherDataResult{
|
||||||
TokenSymbol: tokenSymbol,
|
TokenSymbol: tokenSymbol,
|
||||||
TokenName: tokenName,
|
TokenName: tokenName,
|
||||||
//TokenDecimals: strconv.Itoa(tokenDecimals),
|
//TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||||
TokenDecimals: tokenDecimals,
|
TokenDecimals: tokenDecimals,
|
||||||
SinkAddress: sinkAddress,
|
SinkAddress: sinkAddress,
|
||||||
}
|
}
|
||||||
api.VouchersContent = []dataserviceapi.TokenHoldings{
|
api.VouchersContent = []dataserviceapi.TokenHoldings{
|
||||||
dataserviceapi.TokenHoldings{
|
dataserviceapi.TokenHoldings{
|
||||||
ContractAddress: tokenAddress,
|
ContractAddress: tokenAddress,
|
||||||
TokenSymbol: tokenSymbol,
|
TokenSymbol: tokenSymbol,
|
||||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||||
Balance: strconv.Itoa(tokenBalance),
|
Balance: strconv.Itoa(tokenBalance),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
lookup.Api = api
|
lookup.Api = api
|
||||||
@ -80,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(testutil.AliceChecksum)
|
alice, err := hex.NormalizeHex(apimocks.AliceChecksum)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -88,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(testutil.AliceSession))
|
err = userDb.Put(ctx, storedb.PackKey(storedb.DATA_PUBLIC_KEY_REVERSE, []byte{}), []byte(apimocks.AliceSession))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -97,8 +97,8 @@ func TestTokenTransfer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ev := &apievent.EventTokenTransfer{
|
ev := &apievent.EventTokenTransfer{
|
||||||
From: testutil.BobChecksum,
|
From: apimocks.BobChecksum,
|
||||||
To: testutil.AliceChecksum,
|
To: apimocks.AliceChecksum,
|
||||||
Value: txValue,
|
Value: txValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ func TestTokenTransfer(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_ACTIVE_SYM)
|
v, err := userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_ACTIVE_SYM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -116,18 +116,18 @@ 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, testutil.AliceSession, storedb.DATA_ACTIVE_BAL)
|
v, err = userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_ACTIVE_BAL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
//if !bytes.Equal(v, []byte(strconv.Itoa(tokenBalance))) {
|
//if !bytes.Equal(v, []byte(strconv.Itoa(tokenBalance))) {
|
||||||
fmts := fmt.Sprintf("%%1.%df", tokenDecimals)
|
fmts := fmt.Sprintf("%%1.%df", tokenDecimals)
|
||||||
expect := fmt.Sprintf(fmts, float64(tokenBalance) / math.Pow(10, tokenDecimals))
|
expect := fmt.Sprintf(fmts, float64(tokenBalance)/math.Pow(10, tokenDecimals))
|
||||||
if !bytes.Equal(v, []byte(expect)) {
|
if !bytes.Equal(v, []byte(expect)) {
|
||||||
t.Fatalf("expected '%s', got %s", expect, v)
|
t.Fatalf("expected '%s', got %s", expect, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err = userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_TRANSACTIONS)
|
v, err = userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_TRANSACTIONS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -135,11 +135,11 @@ func TestTokenTransfer(t *testing.T) {
|
|||||||
t.Fatal("no transaction data")
|
t.Fatal("no transaction data")
|
||||||
}
|
}
|
||||||
|
|
||||||
mh, err := application.NewMenuHandlers(nil, userStore, nil, nil, testutil.ReplaceSeparatorFunc)
|
mh, err := application.NewMenuHandlers(nil, userStore, nil, testutil.ReplaceSeparatorFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ctx = context.WithValue(ctx, "SessionId", testutil.AliceSession)
|
ctx = context.WithValue(ctx, "SessionId", apimocks.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)
|
||||||
@ -156,50 +156,49 @@ func TestTokenMint(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
api := &testutil.MockApi{}
|
api := &apimocks.MockApi{}
|
||||||
api.TransactionsContent = []dataserviceapi.Last10TxResponse{
|
api.TransactionsContent = []dataserviceapi.Last10TxResponse{
|
||||||
dataserviceapi.Last10TxResponse{
|
dataserviceapi.Last10TxResponse{
|
||||||
Sender: testutil.AliceChecksum,
|
Sender: apimocks.AliceChecksum,
|
||||||
Recipient: testutil.BobChecksum,
|
Recipient: apimocks.BobChecksum,
|
||||||
TransferValue: strconv.Itoa(txValue),
|
TransferValue: strconv.Itoa(txValue),
|
||||||
ContractAddress: tokenAddress,
|
ContractAddress: tokenAddress,
|
||||||
TxHash: txHash,
|
TxHash: txHash,
|
||||||
DateBlock: time.Unix(txTimestamp, 0),
|
DateBlock: time.Unix(txTimestamp, 0),
|
||||||
TokenSymbol: tokenSymbol,
|
TokenSymbol: tokenSymbol,
|
||||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
api.VoucherDataContent = &models.VoucherDataResult{
|
api.VoucherDataContent = &models.VoucherDataResult{
|
||||||
TokenSymbol: tokenSymbol,
|
TokenSymbol: tokenSymbol,
|
||||||
TokenName: tokenName,
|
TokenName: tokenName,
|
||||||
//TokenDecimals: strconv.Itoa(tokenDecimals),
|
//TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||||
TokenDecimals: tokenDecimals,
|
TokenDecimals: tokenDecimals,
|
||||||
SinkAddress: sinkAddress,
|
SinkAddress: sinkAddress,
|
||||||
}
|
}
|
||||||
api.VouchersContent = []dataserviceapi.TokenHoldings{
|
api.VouchersContent = []dataserviceapi.TokenHoldings{
|
||||||
dataserviceapi.TokenHoldings{
|
dataserviceapi.TokenHoldings{
|
||||||
ContractAddress: tokenAddress,
|
ContractAddress: tokenAddress,
|
||||||
TokenSymbol: tokenSymbol,
|
TokenSymbol: tokenSymbol,
|
||||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||||
Balance: strconv.Itoa(tokenBalance),
|
Balance: strconv.Itoa(tokenBalance),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
lookup.Api = api
|
lookup.Api = api
|
||||||
|
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
storageService := mocks.NewMemStorageService(ctx)
|
storageService := mocks.NewMemStorageService(ctx)
|
||||||
eu := viseevent.NewEventsUpdater(api, storageService)
|
eu := viseevent.NewEventsUpdater(api, storageService)
|
||||||
userDb := storageService.Db
|
userDb := storageService.Db
|
||||||
|
|
||||||
alice, err := hex.NormalizeHex(testutil.AliceChecksum)
|
alice, err := hex.NormalizeHex(apimocks.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(testutil.AliceSession))
|
err = userDb.Put(ctx, storedb.PackKey(storedb.DATA_PUBLIC_KEY_REVERSE, []byte{}), []byte(apimocks.AliceSession))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -208,7 +207,7 @@ func TestTokenMint(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ev := &apievent.EventTokenMint{
|
ev := &apievent.EventTokenMint{
|
||||||
To: testutil.AliceChecksum,
|
To: apimocks.AliceChecksum,
|
||||||
Value: txValue,
|
Value: txValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +217,7 @@ func TestTokenMint(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_ACTIVE_SYM)
|
v, err := userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_ACTIVE_SYM)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -226,18 +225,18 @@ 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, testutil.AliceSession, storedb.DATA_ACTIVE_BAL)
|
v, err = userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_ACTIVE_BAL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
fmts := fmt.Sprintf("%%1.%df", tokenDecimals)
|
fmts := fmt.Sprintf("%%1.%df", tokenDecimals)
|
||||||
expect := fmt.Sprintf(fmts, float64(tokenBalance) / math.Pow(10, tokenDecimals))
|
expect := fmt.Sprintf(fmts, float64(tokenBalance)/math.Pow(10, tokenDecimals))
|
||||||
//if !bytes.Equal(v, []byte(strconv.Itoa(tokenBalance))) {
|
|
||||||
if !bytes.Equal(v, []byte(expect)) {
|
if !bytes.Equal(v, []byte(expect)) {
|
||||||
t.Fatalf("expected '%d', got %s", tokenBalance, v)
|
t.Fatalf("expected '%d', got %s", tokenBalance, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err = userStore.ReadEntry(ctx, testutil.AliceSession, storedb.DATA_TRANSACTIONS)
|
v, err = userStore.ReadEntry(ctx, apimocks.AliceSession, storedb.DATA_TRANSACTIONS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -245,11 +244,11 @@ func TestTokenMint(t *testing.T) {
|
|||||||
t.Fatal("no transaction data")
|
t.Fatal("no transaction data")
|
||||||
}
|
}
|
||||||
|
|
||||||
mh, err := application.NewMenuHandlers(nil, userStore, nil, nil, testutil.ReplaceSeparatorFunc)
|
mh, err := application.NewMenuHandlers(nil, userStore, nil, testutil.ReplaceSeparatorFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ctx = context.WithValue(ctx, "SessionId", testutil.AliceSession)
|
ctx = context.WithValue(ctx, "SessionId", apimocks.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)
|
||||||
|
16
go.mod
16
go.mod
@ -3,11 +3,11 @@ module git.grassecon.net/grassrootseconomics/sarafu-vise-events
|
|||||||
go 1.23.4
|
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.20250120121301-10739fb4a8c9
|
||||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05
|
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250113213645-7c697394b5e7
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250114070250-ce9a263b40a3
|
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250124084723-9a094f440f86
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250113213325-5228aef0889b
|
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122123424-6749c632b0a2
|
||||||
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
|
||||||
github.com/nats-io/nats.go v1.37.0
|
github.com/nats-io/nats.go v1.37.0
|
||||||
@ -16,7 +16,9 @@ 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/gofrs/uuid v4.4.0+incompatible // 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
|
||||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
@ -28,10 +30,14 @@ 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
|
||||||
)
|
)
|
||||||
|
30
go.sum
30
go.sum
@ -1,13 +1,13 @@
|
|||||||
git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d h1:bPAOVZOX4frSGhfOdcj7kc555f8dc9DmMd2YAyC2AMw=
|
git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9 h1:sPcqXQcywxA8W3W+9qQncLPmsrgqTIlec7vmD4/7vyA=
|
||||||
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.20250120121301-10739fb4a8c9/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-20250121134736-ba8cbbccea7d h1:5mzLas+jxTUtusOKx4XvU+n2QvrV/mH17MnJRy46siQ=
|
||||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250113213645-7c697394b5e7 h1:P+Bi5jcQbnCrLnKNC5k8XDTBsocyZTVifqDyZY6d0w8=
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805 h1:deGnqf4YCsbxhXgjFEjYjTUCvciLEmI26T9IysRsQXY=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250113213645-7c697394b5e7/go.mod h1:X9aQF93xw3vcW2QftJfzLewvbotRM0U00DRtdmFw294=
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805/go.mod h1:9bc3d//Qqm11hz7GYRdQc1Uan+0GJIOpvRBbv8cHMu8=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250114070250-ce9a263b40a3 h1:E4TKaXKJbPKbN6UtbqaJbB90aSo64FzwgOhZV9n3XKI=
|
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250124084723-9a094f440f86 h1:wqISfQKU7nJgKVGGMm/b0M46tMRmvkBc+riLOWzd7ss=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250114070250-ce9a263b40a3/go.mod h1:1WryKcUnFI1J4Jl3wZJ4DX/7lnew+0PDY8xWvqc46UI=
|
git.grassecon.net/grassrootseconomics/sarafu-vise v0.0.0-20250124084723-9a094f440f86/go.mod h1:kt/HZVYJZoQLzJtHKSfltZu7+khRUUq5P98PtPpKbUc=
|
||||||
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.20250122123424-6749c632b0a2 h1:ON77G5K0JNuwPb5JT/hRfF6G6+xstlBQgEIEzWydnhg=
|
||||||
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.20250122123424-6749c632b0a2/go.mod h1:pjKp9L/ZsWW3kMB0UoIl1yv9TBIuU33mn9Aghxp7vGk=
|
||||||
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
|
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
|
||||||
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
|
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
|
||||||
github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g=
|
github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g=
|
||||||
@ -21,6 +21,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
|
|||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
|
github.com/fxamacker/cbor/v2 v2.4.0 h1:ri0ArlOR+5XunOP8CRUowT0pSJOwhW098ZCUyskZD88=
|
||||||
github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
|
github.com/fxamacker/cbor/v2 v2.4.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
|
||||||
|
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
|
||||||
|
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||||
github.com/grassrootseconomics/eth-custodial v1.3.0-beta h1:twrMBhl89GqDUL9PlkzQxMP/6OST1BByrNDj+rqXDmU=
|
github.com/grassrootseconomics/eth-custodial v1.3.0-beta h1:twrMBhl89GqDUL9PlkzQxMP/6OST1BByrNDj+rqXDmU=
|
||||||
github.com/grassrootseconomics/eth-custodial v1.3.0-beta/go.mod h1:7uhRcdnJplX4t6GKCEFkbeDhhjlcaGJeJqevbcvGLZo=
|
github.com/grassrootseconomics/eth-custodial v1.3.0-beta/go.mod h1:7uhRcdnJplX4t6GKCEFkbeDhhjlcaGJeJqevbcvGLZo=
|
||||||
github.com/grassrootseconomics/eth-tracker v1.3.0-rc h1:iYe2rwCBrU5O8x0+HSJRjcPT1h68k/uGd3i/cJJQuTQ=
|
github.com/grassrootseconomics/eth-tracker v1.3.0-rc h1:iYe2rwCBrU5O8x0+HSJRjcPT1h68k/uGd3i/cJJQuTQ=
|
||||||
@ -43,6 +45,10 @@ 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=
|
||||||
@ -58,6 +64,8 @@ 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=
|
||||||
@ -76,6 +84,8 @@ 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=
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
@ -1,8 +1,8 @@
|
|||||||
package lookup
|
package lookup
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
Reference in New Issue
Block a user