@@ -343,34 +343,18 @@ func TestHandleGetOrderedBlocksByValidatorKey(t *testing.T) {
343343 mockOracle := oracle .NewOracle (mockConfig )
344344 oracle .NewOracleState (mockConfig )
345345
346- // blockPool := oracle.Block{
347- // // Set the desired values for the blockPool struct
348- // Slot: 0,
349- // Block: 0,
350- // ValidatorIndex: 420,
351- // BlockType: 3,
352- // }
353- blockSubs := []oracle.Subscription {
354- // Create mock subscription objects as needed
355- }
356- blockUnsubs := []oracle.Unsubscription {
357- // Create mock unsubscription objects as needed
346+ numBlocks := 100
347+ for i := 0 ; i < numBlocks ; i ++ {
348+ // Create mock blocks and add them to the OracleState's ProposedBlocks
349+ mockBlock := blockOkProposal (
350+ 0 ,
351+ 420 ,
352+ fmt .Sprintf ("%d" , i + 1 ),
353+ big .NewInt (int64 (rand .Intn (1000 )+ 10000 )),
354+ "0xaaa0000000000000000000000000000000000000" ,
355+ )
356+ mockOracle .State ().HandleCorrectBlockProposal (mockBlock )
358357 }
359- blockDonations := []oracle.Donation {
360- // Create mock donation objects as needed
361- }
362- mevReward := big .NewInt (int64 (rand .Intn (1000 ) + 10000 ))
363-
364- // Call the function and capture the returned values
365- processedSlot , err := mockOracle .AdvanceStateToNextSlot (blockOkProposal (
366- 0 ,
367- 420 ,
368- "1" ,
369- mevReward ,
370- "0xaaa0000000000000000000000000000000000000" ), blockSubs , blockUnsubs , blockDonations )
371- fmt .Print (mockOracle .State ().ProposedBlocks )
372-
373- _ = processedSlot
374358 // Create an instance of your ApiService with the mock Oracle
375359 apiService := & ApiService {
376360 oracle : mockOracle ,
@@ -384,21 +368,20 @@ func TestHandleGetOrderedBlocksByValidatorKey(t *testing.T) {
384368 // Call the handler function directly, passing in the ResponseRecorder and the Request
385369 handler := http .HandlerFunc (apiService .handleMemoryValidatorBlocks )
386370 handler .ServeHTTP (rr , req )
387- fmt .Print (rr .Body .String ())
388-
389- handler2 := http .HandlerFunc (apiService .handleMemoryAllBlocks )
390- handler2 .ServeHTTP (rr , req )
391- fmt .Print (rr .Body .String ())
371+ fmt .Println (rr .Body )
392372
393- // // Perform assertions on the response
394- // if status := rr.Code; status != http.StatusOK {
395- // t.Errorf("handler returned wrong status code: got %v, want %v", status, http.StatusOK)
396- // }
373+ // handler2 := http.HandlerFunc(apiService.handleMemoryAllBlocks)
374+ // handler2.ServeHTTP(rr, req)
397375 // fmt.Print(rr.Body.String())
398- // // Perform additional assertions on the response body or headers if needed
399- // // For example, you can check the response body for expected JSON data
400376
401- // // Example assertion for JSON response
377+ // Perform assertions on the response
378+ if status := rr .Code ; status != http .StatusOK {
379+ t .Errorf ("handler returned wrong status code: got %v, want %v" , status , http .StatusOK )
380+ }
381+ // Perform additional assertions on the response body or headers if needed
382+ // For example, you can check the response body for expected JSON data
383+
384+ // Example assertion for JSON response
402385 // expectedResponse := `{"message":"success"}`
403386 // if rr.Body.String() != expectedResponse {
404387 // t.Errorf("handler returned unexpected body: got %v, want %v", rr.Body.String(), expectedResponse)
0 commit comments