Skip to content

Commit

Permalink
test: add test to check that l1_inclusion_block_number query param fr…
Browse files Browse the repository at this point in the history
…om GET queries is correctly parsed
  • Loading branch information
samlaf committed Jan 8, 2025
1 parent 52f3c84 commit a3b6ca4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,21 @@ func TestHandlerGet(t *testing.T) {
expectedCode: http.StatusOK,
expectedBody: testCommitStr,
},
{
// make sure that the l1_inclusion_block_number query param is parsed correctly and passed to the storage's GET call.
name: "Success - OP Alt-DA with l1_inclusion_block_number query param",
url: fmt.Sprintf("/get/0x010000%s?l1_inclusion_block_number=100", testCommitStr),
mockBehavior: func() {
mockStorageMgr.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Eq(common.VerifyOptions{RollupL1InclusionBlockNum: 100})).Return([]byte(testCommitStr), nil)
},
expectedCode: http.StatusOK,
expectedBody: testCommitStr,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Log(tt.name)
tt.mockBehavior()

req := httptest.NewRequest(http.MethodGet, tt.url, nil)
Expand Down Expand Up @@ -158,6 +169,7 @@ func TestHandlerPutSuccess(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Log(tt.name)
tt.mockBehavior()

req := httptest.NewRequest(http.MethodPost, tt.url, bytes.NewReader(tt.body))
Expand Down Expand Up @@ -245,6 +257,7 @@ func TestHandlerPutErrors(t *testing.T) {
for _, tt := range tests {
for _, mode := range modes {
t.Run(tt.name+" / "+mode.name, func(t *testing.T) {
t.Log(tt.name + " / " + mode.name)
mockStorageMgr.EXPECT().Put(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil, tt.mockStorageMgrPutReturnedErr)

req := httptest.NewRequest(http.MethodPost, mode.url, strings.NewReader("optional body to be sent to eigenda"))
Expand Down
1 change: 1 addition & 0 deletions server/routing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func TestRouting(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Log(tt.name)
req := httptest.NewRequest(tt.method, tt.url, nil)
rec := httptest.NewRecorder()
server.httpServer.Handler.ServeHTTP(rec, req)
Expand Down

0 comments on commit a3b6ca4

Please sign in to comment.