@@ -1075,3 +1075,85 @@ func TestParseFiles_IgnoreParentFailures(t *testing.T) {
10751075 })
10761076 }
10771077}
1078+
1079+ func TestParseFiles_WithPanicEventFile (t * testing.T ) {
1080+ t .Parallel ()
1081+
1082+ parser := NewParser ()
1083+ filePath := "testdata/events-with-panic.json"
1084+ results , _ , err := parser .ParseFiles ([]string {filePath }, "run" , 1 , Config {})
1085+
1086+ if err != nil {
1087+ t .Fatalf ("Failed to parse event file: %v" , err )
1088+ }
1089+
1090+ assert .Equal (t , 6 , len (results ), "Expected 6 test results from file." )
1091+
1092+ // Map test names to expected values for easier assertions
1093+ expected := map [string ]struct {
1094+ pkg string
1095+ pkgPanic bool
1096+ panic bool
1097+ passRatio float64
1098+ runs int
1099+ failures int
1100+ successes int
1101+ skipped bool
1102+ skips int
1103+ }{
1104+ "Test_EventHandlerStateSync" : {
1105+ pkg : "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/capabilities/workflows/syncer" , pkgPanic : true , panic : false , passRatio : 1 , runs : 1 , failures : 0 , successes : 1 , skipped : false , skips : 0 ,
1106+ },
1107+ "Test_InitialStateSync" : {
1108+ pkg : "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/capabilities/workflows/syncer" , pkgPanic : true , panic : false , passRatio : 1 , runs : 1 , failures : 0 , successes : 1 , skipped : false , skips : 0 ,
1109+ },
1110+ "Test_RegistrySyncer_SkipsEventsNotBelongingToDON" : {
1111+ pkg : "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/capabilities/workflows/syncer" , pkgPanic : true , panic : false , passRatio : 1 , runs : 1 , failures : 0 , successes : 1 , skipped : false , skips : 0 ,
1112+ },
1113+ "Test_RegistrySyncer_WorkflowRegistered_InitiallyActivated" : {
1114+ pkg : "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/capabilities/workflows/syncer" , pkgPanic : true , panic : true , passRatio : 0 , runs : 1 , failures : 1 , successes : 0 , skipped : false , skips : 0 ,
1115+ },
1116+ "Test_RegistrySyncer_WorkflowRegistered_InitiallyPaused" : {
1117+ pkg : "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/capabilities/workflows/syncer" , pkgPanic : true , panic : false , passRatio : 1 , runs : 1 , failures : 0 , successes : 1 , skipped : false , skips : 0 ,
1118+ },
1119+ "Test_SecretsWorker" : {
1120+ pkg : "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/capabilities/workflows/syncer" , pkgPanic : false , panic : false , passRatio : 1 , runs : 0 , failures : 0 , successes : 0 , skipped : true , skips : 1 ,
1121+ },
1122+ }
1123+
1124+ for _ , r := range results {
1125+ exp , ok := expected [r .TestName ]
1126+ require .True (t , ok , "Unexpected test name: %s" , r .TestName )
1127+ assert .Equal (t , exp .pkg , r .TestPackage , "Package mismatch for %s" , r .TestName )
1128+ assert .Equal (t , exp .pkgPanic , r .PackagePanic , "PackagePanic mismatch for %s" , r .TestName )
1129+ assert .Equal (t , exp .panic , r .Panic , "Panic mismatch for %s" , r .TestName )
1130+ assert .InDelta (t , exp .passRatio , r .PassRatio , 0.001 , "PassRatio mismatch for %s" , r .TestName )
1131+ assert .Equal (t , exp .runs , r .Runs , "Runs mismatch for %s" , r .TestName )
1132+ assert .Equal (t , exp .failures , r .Failures , "Failures mismatch for %s" , r .TestName )
1133+ assert .Equal (t , exp .successes , r .Successes , "Successes mismatch for %s" , r .TestName )
1134+ assert .Equal (t , exp .skipped , r .Skipped , "Skipped mismatch for %s" , r .TestName )
1135+ assert .Equal (t , exp .skips , r .Skips , "Skips count mismatch for %s" , r .TestName )
1136+ }
1137+
1138+
1139+ }
1140+
1141+ func TestParseFiles_WithPanicEventFileSpecific (t * testing.T ) {
1142+ t .Parallel ()
1143+
1144+ parser := NewParser ()
1145+ filePath := "testdata/events-with-panic-single.json"
1146+
1147+ results , _ , err := parser .ParseFiles ([]string {filePath }, "run" , 1 , Config {})
1148+ if err != nil {
1149+ t .Fatalf ("Failed to parse event file: %v" , err )
1150+ }
1151+ assert .Equal (t , 1 , len (results ), "Expected 6 test results from file." )
1152+
1153+ testResult := results [0 ]
1154+
1155+ assert .True (t , testResult .Panic , "Expected test result to be marked as panic" )
1156+ assert .True (t , testResult .PackagePanic , "Expected test result to be marked as panic" )
1157+ assert .Equal (t , "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/capabilities/workflows/syncer" , testResult .TestPackage , "Test package mismatch" )
1158+ assert .Equal (t , "Test_RegistrySyncer_WorkflowRegistered_InitiallyActivated" , testResult .TestName , "Test name mismatch" )
1159+ }
0 commit comments