@@ -894,3 +894,44 @@ func TestStateParseTransitivelyAcceptedBlock(t *testing.T) {
894
894
t .Fatalf ("Parsed blk1 reported incorrect height. Expected %d got %d" , blk1 .Height (), parsedBlk1 .Height ())
895
895
}
896
896
}
897
+
898
+ func TestIsProcessing (t * testing.T ) {
899
+ testBlks := NewTestBlocks (2 )
900
+ genesisBlock := testBlks [0 ]
901
+ genesisBlock .SetStatus (choices .Accepted )
902
+ blk1 := testBlks [1 ]
903
+
904
+ getBlock , parseBlock , getCanonicalBlockID := createInternalBlockFuncs (t , testBlks )
905
+ chainState := NewState (& Config {
906
+ DecidedCacheSize : 2 ,
907
+ MissingCacheSize : 2 ,
908
+ UnverifiedCacheSize : 2 ,
909
+ BytesToIDCacheSize : 2 ,
910
+ LastAcceptedBlock : genesisBlock ,
911
+ GetBlock : getBlock ,
912
+ UnmarshalBlock : parseBlock ,
913
+ BuildBlock : cantBuildBlock ,
914
+ GetBlockIDAtHeight : getCanonicalBlockID ,
915
+ })
916
+
917
+ // Parse blk1
918
+ parsedBlk1 , err := chainState .ParseBlock (context .Background (), blk1 .Bytes ())
919
+ require .NoError (t , err )
920
+
921
+ // Check that it is not processing in consensus
922
+ require .False (t , chainState .IsProcessing (parsedBlk1 .ID ()))
923
+
924
+ // Verify blk1
925
+ err = parsedBlk1 .Verify (context .Background ())
926
+ require .NoError (t , err )
927
+
928
+ // Check that it is processing in consensus
929
+ require .True (t , chainState .IsProcessing (parsedBlk1 .ID ()))
930
+
931
+ // Accept blk1
932
+ err = parsedBlk1 .Accept (context .Background ())
933
+ require .NoError (t , err )
934
+
935
+ // Check that it is no longer processing in consensus
936
+ require .False (t , chainState .IsProcessing (parsedBlk1 .ID ()))
937
+ }
0 commit comments