@@ -32,6 +32,12 @@ class TestConditionChecker : public AbstractThresholdConditionChecker
32
32
int GetStateSinceHeightFor (const CBlockIndex* pindexPrev) const { return AbstractThresholdConditionChecker::GetStateSinceHeightFor (pindexPrev, paramsDummy, cache); }
33
33
};
34
34
35
+ class TestAlwaysActiveConditionChecker : public TestConditionChecker
36
+ {
37
+ public:
38
+ int64_t BeginTime (const Consensus::Params& params) const override { return Consensus::BIP9Deployment::ALWAYS_ACTIVE; }
39
+ };
40
+
35
41
#define CHECKERS 6
36
42
37
43
class VersionBitsTester
@@ -43,6 +49,8 @@ class VersionBitsTester
43
49
// The first one performs all checks, the second only 50%, the third only 25%, etc...
44
50
// This is to test whether lack of cached information leads to the same results.
45
51
TestConditionChecker checker[CHECKERS];
52
+ // Another 6 that assume always active activation
53
+ TestAlwaysActiveConditionChecker checker_always[CHECKERS];
46
54
47
55
// Test counter (to identify failures)
48
56
int num;
@@ -56,6 +64,7 @@ class VersionBitsTester
56
64
}
57
65
for (unsigned int i = 0 ; i < CHECKERS; i++) {
58
66
checker[i] = TestConditionChecker ();
67
+ checker_always[i] = TestAlwaysActiveConditionChecker ();
59
68
}
60
69
vpblock.clear ();
61
70
return *this ;
@@ -82,6 +91,7 @@ class VersionBitsTester
82
91
for (int i = 0 ; i < CHECKERS; i++) {
83
92
if (InsecureRandBits (i) == 0 ) {
84
93
BOOST_CHECK_MESSAGE (checker[i].GetStateSinceHeightFor (vpblock.empty () ? nullptr : vpblock.back ()) == height, strprintf (" Test %i for StateSinceHeight" , num));
94
+ BOOST_CHECK_MESSAGE (checker_always[i].GetStateSinceHeightFor (vpblock.empty () ? nullptr : vpblock.back ()) == 0 , strprintf (" Test %i for StateSinceHeight (always active)" , num));
85
95
}
86
96
}
87
97
num++;
@@ -92,6 +102,7 @@ class VersionBitsTester
92
102
for (int i = 0 ; i < CHECKERS; i++) {
93
103
if (InsecureRandBits (i) == 0 ) {
94
104
BOOST_CHECK_MESSAGE (checker[i].GetStateFor (vpblock.empty () ? nullptr : vpblock.back ()) == THRESHOLD_DEFINED, strprintf (" Test %i for DEFINED" , num));
105
+ BOOST_CHECK_MESSAGE (checker_always[i].GetStateFor (vpblock.empty () ? nullptr : vpblock.back ()) == THRESHOLD_ACTIVE, strprintf (" Test %i for ACTIVE (always active)" , num));
95
106
}
96
107
}
97
108
num++;
@@ -102,6 +113,7 @@ class VersionBitsTester
102
113
for (int i = 0 ; i < CHECKERS; i++) {
103
114
if (InsecureRandBits (i) == 0 ) {
104
115
BOOST_CHECK_MESSAGE (checker[i].GetStateFor (vpblock.empty () ? nullptr : vpblock.back ()) == THRESHOLD_STARTED, strprintf (" Test %i for STARTED" , num));
116
+ BOOST_CHECK_MESSAGE (checker_always[i].GetStateFor (vpblock.empty () ? nullptr : vpblock.back ()) == THRESHOLD_ACTIVE, strprintf (" Test %i for ACTIVE (always active)" , num));
105
117
}
106
118
}
107
119
num++;
@@ -112,6 +124,7 @@ class VersionBitsTester
112
124
for (int i = 0 ; i < CHECKERS; i++) {
113
125
if (InsecureRandBits (i) == 0 ) {
114
126
BOOST_CHECK_MESSAGE (checker[i].GetStateFor (vpblock.empty () ? nullptr : vpblock.back ()) == THRESHOLD_LOCKED_IN, strprintf (" Test %i for LOCKED_IN" , num));
127
+ BOOST_CHECK_MESSAGE (checker_always[i].GetStateFor (vpblock.empty () ? nullptr : vpblock.back ()) == THRESHOLD_ACTIVE, strprintf (" Test %i for ACTIVE (always active)" , num));
115
128
}
116
129
}
117
130
num++;
@@ -122,6 +135,7 @@ class VersionBitsTester
122
135
for (int i = 0 ; i < CHECKERS; i++) {
123
136
if (InsecureRandBits (i) == 0 ) {
124
137
BOOST_CHECK_MESSAGE (checker[i].GetStateFor (vpblock.empty () ? nullptr : vpblock.back ()) == THRESHOLD_ACTIVE, strprintf (" Test %i for ACTIVE" , num));
138
+ BOOST_CHECK_MESSAGE (checker_always[i].GetStateFor (vpblock.empty () ? nullptr : vpblock.back ()) == THRESHOLD_ACTIVE, strprintf (" Test %i for ACTIVE (always active)" , num));
125
139
}
126
140
}
127
141
num++;
@@ -132,6 +146,7 @@ class VersionBitsTester
132
146
for (int i = 0 ; i < CHECKERS; i++) {
133
147
if (InsecureRandBits (i) == 0 ) {
134
148
BOOST_CHECK_MESSAGE (checker[i].GetStateFor (vpblock.empty () ? nullptr : vpblock.back ()) == THRESHOLD_FAILED, strprintf (" Test %i for FAILED" , num));
149
+ BOOST_CHECK_MESSAGE (checker_always[i].GetStateFor (vpblock.empty () ? nullptr : vpblock.back ()) == THRESHOLD_ACTIVE, strprintf (" Test %i for ACTIVE (always active)" , num));
135
150
}
136
151
}
137
152
num++;
0 commit comments