@@ -165,3 +165,34 @@ func TestGenerator_Generate(t *testing.T) {
165
165
})
166
166
}
167
167
}
168
+
169
+ func TestGenerator_CheckAPI (t * testing.T ) {
170
+ targetEpoch := types .EpochID (3 )
171
+ db := sql .InMemory ()
172
+ createAtxs (t , db , targetEpoch - 1 , types .RandomActiveSet (activeSetSize ))
173
+ cfg , cleanup := launchServer (t , datastore .NewCachedDB (db , logtest .New (t )))
174
+ t .Cleanup (cleanup )
175
+
176
+ fs := afero .NewMemMapFs ()
177
+ g := NewGenerator (
178
+ "https://api.blockcypher.com/v1/btc/main" ,
179
+ cfg .PublicListener ,
180
+ WithLogger (logtest .New (t )),
181
+ WithFilesystem (fs ),
182
+ WithHttpClient (http .DefaultClient ),
183
+ )
184
+ ctx , cancel := context .WithCancel (context .Background ())
185
+ defer cancel ()
186
+ persisted , err := g .Generate (ctx , targetEpoch , true , false )
187
+ require .NoError (t , err )
188
+
189
+ got , err := afero .ReadFile (fs , persisted )
190
+ require .NoError (t , err )
191
+ require .NotEmpty (t , got )
192
+
193
+ require .NoError (t , bootstrap .ValidateSchema (got ))
194
+
195
+ var update bootstrap.Update
196
+ require .NoError (t , json .Unmarshal (got , & update ))
197
+ require .NotEqual (t , "00000000" , update .Data .Epoch .Beacon )
198
+ }
0 commit comments