Hush Full Node software. We were censored from Github, this is where all development happens now.
https://hush.is
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include "metrics.h"
|
|
|
|
#include "utiltime.h"
|
|
|
|
|
|
|
|
|
|
|
|
TEST(Metrics, GetLocalSolPS) {
|
|
|
|
SetMockTime(100);
|
|
|
|
miningTimer.start();
|
|
|
|
|
|
|
|
// No time has passed
|
|
|
|
EXPECT_EQ(0, GetLocalSolPS());
|
|
|
|
|
|
|
|
// Increment time
|
|
|
|
SetMockTime(101);
|
|
|
|
EXPECT_EQ(0, GetLocalSolPS());
|
|
|
|
|
|
|
|
// Increment solutions
|
|
|
|
solutionTargetChecks.increment();
|
|
|
|
EXPECT_EQ(1, GetLocalSolPS());
|
|
|
|
|
|
|
|
// Increment time
|
|
|
|
SetMockTime(102);
|
|
|
|
EXPECT_EQ(0.5, GetLocalSolPS());
|
|
|
|
|
|
|
|
// Increment solutions
|
|
|
|
solutionTargetChecks.increment();
|
|
|
|
solutionTargetChecks.increment();
|
|
|
|
EXPECT_EQ(1.5, GetLocalSolPS());
|
|
|
|
|
|
|
|
// Stop timing
|
|
|
|
miningTimer.stop();
|
|
|
|
EXPECT_EQ(1.5, GetLocalSolPS());
|
|
|
|
|
|
|
|
// Increment time
|
|
|
|
SetMockTime(103);
|
|
|
|
EXPECT_EQ(1.5, GetLocalSolPS());
|
|
|
|
|
|
|
|
// Start timing again
|
|
|
|
miningTimer.start();
|
|
|
|
EXPECT_EQ(1.5, GetLocalSolPS());
|
|
|
|
|
|
|
|
// Increment time
|
|
|
|
SetMockTime(104);
|
|
|
|
EXPECT_EQ(1, GetLocalSolPS());
|
|
|
|
}
|