@@ -1584,7 +1584,8 @@ func TestProduceSyncCommitteeContribution(t *testing.T) {
15841584 SyncCommitteeIndices : []primitives.CommitteeIndex {0 },
15851585 },
15861586 },
1587- SyncCommitteePool : syncCommitteePool ,
1587+ SyncCommitteePool : syncCommitteePool ,
1588+ OptimisticModeFetcher : & mockChain.ChainService {},
15881589 }
15891590 t .Run ("ok" , func (t * testing.T ) {
15901591 url := "http://example.com?slot=1&subcommittee_index=1&beacon_block_root=0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"
@@ -1672,14 +1673,35 @@ func TestProduceSyncCommitteeContribution(t *testing.T) {
16721673 SyncCommitteeIndices : []primitives.CommitteeIndex {0 },
16731674 },
16741675 },
1675- SyncCommitteePool : syncCommitteePool ,
1676+ SyncCommitteePool : syncCommitteePool ,
1677+ OptimisticModeFetcher : & mockChain.ChainService {},
16761678 }
16771679 server .ProduceSyncCommitteeContribution (writer , request )
16781680 assert .Equal (t , http .StatusNotFound , writer .Code )
16791681 resp2 := & structs.ProduceSyncCommitteeContributionResponse {}
16801682 require .NoError (t , json .Unmarshal (writer .Body .Bytes (), resp2 ))
16811683 require .ErrorContains (t , "No subcommittee messages found" , errors .New (writer .Body .String ()))
16821684 })
1685+ t .Run ("Optimistic returns 503" , func (t * testing.T ) {
1686+ url := "http://example.com?slot=1&subcommittee_index=1&beacon_block_root=0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"
1687+ request := httptest .NewRequest (http .MethodGet , url , nil )
1688+ writer := httptest .NewRecorder ()
1689+ writer .Body = & bytes.Buffer {}
1690+ syncCommitteePool = synccommittee .NewStore ()
1691+ server = Server {
1692+ CoreService : & core.Service {
1693+ HeadFetcher : & mockChain.ChainService {
1694+ SyncCommitteeIndices : []primitives.CommitteeIndex {0 },
1695+ },
1696+ },
1697+ SyncCommitteePool : syncCommitteePool ,
1698+ OptimisticModeFetcher : & mockChain.ChainService {
1699+ Optimistic : true ,
1700+ },
1701+ }
1702+ server .ProduceSyncCommitteeContribution (writer , request )
1703+ assert .Equal (t , http .StatusServiceUnavailable , writer .Code )
1704+ })
16831705}
16841706
16851707func TestServer_RegisterValidator (t * testing.T ) {
0 commit comments