@@ -14,6 +14,12 @@ import (
14
14
"github.com/stretchr/testify/assert"
15
15
)
16
16
17
+ const (
18
+ firstCheckpoint = (64 * (iota + 1 )) - 1
19
+ secondCheckpoint
20
+ thirdCheckpoint
21
+ )
22
+
17
23
func TestProtocol14StateVerifier (t * testing.T ) {
18
24
itest := integration .NewTest (t , protocol15Config )
19
25
@@ -99,42 +105,43 @@ func TestProtocol14StateVerifier(t *testing.T) {
99
105
assert .True (t , txResp .Successful )
100
106
101
107
// Wait for the first checkpoint ledger
102
- for ! itest .LedgerIngested (63 ) {
103
- t .Log ("First checkpoint ledger (63) not ingested yet..." )
108
+ for ! itest .LedgerIngested (firstCheckpoint ) {
109
+ t .Log ("First checkpoint ledger not ingested yet..." )
104
110
time .Sleep (5 * time .Second )
105
111
}
106
112
107
- verified := waitForStateVerifications (t , itest , 1 )
113
+ verified := waitForStateVerifications (itest , 1 )
108
114
if ! verified {
109
115
t .Fatal ("State verification not run..." )
110
116
}
111
117
112
118
// Trigger state rebuild to check if ingesting from history archive works
113
- itest .RunHorizonCLICommand ([] string { "expingest" , "trigger-state-rebuild" } )
119
+ itest .RunHorizonCLICommand ("expingest" , "trigger-state-rebuild" )
114
120
115
121
// Wait for the second checkpoint ledger and state rebuild
116
- for ! itest .LedgerClosed (127 ) {
117
- t .Log ("First checkpoint ledger (127) not closed yet..." )
122
+ for ! itest .LedgerClosed (secondCheckpoint ) {
123
+ t .Log ("Second checkpoint ledger not closed yet..." )
118
124
time .Sleep (5 * time .Second )
119
125
}
120
126
121
127
// Wait for the third checkpoint ledger and state verification trigger
122
- for ! itest .LedgerIngested (191 ) {
123
- t .Log ("First checkpoint ledger (191) not ingested yet..." )
128
+ for ! itest .LedgerIngested (thirdCheckpoint ) {
129
+ t .Log ("Third checkpoint ledger not ingested yet..." )
124
130
time .Sleep (5 * time .Second )
125
131
}
126
132
127
- verified = waitForStateVerifications (t , itest , 2 )
133
+ verified = waitForStateVerifications (itest , 2 )
128
134
if ! verified {
129
135
t .Fatal ("State verification not run..." )
130
136
}
131
137
}
132
138
133
- func waitForStateVerifications (t * testing.T , itest * integration.Test , count int ) bool {
139
+ func waitForStateVerifications (itest * integration.Test , count int ) bool {
140
+ t := itest .CurrentTest ()
134
141
// Check metrics until state verification run
135
142
for i := 0 ; i < 120 ; i ++ {
136
143
t .Logf ("Checking metrics (%d attempt)\n " , i )
137
- res , err := http .Get (fmt . Sprintf ( "http://localhost:%d/metrics" , itest .AdminPort () ))
144
+ res , err := http .Get (itest .MetricsURL ( ))
138
145
assert .NoError (t , err )
139
146
140
147
metricsBytes , err := ioutil .ReadAll (res .Body )
0 commit comments