Gofmt, remove commented code
This commit is contained in:
parent
7e2d6b8d09
commit
b69115caaa
@ -9,15 +9,15 @@ import (
|
||||
"syscall"
|
||||
|
||||
"git.defalsify.org/vise.git/logging"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/config"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/event/nats"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/lookup"
|
||||
viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||
)
|
||||
|
||||
var (
|
||||
logg = logging.NewVanilla()
|
||||
logg = logging.NewVanilla()
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -1,21 +1,21 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
|
||||
apiconfig "git.grassecon.net/grassrootseconomics/sarafu-api/config"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/env"
|
||||
)
|
||||
|
||||
var (
|
||||
JetstreamURL string
|
||||
JetstreamURL string
|
||||
JetstreamClientName string
|
||||
Apply = config.Apply
|
||||
GetConns = config.GetConns
|
||||
Apply = config.Apply
|
||||
GetConns = config.GetConns
|
||||
)
|
||||
|
||||
const (
|
||||
defaultJetstreamURL string = "localhost:4222"
|
||||
defaultJetstreamURL string = "localhost:4222"
|
||||
defaultJetstreamClientName string = "omnom"
|
||||
)
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
geEvent "github.com/grassrootseconomics/eth-tracker/pkg/event"
|
||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||
geEvent "github.com/grassrootseconomics/eth-tracker/pkg/event"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -4,20 +4,19 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"git.defalsify.org/vise.git/cache"
|
||||
"git.defalsify.org/vise.git/db"
|
||||
"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"
|
||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||
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"
|
||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks"
|
||||
)
|
||||
|
||||
|
||||
func TestCustodialRegistration(t *testing.T) {
|
||||
err := config.LoadConfig()
|
||||
if err != nil {
|
||||
|
@ -5,13 +5,13 @@ import (
|
||||
"encoding/json"
|
||||
"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"
|
||||
"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 (
|
||||
@ -23,10 +23,10 @@ var (
|
||||
// Extends Router.
|
||||
type NatsSubscription struct {
|
||||
*event.Router
|
||||
ctx context.Context
|
||||
ctx context.Context
|
||||
conn *nats.Conn
|
||||
js jetstream.JetStream
|
||||
cs jetstream.Consumer
|
||||
js jetstream.JetStream
|
||||
cs jetstream.Consumer
|
||||
cctx jetstream.ConsumeContext
|
||||
}
|
||||
|
||||
@ -37,13 +37,13 @@ func NewNatsSubscription(handler *apievent.EventsHandler) *NatsSubscription {
|
||||
}
|
||||
}
|
||||
|
||||
// Connect sets up the connection to the nats server and a consumer for the
|
||||
// Connect sets up the connection to the nats server and a consumer for the
|
||||
// "Jetstream".
|
||||
//
|
||||
// Fails if connection fails or the "Jetstream" consumer cannot be set up.
|
||||
//
|
||||
// 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
|
||||
|
||||
// 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
|
||||
}
|
||||
n.cs, err = n.js.CreateConsumer(ctx, "TRACKER", jetstream.ConsumerConfig{
|
||||
Name: config.JetstreamClientName,
|
||||
Durable: config.JetstreamClientName,
|
||||
Name: config.JetstreamClientName,
|
||||
Durable: config.JetstreamClientName,
|
||||
FilterSubjects: []string{"TRACKER.*"},
|
||||
})
|
||||
if err != nil {
|
||||
@ -71,14 +71,14 @@ func(n *NatsSubscription) Connect(ctx context.Context, connStr string) error {
|
||||
logg.DebugCtxf(ctx, "nats connected, starting consumer", "status", n.conn.Status(), "server", serverInfo)
|
||||
n.cctx, err = n.cs.Consume(n.handleEvent)
|
||||
if err != nil {
|
||||
return err
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close cleanly brings down the nats and jetstream connection.
|
||||
func(n *NatsSubscription) Close() error {
|
||||
func (n *NatsSubscription) Close() error {
|
||||
n.cctx.Stop()
|
||||
select {
|
||||
case <-n.cctx.Closed():
|
||||
@ -88,7 +88,7 @@ func(n *NatsSubscription) Close() error {
|
||||
}
|
||||
|
||||
// jetstream message handler and acknowledger.
|
||||
func(n *NatsSubscription) handleEvent(m jetstream.Msg) {
|
||||
func (n *NatsSubscription) handleEvent(m jetstream.Msg) {
|
||||
var ev geEvent.Event
|
||||
|
||||
logg.DebugCtxf(n.ctx, "have msg", "msg", m)
|
||||
|
@ -9,34 +9,34 @@ import (
|
||||
"testing"
|
||||
"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.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/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"
|
||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||
"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 (
|
||||
txBlock = 42
|
||||
tokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a"
|
||||
tokenSymbol = "FOO"
|
||||
tokenName = "Foo Token"
|
||||
txBlock = 42
|
||||
tokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a"
|
||||
tokenSymbol = "FOO"
|
||||
tokenName = "Foo Token"
|
||||
tokenDecimals = 6
|
||||
txValue = 1337
|
||||
tokenBalance = 362436
|
||||
txTimestamp = 1730592500
|
||||
txHash = "0xabcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789"
|
||||
sinkAddress = "0xb42C5920014eE152F2225285219407938469BBfA"
|
||||
txValue = 1337
|
||||
tokenBalance = 362436
|
||||
txTimestamp = 1730592500
|
||||
txHash = "0xabcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789"
|
||||
sinkAddress = "0xb42C5920014eE152F2225285219407938469BBfA"
|
||||
)
|
||||
|
||||
// TODO: jetstream, would have been nice of you to provide an easier way to make a mock msg
|
||||
@ -44,51 +44,51 @@ type testMsg struct {
|
||||
data []byte
|
||||
}
|
||||
|
||||
func(m *testMsg) Ack() error {
|
||||
func (m *testMsg) Ack() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func(m *testMsg) Nak() error {
|
||||
func (m *testMsg) Nak() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func(m *testMsg) NakWithDelay(time.Duration) error {
|
||||
func (m *testMsg) NakWithDelay(time.Duration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func(m *testMsg) Data() []byte {
|
||||
func (m *testMsg) Data() []byte {
|
||||
return m.data
|
||||
}
|
||||
|
||||
func(m *testMsg) Reply() string {
|
||||
func (m *testMsg) Reply() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func(m *testMsg) Subject() string {
|
||||
func (m *testMsg) Subject() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func(m *testMsg) Term() error {
|
||||
func (m *testMsg) Term() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func(m *testMsg) TermWithReason(string) error {
|
||||
func (m *testMsg) TermWithReason(string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func(m *testMsg) DoubleAck(ctx context.Context) error {
|
||||
func (m *testMsg) DoubleAck(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func(m *testMsg) Headers() nats.Header {
|
||||
func (m *testMsg) Headers() nats.Header {
|
||||
return nats.Header{}
|
||||
}
|
||||
|
||||
func(m *testMsg) InProgress() error {
|
||||
func (m *testMsg) InProgress() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func(m *testMsg) Metadata() (*jetstream.MsgMetadata, error) {
|
||||
func (m *testMsg) Metadata() (*jetstream.MsgMetadata, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@ -101,29 +101,29 @@ func TestHandleMsg(t *testing.T) {
|
||||
api := &apimocks.MockApi{}
|
||||
api.TransactionsContent = []dataserviceapi.Last10TxResponse{
|
||||
dataserviceapi.Last10TxResponse{
|
||||
Sender: apimocks.AliceChecksum,
|
||||
Recipient: apimocks.BobChecksum,
|
||||
TransferValue: strconv.Itoa(txValue),
|
||||
Sender: apimocks.AliceChecksum,
|
||||
Recipient: apimocks.BobChecksum,
|
||||
TransferValue: strconv.Itoa(txValue),
|
||||
ContractAddress: tokenAddress,
|
||||
TxHash: txHash,
|
||||
DateBlock: time.Unix(txTimestamp, 0),
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
TxHash: txHash,
|
||||
DateBlock: time.Unix(txTimestamp, 0),
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
},
|
||||
}
|
||||
api.VoucherDataContent = &models.VoucherDataResult{
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenName: tokenName,
|
||||
TokenName: tokenName,
|
||||
//TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
TokenDecimals: tokenDecimals,
|
||||
SinkAddress: sinkAddress,
|
||||
SinkAddress: sinkAddress,
|
||||
}
|
||||
api.VouchersContent = []dataserviceapi.TokenHoldings{
|
||||
dataserviceapi.TokenHoldings{
|
||||
ContractAddress: tokenAddress,
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
Balance: strconv.Itoa(tokenBalance),
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
Balance: strconv.Itoa(tokenBalance),
|
||||
},
|
||||
}
|
||||
lookup.Api = api
|
||||
@ -182,8 +182,8 @@ func TestHandleMsg(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmts := fmt.Sprintf("%%1.%df", tokenDecimals)
|
||||
expect := fmt.Sprintf(fmts, float64(tokenBalance) / math.Pow(10, tokenDecimals))
|
||||
//if !bytes.Equal(v, []byte(strconv.Itoa(tokenBalance))) {
|
||||
expect := fmt.Sprintf(fmts, float64(tokenBalance)/math.Pow(10, tokenDecimals))
|
||||
|
||||
if !bytes.Equal(v, []byte(expect)) {
|
||||
t.Fatalf("expected '%d', got %s", tokenBalance, v)
|
||||
}
|
||||
@ -196,7 +196,6 @@ func TestHandleMsg(t *testing.T) {
|
||||
t.Fatal("no transaction data")
|
||||
}
|
||||
|
||||
|
||||
mh, err := application.NewMenuHandlers(nil, userStore, nil, testutil.ReplaceSeparatorFunc)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -210,14 +209,4 @@ func TestHandleMsg(t *testing.T) {
|
||||
if rrs.Content != expect {
|
||||
t.Fatalf("expected '%v', got '%v'", expect, rrs.Content)
|
||||
}
|
||||
// userDb.SetPrefix(event.DATATYPE_USERSUB)
|
||||
// userDb.SetSession(apimocks.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
|
||||
// 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)
|
||||
evCC, ok := asCustodialRegistrationEvent(gev)
|
||||
if ok {
|
||||
|
@ -34,7 +34,6 @@ func formatTransaction(tag string, idx int, item any) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
// waiter to check whether object is available on dependency endpoints.
|
||||
func updateWait(ctx context.Context) error {
|
||||
return nil
|
||||
|
@ -9,37 +9,36 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||
"git.defalsify.org/vise.git/db"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise-events/config"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
||||
"git.grassecon.net/grassrootseconomics/common/hex"
|
||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||
"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"
|
||||
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"
|
||||
apimocks "git.grassecon.net/grassrootseconomics/sarafu-api/testutil/mocks"
|
||||
viseevent "git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/mocks"
|
||||
dataserviceapi "github.com/grassrootseconomics/ussd-data-service/pkg/api"
|
||||
)
|
||||
|
||||
const (
|
||||
txBlock = 42
|
||||
tokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a"
|
||||
tokenSymbol = "FOO"
|
||||
tokenName = "Foo Token"
|
||||
txBlock = 42
|
||||
tokenAddress = "0x765DE816845861e75A25fCA122bb6898B8B1282a"
|
||||
tokenSymbol = "FOO"
|
||||
tokenName = "Foo Token"
|
||||
tokenDecimals = 6
|
||||
txValue = 1337
|
||||
tokenBalance = 362436
|
||||
txTimestamp = 1730592500
|
||||
txHash = "0xabcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789"
|
||||
sinkAddress = "0xb42C5920014eE152F2225285219407938469BBfA"
|
||||
bogusSym = "/-21380u"
|
||||
txValue = 1337
|
||||
tokenBalance = 362436
|
||||
txTimestamp = 1730592500
|
||||
txHash = "0xabcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789"
|
||||
sinkAddress = "0xb42C5920014eE152F2225285219407938469BBfA"
|
||||
bogusSym = "/-21380u"
|
||||
)
|
||||
|
||||
|
||||
func TestTokenTransfer(t *testing.T) {
|
||||
err := config.LoadConfig()
|
||||
if err != nil {
|
||||
@ -49,29 +48,29 @@ func TestTokenTransfer(t *testing.T) {
|
||||
api := &apimocks.MockApi{}
|
||||
api.TransactionsContent = []dataserviceapi.Last10TxResponse{
|
||||
dataserviceapi.Last10TxResponse{
|
||||
Sender: apimocks.AliceChecksum,
|
||||
Recipient: apimocks.BobChecksum,
|
||||
TransferValue: strconv.Itoa(txValue),
|
||||
Sender: apimocks.AliceChecksum,
|
||||
Recipient: apimocks.BobChecksum,
|
||||
TransferValue: strconv.Itoa(txValue),
|
||||
ContractAddress: tokenAddress,
|
||||
TxHash: txHash,
|
||||
DateBlock: time.Unix(txTimestamp, 0),
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
TxHash: txHash,
|
||||
DateBlock: time.Unix(txTimestamp, 0),
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
},
|
||||
}
|
||||
api.VoucherDataContent = &models.VoucherDataResult{
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenName: tokenName,
|
||||
TokenName: tokenName,
|
||||
//TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
TokenDecimals: tokenDecimals,
|
||||
SinkAddress: sinkAddress,
|
||||
SinkAddress: sinkAddress,
|
||||
}
|
||||
api.VouchersContent = []dataserviceapi.TokenHoldings{
|
||||
dataserviceapi.TokenHoldings{
|
||||
ContractAddress: tokenAddress,
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
Balance: strconv.Itoa(tokenBalance),
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
Balance: strconv.Itoa(tokenBalance),
|
||||
},
|
||||
}
|
||||
lookup.Api = api
|
||||
@ -98,8 +97,8 @@ func TestTokenTransfer(t *testing.T) {
|
||||
}
|
||||
|
||||
ev := &apievent.EventTokenTransfer{
|
||||
From: apimocks.BobChecksum,
|
||||
To: apimocks.AliceChecksum,
|
||||
From: apimocks.BobChecksum,
|
||||
To: apimocks.AliceChecksum,
|
||||
Value: txValue,
|
||||
}
|
||||
|
||||
@ -123,7 +122,7 @@ func TestTokenTransfer(t *testing.T) {
|
||||
}
|
||||
//if !bytes.Equal(v, []byte(strconv.Itoa(tokenBalance))) {
|
||||
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)) {
|
||||
t.Fatalf("expected '%s', got %s", expect, v)
|
||||
}
|
||||
@ -160,34 +159,33 @@ func TestTokenMint(t *testing.T) {
|
||||
api := &apimocks.MockApi{}
|
||||
api.TransactionsContent = []dataserviceapi.Last10TxResponse{
|
||||
dataserviceapi.Last10TxResponse{
|
||||
Sender: apimocks.AliceChecksum,
|
||||
Recipient: apimocks.BobChecksum,
|
||||
TransferValue: strconv.Itoa(txValue),
|
||||
Sender: apimocks.AliceChecksum,
|
||||
Recipient: apimocks.BobChecksum,
|
||||
TransferValue: strconv.Itoa(txValue),
|
||||
ContractAddress: tokenAddress,
|
||||
TxHash: txHash,
|
||||
DateBlock: time.Unix(txTimestamp, 0),
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
TxHash: txHash,
|
||||
DateBlock: time.Unix(txTimestamp, 0),
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
},
|
||||
}
|
||||
api.VoucherDataContent = &models.VoucherDataResult{
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenName: tokenName,
|
||||
TokenName: tokenName,
|
||||
//TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
TokenDecimals: tokenDecimals,
|
||||
SinkAddress: sinkAddress,
|
||||
SinkAddress: sinkAddress,
|
||||
}
|
||||
api.VouchersContent = []dataserviceapi.TokenHoldings{
|
||||
dataserviceapi.TokenHoldings{
|
||||
ContractAddress: tokenAddress,
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
Balance: strconv.Itoa(tokenBalance),
|
||||
TokenSymbol: tokenSymbol,
|
||||
TokenDecimals: strconv.Itoa(tokenDecimals),
|
||||
Balance: strconv.Itoa(tokenBalance),
|
||||
},
|
||||
}
|
||||
lookup.Api = api
|
||||
|
||||
|
||||
ctx := context.Background()
|
||||
storageService := mocks.NewMemStorageService(ctx)
|
||||
eu := viseevent.NewEventsUpdater(api, storageService)
|
||||
@ -209,7 +207,7 @@ func TestTokenMint(t *testing.T) {
|
||||
}
|
||||
|
||||
ev := &apievent.EventTokenMint{
|
||||
To: apimocks.AliceChecksum,
|
||||
To: apimocks.AliceChecksum,
|
||||
Value: txValue,
|
||||
}
|
||||
|
||||
@ -232,8 +230,8 @@ func TestTokenMint(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmts := fmt.Sprintf("%%1.%df", tokenDecimals)
|
||||
expect := fmt.Sprintf(fmts, float64(tokenBalance) / math.Pow(10, tokenDecimals))
|
||||
//if !bytes.Equal(v, []byte(strconv.Itoa(tokenBalance))) {
|
||||
expect := fmt.Sprintf(fmts, float64(tokenBalance)/math.Pow(10, tokenDecimals))
|
||||
|
||||
if !bytes.Equal(v, []byte(expect)) {
|
||||
t.Fatalf("expected '%d', got %s", tokenBalance, v)
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package lookup
|
||||
|
||||
import (
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||
)
|
||||
|
||||
var (
|
||||
|
Loading…
Reference in New Issue
Block a user