- Backend REST/gateway/track routes, analytics, Blockscout proxy paths. - Frontend wallet and liquidity surfaces; MetaMask token list alignment. - Deployment docs, verification scripts, address inventory updates. Check: go build ./... under backend/ (pass). Made-with: Cursor
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package track1
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestHandleBlockDetailRejectsInvalidBlockNumber(t *testing.T) {
|
|
server := &Server{}
|
|
req := httptest.NewRequest(http.MethodGet, "/api/v1/track1/block/not-a-number", nil)
|
|
w := httptest.NewRecorder()
|
|
|
|
server.HandleBlockDetail(w, req)
|
|
|
|
if w.Code != http.StatusBadRequest {
|
|
t.Fatalf("expected 400 for invalid block number, got %d", w.Code)
|
|
}
|
|
}
|
|
|
|
func TestHandleTransactionDetailRejectsInvalidHash(t *testing.T) {
|
|
server := &Server{}
|
|
req := httptest.NewRequest(http.MethodGet, "/api/v1/track1/tx/not-a-hash", nil)
|
|
w := httptest.NewRecorder()
|
|
|
|
server.HandleTransactionDetail(w, req)
|
|
|
|
if w.Code != http.StatusBadRequest {
|
|
t.Fatalf("expected 400 for invalid tx hash, got %d", w.Code)
|
|
}
|
|
}
|
|
|
|
func TestHandleAddressBalanceRejectsInvalidAddress(t *testing.T) {
|
|
server := &Server{}
|
|
req := httptest.NewRequest(http.MethodGet, "/api/v1/track1/address/not-an-address/balance", nil)
|
|
w := httptest.NewRecorder()
|
|
|
|
server.HandleAddressBalance(w, req)
|
|
|
|
if w.Code != http.StatusBadRequest {
|
|
t.Fatalf("expected 400 for invalid address, got %d", w.Code)
|
|
}
|
|
}
|