From eda89ce7ecdc39d69cfbcf02457679d62388c7a1 Mon Sep 17 00:00:00 2001 From: Matt Johnstone Date: Tue, 29 Oct 2024 12:51:45 +0200 Subject: [PATCH] ran go mod tidy --- cmd/solana_exporter/exporter_test.go | 41 +++++++++++++++------------- cmd/solana_exporter/slots_test.go | 4 +-- go.mod | 5 +--- go.sum | 7 ++--- 4 files changed, 27 insertions(+), 30 deletions(-) diff --git a/cmd/solana_exporter/exporter_test.go b/cmd/solana_exporter/exporter_test.go index dad2a2f..cade12d 100644 --- a/cmd/solana_exporter/exporter_test.go +++ b/cmd/solana_exporter/exporter_test.go @@ -16,9 +16,6 @@ import ( "time" ) -const InflationRewardLamports = 10 -const FeeRewardLamports = 10 - type ( Simulator struct { Server *rpc.MockServer @@ -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 { @@ -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 { @@ -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}) diff --git a/cmd/solana_exporter/slots_test.go b/cmd/solana_exporter/slots_test.go index aa1b0a6..687d4a1 100644 --- a/cmd/solana_exporter/slots_test.go +++ b/cmd/solana_exporter/slots_test.go @@ -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)), ), @@ -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)), ), diff --git a/go.mod b/go.mod index 05487a1..361a7d5 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 5ca7cc6..5ba3e59 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= @@ -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=