Skip to content

Commit

Permalink
feat: update tests running for ci and add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
boodyvo committed Sep 25, 2024
1 parent c2c99a4 commit f9983d0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ vet:
go vet ./...

.PHONY: test
# Find all directories containing go.mod, and run go test for each module, excluding auction-audit
test:
go test -v ./...
find . -name "go.mod" -not -path "*/vendor/*" -not -path "*/auction-audit/*" -exec dirname {} \; | \
while read dir; do \
echo "Running tests in $$dir..."; \
(cd $$dir && go test ./... -v) || exit 1; \
done


.PHONY: test-integration
test-integration:
Expand Down
4 changes: 4 additions & 0 deletions alerts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ make install

AWS_PROFILE=development $GOPATH/bin/alerts usdx run
```

## Alerts

There is a separate auction alerts service run that is described in the [doc](./auctions/README.md).
7 changes: 7 additions & 0 deletions alerts/auctions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Description

Auction alerts tracks ongoing auctions on the Kava Chain and alerts for:

- Total value of auctions above configured value
- Percentage price deviation of auction clearing price above configured value
- Price deviation of USDX below configured value
2 changes: 1 addition & 1 deletion alerts/auctions/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func getAuctionDataAtHeight(client AuctionClient, height int64) (*AuctionData, e
return nil, err
}

cdpMarkets, err := client.GetMarkets(height)
cdpMarkets, err := client.GetCollateralParams(height)
if err != nil {
return nil, err
}
Expand Down
8 changes: 3 additions & 5 deletions alerts/auctions/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
cdptypes "github.com/kava-labs/kava/x/cdp/types"
hardtypes "github.com/kava-labs/kava/x/hard/types"
pricefeedtypes "github.com/kava-labs/kava/x/pricefeed/types"
"google.golang.org/grpc"
)

const (
Expand All @@ -30,13 +29,12 @@ type AuctionClient interface {
GetInfo() (*InfoResponse, error)
GetPrices(height int64) (pricefeedtypes.CurrentPriceResponses, error)
GetAuctions(height int64) ([]auctiontypes.Auction, error)
GetMarkets(height int64) (cdptypes.CollateralParams, error)
GetCollateralParams(height int64) (cdptypes.CollateralParams, error)
GetMoneyMarkets(height int64) (hardtypes.MoneyMarkets, error)
}

// GrpcAuctionClient defines a client for interacting with auctions via rpc
type GrpcAuctionClient struct {
conn *grpc.ClientConn
grpcClient *kavagrpc.KavaGrpcClient
util *kavagrpcutil.Util
cdc codec.Codec
Expand Down Expand Up @@ -90,8 +88,8 @@ func (c *GrpcAuctionClient) GetPrices(height int64) (pricefeedtypes.CurrentPrice
return prices.Prices, nil
}

// GetMarkets gets an array of collateral params for each collateral type for provided height
func (c *GrpcAuctionClient) GetMarkets(height int64) (cdptypes.CollateralParams, error) {
// GetCollateralParams gets an array of collateral params for each collateral type for provided height
func (c *GrpcAuctionClient) GetCollateralParams(height int64) (cdptypes.CollateralParams, error) {
heightCtx := c.util.CtxAtHeight(height)
params, err := c.grpcClient.Query.Cdp.Params(heightCtx, &cdptypes.QueryParamsRequest{})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions alerts/auctions/grpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestGrpcGetMarkets(t *testing.T) {
t.Skip("skipping test in short mode")
}

markets, err := dataQueryClient.GetMarkets(11000000)
markets, err := dataQueryClient.GetCollateralParams(11000000)
require.NoError(t, err)
require.Len(t, markets, 10)
}
Expand All @@ -100,5 +100,5 @@ func TestGrpcGetMoneyMarkets(t *testing.T) {

moneyMarkets, err := dataQueryClient.GetMoneyMarkets(11000000)
require.NoError(t, err)
require.Len(t, moneyMarkets, 29)
require.Len(t, moneyMarkets, 16)
}

0 comments on commit f9983d0

Please sign in to comment.