Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
notJoon committed May 9, 2024
1 parent 9ee8f70 commit 50e7d49
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions price_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ func TestFetchTokenPrices(t *testing.T) {
},
}

json.NewEncoder(w).Encode(tokenPricesResponse)
err := json.NewEncoder(w).Encode(tokenPricesResponse)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
}))
defer server.Close()

Expand Down Expand Up @@ -98,8 +102,8 @@ func TestFetchTokenPricesLive(t *testing.T) {
t.Fatalf("Failed to fetch token prices: %v", err)
}

if len(prices) == 0 {
t.Errorf("Fetched token prices are empty")
if len(prices) != 6 {
t.Errorf("Expected 6 token prices, got %d", len(prices))
}

for _, price := range prices {
Expand Down
4 changes: 3 additions & 1 deletion store.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package vwap

const interval = 600

// VWAPData represents the specific token's VWAP data.
type VWAPData struct {
TokenName string `json:"token_name"` // VWAP data belongs token name
Expand All @@ -23,7 +25,7 @@ func init() {
// - timestamp: the timestamp of the VWAP value
func store(tokenName string, vwap float64, timestamp int) {
// adjust the timestamp to the 10 minutes interval.
adjustedTimestamp := timestamp - (timestamp % 600)
adjustedTimestamp := timestamp - (timestamp % interval)

// get the VWAP data for the token
lst, ok := vwapDataMap[tokenName]
Expand Down

0 comments on commit 50e7d49

Please sign in to comment.