@@ -7143,7 +7143,8 @@ func TestPlugin_broadcastBlobPayloads(t *testing.T) {
71437143 }
71447144
71457145 fetcher := & callbackBlobFetcher {fn : func ([]byte ) error { return nil }}
7146- result := r .broadcastBlobPayloads (t .Context (), fetcher , 1 , nil , nil )
7146+ result , err := r .broadcastBlobPayloads (t .Context (), fetcher , 1 , nil , nil )
7147+ require .NoError (t , err )
71477148 assert .Empty (t , result )
71487149 })
71497150
@@ -7161,7 +7162,8 @@ func TestPlugin_broadcastBlobPayloads(t *testing.T) {
71617162 payloads := [][]byte {[]byte ("p1" ), []byte ("p2" ), []byte ("p3" )}
71627163 ids := []string {"req-1" , "req-2" , "req-3" }
71637164
7164- result := r .broadcastBlobPayloads (t .Context (), fetcher , 1 , payloads , ids )
7165+ result , err := r .broadcastBlobPayloads (t .Context (), fetcher , 1 , payloads , ids )
7166+ require .NoError (t , err )
71657167 assert .Len (t , result , 3 )
71667168 for _ , item := range result {
71677169 assert .Equal (t , []byte ("handle" ), item )
@@ -7188,7 +7190,8 @@ func TestPlugin_broadcastBlobPayloads(t *testing.T) {
71887190 payloads := [][]byte {[]byte ("p1" ), []byte ("p2" ), []byte ("p3" )}
71897191 ids := []string {"req-1" , "req-2" , "req-3" }
71907192
7191- result := r .broadcastBlobPayloads (t .Context (), fetcher , 5 , payloads , ids )
7193+ result , err := r .broadcastBlobPayloads (t .Context (), fetcher , 5 , payloads , ids )
7194+ require .NoError (t , err )
71927195 assert .Len (t , result , 2 )
71937196
71947197 warnLogs := observed .FilterMessage ("failed to broadcast pending queue item as blob, skipping" )
@@ -7213,7 +7216,8 @@ func TestPlugin_broadcastBlobPayloads(t *testing.T) {
72137216 payloads := [][]byte {[]byte ("p1" ), []byte ("p2" )}
72147217 ids := []string {"req-1" , "req-2" }
72157218
7216- result := r .broadcastBlobPayloads (t .Context (), fetcher , 1 , payloads , ids )
7219+ result , err := r .broadcastBlobPayloads (t .Context (), fetcher , 1 , payloads , ids )
7220+ require .NoError (t , err )
72177221 assert .Empty (t , result )
72187222
72197223 warnLogs := observed .FilterMessage ("failed to broadcast pending queue item as blob, skipping" )
@@ -7234,7 +7238,8 @@ func TestPlugin_broadcastBlobPayloads(t *testing.T) {
72347238 payloads := [][]byte {[]byte ("p1" ), []byte ("p2" )}
72357239 ids := []string {"req-1" , "req-2" }
72367240
7237- result := r .broadcastBlobPayloads (t .Context (), fetcher , 1 , payloads , ids )
7241+ result , err := r .broadcastBlobPayloads (t .Context (), fetcher , 1 , payloads , ids )
7242+ require .NoError (t , err )
72387243 assert .Empty (t , result )
72397244
72407245 warnLogs := observed .FilterMessage ("failed to marshal blob handle, skipping" )
@@ -7267,12 +7272,64 @@ func TestPlugin_broadcastBlobPayloads(t *testing.T) {
72677272 payloads := [][]byte {[]byte ("p1" ), []byte ("p2" ), []byte ("p3" )}
72687273 ids := []string {"req-1" , "req-2" , "req-3" }
72697274
7270- result := r .broadcastBlobPayloads (t .Context (), fetcher , 1 , payloads , ids )
7275+ result , err := r .broadcastBlobPayloads (t .Context (), fetcher , 1 , payloads , ids )
7276+ require .NoError (t , err )
72717277
72727278 broadcastWarns := observed .FilterMessage ("failed to broadcast pending queue item as blob, skipping" )
72737279 marshalWarns := observed .FilterMessage ("failed to marshal blob handle, skipping" )
72747280 assert .Equal (t , 1 , broadcastWarns .Len ())
72757281 assert .Equal (t , 1 , marshalWarns .Len ())
72767282 assert .Len (t , result , 1 )
72777283 })
7284+
7285+ t .Run ("context cancellation propagates error" , func (t * testing.T ) {
7286+ lggr := logger .TestLogger (t )
7287+ r := & ReportingPlugin {
7288+ lggr : lggr ,
7289+ metrics : newTestMetrics (t ),
7290+ marshalBlob : func (ocr3_1types.BlobHandle ) ([]byte , error ) {
7291+ return []byte ("handle" ), nil
7292+ },
7293+ }
7294+
7295+ ctx , cancel := context .WithCancel (t .Context ())
7296+ cancel ()
7297+
7298+ fetcher := & callbackBlobFetcher {fn : func ([]byte ) error {
7299+ return ctx .Err ()
7300+ }}
7301+
7302+ payloads := [][]byte {[]byte ("p1" ), []byte ("p2" )}
7303+ ids := []string {"req-1" , "req-2" }
7304+
7305+ result , err := r .broadcastBlobPayloads (ctx , fetcher , 1 , payloads , ids )
7306+ assert .Nil (t , result )
7307+ assert .ErrorIs (t , err , context .Canceled )
7308+ })
7309+
7310+ t .Run ("context deadline exceeded propagates error" , func (t * testing.T ) {
7311+ lggr := logger .TestLogger (t )
7312+ r := & ReportingPlugin {
7313+ lggr : lggr ,
7314+ metrics : newTestMetrics (t ),
7315+ marshalBlob : func (ocr3_1types.BlobHandle ) ([]byte , error ) {
7316+ return []byte ("handle" ), nil
7317+ },
7318+ }
7319+
7320+ ctx , cancel := context .WithTimeout (t .Context (), 0 )
7321+ defer cancel ()
7322+ <- ctx .Done ()
7323+
7324+ fetcher := & callbackBlobFetcher {fn : func ([]byte ) error {
7325+ return ctx .Err ()
7326+ }}
7327+
7328+ payloads := [][]byte {[]byte ("p1" )}
7329+ ids := []string {"req-1" }
7330+
7331+ result , err := r .broadcastBlobPayloads (ctx , fetcher , 1 , payloads , ids )
7332+ assert .Nil (t , result )
7333+ assert .ErrorIs (t , err , context .DeadlineExceeded )
7334+ })
72787335}
0 commit comments