Skip to content

Commit

Permalink
ran go mod tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
johnstonematt committed Oct 29, 2024
1 parent c767cf3 commit eda89ce
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 30 deletions.
41 changes: 22 additions & 19 deletions cmd/solana_exporter/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ import (
"time"
)

const InflationRewardLamports = 10
const FeeRewardLamports = 10

type (
Simulator struct {
Server *rpc.MockServer
Expand All @@ -28,17 +25,21 @@ type (
Epoch int
TransactionCount int

SlotTime time.Duration
EpochSize int
LeaderSchedule map[string][]int
Nodekeys []string
Votekeys []string
// constants for the simulator
SlotTime time.Duration
EpochSize int
LeaderSchedule map[string][]int
Nodekeys []string
Votekeys []string
FeeRewardLamports int
InflationRewardLamports int
}
)

func NewSimulator(t *testing.T, slot int) (*Simulator, *rpc.Client) {
nodekeys := []string{"aaa", "bbb", "ccc"}
votekeys := []string{"AAA", "BBB", "CCC"}
feeRewardLamports, inflationRewardLamports := 10, 10

validatorInfos := make(map[string]rpc.MockValidatorInfo)
for i, nodekey := range nodekeys {
Expand Down Expand Up @@ -68,21 +69,23 @@ func NewSimulator(t *testing.T, slot int) (*Simulator, *rpc.Client) {
"CCC": 6 * rpc.LamportsInSol,
},
map[string]int{
"AAA": InflationRewardLamports,
"BBB": InflationRewardLamports,
"CCC": InflationRewardLamports,
"AAA": inflationRewardLamports,
"BBB": inflationRewardLamports,
"CCC": inflationRewardLamports,
},
nil,
validatorInfos,
)
simulator := Simulator{
Slot: 0,
Server: mockServer,
EpochSize: 24,
SlotTime: 100 * time.Millisecond,
LeaderSchedule: leaderSchedule,
Nodekeys: nodekeys,
Votekeys: votekeys,
Slot: 0,
Server: mockServer,
EpochSize: 24,
SlotTime: 100 * time.Millisecond,
LeaderSchedule: leaderSchedule,
Nodekeys: nodekeys,
Votekeys: votekeys,
InflationRewardLamports: inflationRewardLamports,
FeeRewardLamports: feeRewardLamports,
}
simulator.PopulateSlot(0)
if slot > 0 {
Expand Down Expand Up @@ -146,7 +149,7 @@ func (c *Simulator) PopulateSlot(slot int) {
}

c.TransactionCount += len(transactions)
block = &rpc.MockBlockInfo{Fee: FeeRewardLamports, Transactions: transactions}
block = &rpc.MockBlockInfo{Fee: c.FeeRewardLamports, Transactions: transactions}
}
// add slot info:
c.Server.SetOpt(rpc.SlotInfosOpt, slot, rpc.MockSlotInfo{Leader: leader, Block: block})
Expand Down
4 changes: 2 additions & 2 deletions cmd/solana_exporter/slots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func TestSlotWatcher_WatchSlots_Dynamic(t *testing.T) {
// inflation rewards:
votekey := simulator.Votekeys[i]
assert.Equalf(t,
float64(InflationRewardLamports)/rpc.LamportsInSol,
float64(simulator.InflationRewardLamports)/rpc.LamportsInSol,
testutil.ToFloat64(
watcher.InflationRewardsMetric.WithLabelValues(votekey, toString(initial.EpochNumber)),
),
Expand All @@ -251,7 +251,7 @@ func TestSlotWatcher_WatchSlots_Dynamic(t *testing.T) {

// fee rewards:
assert.Equalf(t,
float64(FeeRewardLamports*leaderSlotsPerEpoch*3/4)/rpc.LamportsInSol,
float64(simulator.FeeRewardLamports*leaderSlotsPerEpoch*3/4)/rpc.LamportsInSol,
testutil.ToFloat64(
watcher.FeeRewardsMetric.WithLabelValues(nodekey, toString(initial.EpochNumber)),
),
Expand Down
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@ go 1.22
require (
github.com/prometheus/client_golang v1.19.1
github.com/stretchr/testify v1.9.0
k8s.io/klog/v2 v2.120.1
go.uber.org/zap v1.27.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/sys v0.17.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
7 changes: 2 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
Expand All @@ -27,6 +24,8 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
Expand All @@ -40,5 +39,3 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw=
k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=

0 comments on commit eda89ce

Please sign in to comment.