split out correct metric changes
This commit is contained in:
parent
e1edb64d09
commit
206aa75eca
|
@ -178,6 +178,54 @@ func TestSolanaCollector_WatchSlots_Dynamic(t *testing.T) {
|
|||
time.Sleep(time.Second)
|
||||
final := getSlotMetricValues()
|
||||
|
||||
// make sure things are changing correctly:
|
||||
assertSlotMetricsChangeCorrectly(t, initial, final)
|
||||
|
||||
// sense check to make sure the exporter is not "ahead" of the client (due to double counting or whatever)
|
||||
assert.LessOrEqualf(
|
||||
t,
|
||||
int(final.SlotHeight),
|
||||
client.Slot,
|
||||
"Exporter slot (%v) ahead of client slot (%v)!",
|
||||
int(final.SlotHeight),
|
||||
client.Slot,
|
||||
)
|
||||
assert.LessOrEqualf(
|
||||
t,
|
||||
int(final.TotalTransactions),
|
||||
client.TransactionCount,
|
||||
"Exporter transaction count (%v) ahead of client transaction count (%v)!",
|
||||
int(final.TotalTransactions),
|
||||
client.TransactionCount,
|
||||
)
|
||||
assert.LessOrEqualf(
|
||||
t,
|
||||
int(final.EpochNumber),
|
||||
client.Epoch,
|
||||
"Exporter epoch (%v) ahead of client epoch (%v)!",
|
||||
int(final.EpochNumber),
|
||||
client.Epoch,
|
||||
)
|
||||
|
||||
// check if epoch changed
|
||||
if final.EpochNumber > initial.EpochNumber {
|
||||
epochChanged = true
|
||||
}
|
||||
|
||||
// make current final the new initial (for next iteration)
|
||||
initial = final
|
||||
}
|
||||
|
||||
// epoch should have changed somewhere
|
||||
assert.Truef(t, epochChanged, "Epoch has not changed!")
|
||||
|
||||
// cancel and wait for cancellation:
|
||||
slotsCancel()
|
||||
runCancel()
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
func assertSlotMetricsChangeCorrectly(t *testing.T, initial slotMetricValues, final slotMetricValues) {
|
||||
// make sure that things have increased
|
||||
assert.Greaterf(
|
||||
t,
|
||||
|
@ -203,19 +251,4 @@ func TestSolanaCollector_WatchSlots_Dynamic(t *testing.T) {
|
|||
initial.EpochNumber,
|
||||
final.EpochNumber,
|
||||
)
|
||||
if final.EpochNumber > initial.EpochNumber {
|
||||
epochChanged = true
|
||||
}
|
||||
|
||||
// make current final the new initial (for next iteration)
|
||||
initial = final
|
||||
}
|
||||
|
||||
// epoch should have changed somewhere
|
||||
assert.Truef(t, epochChanged, "Epoch has not changed!")
|
||||
|
||||
// cancel and wait for cancellation:
|
||||
slotsCancel()
|
||||
runCancel()
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue