Skip to content

Commit

Permalink
Lints, more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Warehime committed Feb 26, 2024
1 parent e0a8c37 commit 7799d29
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
1 change: 0 additions & 1 deletion protocol/daemons/slinky/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type ClientTestSuite struct {
daemonFlags daemonflags.DaemonFlags
appFlags appflags.Flags
daemonServer *daemonserver.Server
exchangePriceCache *pricefeed_types.MarketToExchangePrices
grpcServer *grpc.Server
pricesMockQueryServer *mocks.QueryServer
wg sync.WaitGroup
Expand Down
1 change: 0 additions & 1 deletion protocol/daemons/slinky/client/market_pair_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,4 @@ func TestMarketPairFetcher(t *testing.T) {
err := fetcher.FetchIdMappings(context.Background())
require.Error(t, err, "test error")
})

}
15 changes: 8 additions & 7 deletions protocol/daemons/slinky/client/price_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ func TestPriceFetcherTestSuite(t *testing.T) {

type PriceFetcherTestSuite struct {
suite.Suite
daemonFlags daemonflags.DaemonFlags
appFlags appflags.Flags
daemonServer *daemonserver.Server
exchangePriceCache *pricefeed_types.MarketToExchangePrices
pricesGrpcServer *grpc.Server
wg sync.WaitGroup
daemonFlags daemonflags.DaemonFlags
appFlags appflags.Flags
daemonServer *daemonserver.Server
pricesGrpcServer *grpc.Server
wg sync.WaitGroup
}

func (p *PriceFetcherTestSuite) SetupTest() {
Expand Down Expand Up @@ -189,7 +188,9 @@ func (p *PriceFetcherTestSuite) TestPriceFetcher() {
logger,
)
p.Require().NoError(fetcher.Start(context.Background()))
p.Require().Errorf(fetcher.FetchPrices(context.Background()), "slinky client returned price %s not parsable as uint64", "abc123")
p.Require().Errorf(
fetcher.FetchPrices(context.Background()),
"slinky client returned price %s not parsable as uint64", "abc123")
fetcher.Stop()
})

Expand Down
3 changes: 2 additions & 1 deletion protocol/lib/slinky/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package slinky

import (
"fmt"
"github.com/skip-mev/slinky/x/oracle/types"
"strings"

"github.com/skip-mev/slinky/x/oracle/types"
)

/*
Expand Down
34 changes: 34 additions & 0 deletions protocol/lib/slinky/utils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package slinky_test

import (
"fmt"
"testing"

"github.com/skip-mev/slinky/x/oracle/types"
"github.com/stretchr/testify/require"

"github.com/dydxprotocol/v4-chain/protocol/lib/slinky"
)

func TestMarketPairToCurrencyPair(t *testing.T) {
testCases := []struct {
mp string
cp types.CurrencyPair
err error
}{
{mp: "FOO-BAR", cp: types.CurrencyPair{Base: "FOO", Quote: "BAR"}, err: nil},
{mp: "FOOBAR", cp: types.CurrencyPair{}, err: fmt.Errorf("incorrectly formatted CurrencyPair: FOOBAR")},
{mp: "FOO/BAR", cp: types.CurrencyPair{}, err: fmt.Errorf("incorrectly formatted CurrencyPair: FOOBAR")},
}
for _, tc := range testCases {
t.Run(fmt.Sprintf("TestMarketPair %s", tc.mp), func(t *testing.T) {
cp, err := slinky.MarketPairToCurrencyPair(tc.mp)
if tc.err != nil {
require.Error(t, err, tc.err)
} else {
require.NoError(t, err)
require.Equal(t, tc.cp, cp)
}
})
}
}

0 comments on commit 7799d29

Please sign in to comment.