Commit b79cb066 authored by Ethen Pociask's avatar Ethen Pociask

[indexer.client] Updated tests

parent fea2d96f
...@@ -135,7 +135,7 @@ func (a *API) startServer(ctx context.Context) error { ...@@ -135,7 +135,7 @@ func (a *API) startServer(ctx context.Context) error {
} }
// Update the port in the config in case the OS chose a different port // Update the port in the config in case the OS chose a different port
// than the one we requested (e.g. port 0) // than the one we requested (e.g. using port 0 to fetch a random open port)
a.serverConfig.Port = tcpAddr.Port a.serverConfig.Port = tcpAddr.Port
err = http.Serve(listener, server.Handler) err = http.Serve(listener, server.Handler)
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"github.com/ethereum-optimism/optimism/indexer/api/routes" "github.com/ethereum-optimism/optimism/indexer/api/models"
"github.com/ethereum-optimism/optimism/indexer/config" "github.com/ethereum-optimism/optimism/indexer/config"
"github.com/ethereum-optimism/optimism/indexer/database" "github.com/ethereum-optimism/optimism/indexer/database"
"github.com/ethereum-optimism/optimism/op-node/testlog" "github.com/ethereum-optimism/optimism/op-node/testlog"
...@@ -116,7 +116,7 @@ func TestL1BridgeDepositsHandler(t *testing.T) { ...@@ -116,7 +116,7 @@ func TestL1BridgeDepositsHandler(t *testing.T) {
assert.Equal(t, http.StatusOK, responseRecorder.Code) assert.Equal(t, http.StatusOK, responseRecorder.Code)
var resp routes.DepositResponse var resp models.DepositResponse
err = json.Unmarshal(responseRecorder.Body.Bytes(), &resp) err = json.Unmarshal(responseRecorder.Body.Bytes(), &resp)
assert.Nil(t, err) assert.Nil(t, err)
...@@ -137,7 +137,7 @@ func TestL2BridgeWithdrawalsByAddressHandler(t *testing.T) { ...@@ -137,7 +137,7 @@ func TestL2BridgeWithdrawalsByAddressHandler(t *testing.T) {
responseRecorder := httptest.NewRecorder() responseRecorder := httptest.NewRecorder()
api.router.ServeHTTP(responseRecorder, request) api.router.ServeHTTP(responseRecorder, request)
var resp routes.WithdrawalResponse var resp models.WithdrawalResponse
err = json.Unmarshal(responseRecorder.Body.Bytes(), &resp) err = json.Unmarshal(responseRecorder.Body.Bytes(), &resp)
assert.Nil(t, err) assert.Nil(t, err)
......
package models
// DepositItem ... Deposit item model for API responses
type DepositItem struct {
Guid string `json:"guid"`
From string `json:"from"`
To string `json:"to"`
Timestamp uint64 `json:"timestamp"`
L1BlockHash string `json:"l1BlockHash"`
L1TxHash string `json:"l1TxHash"`
L2TxHash string `json:"l2TxHash"`
Amount string `json:"amount"`
L1TokenAddress string `json:"l1TokenAddress"`
L2TokenAddress string `json:"l2TokenAddress"`
}
// DepositResponse ... Data model for API JSON response
type DepositResponse struct {
Cursor string `json:"cursor"`
HasNextPage bool `json:"hasNextPage"`
Items []DepositItem `json:"items"`
}
// WithdrawalItem ... Data model for API JSON response
type WithdrawalItem struct {
Guid string `json:"guid"`
From string `json:"from"`
To string `json:"to"`
TransactionHash string `json:"transactionHash"`
MessageHash string `json:"messageHash"`
Timestamp uint64 `json:"timestamp"`
L2BlockHash string `json:"l2BlockHash"`
Amount string `json:"amount"`
ProofTransactionHash string `json:"proofTransactionHash"`
ClaimTransactionHash string `json:"claimTransactionHash"`
L1TokenAddress string `json:"l1TokenAddress"`
L2TokenAddress string `json:"l2TokenAddress"`
}
// WithdrawalResponse ... Data model for API JSON response
type WithdrawalResponse struct {
Cursor string `json:"cursor"`
HasNextPage bool `json:"hasNextPage"`
Items []WithdrawalItem `json:"items"`
}
...@@ -3,37 +3,17 @@ package routes ...@@ -3,37 +3,17 @@ package routes
import ( import (
"net/http" "net/http"
"github.com/ethereum-optimism/optimism/indexer/api/models"
"github.com/ethereum-optimism/optimism/indexer/database" "github.com/ethereum-optimism/optimism/indexer/database"
"github.com/ethereum/go-ethereum/common"
"github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5"
) )
// DepositItem ... Deposit item model for API responses
type DepositItem struct {
Guid string `json:"guid"`
From string `json:"from"`
To string `json:"to"`
Timestamp uint64 `json:"timestamp"`
L1BlockHash string `json:"l1BlockHash"`
L1TxHash string `json:"l1TxHash"`
L2TxHash string `json:"l2TxHash"`
Amount string `json:"amount"`
L1TokenAddress string `json:"l1TokenAddress"`
L2TokenAddress string `json:"l2TokenAddress"`
}
// DepositResponse ... Data model for API JSON response
type DepositResponse struct {
Cursor string `json:"cursor"`
HasNextPage bool `json:"hasNextPage"`
Items []DepositItem `json:"items"`
}
// newDepositResponse ... Converts a database.L1BridgeDepositsResponse to an api.DepositResponse // newDepositResponse ... Converts a database.L1BridgeDepositsResponse to an api.DepositResponse
func newDepositResponse(deposits *database.L1BridgeDepositsResponse) DepositResponse { func newDepositResponse(deposits *database.L1BridgeDepositsResponse) models.DepositResponse {
items := make([]DepositItem, len(deposits.Deposits)) items := make([]models.DepositItem, len(deposits.Deposits))
for i, deposit := range deposits.Deposits { for i, deposit := range deposits.Deposits {
item := DepositItem{ item := models.DepositItem{
Guid: deposit.L1BridgeDeposit.TransactionSourceHash.String(), Guid: deposit.L1BridgeDeposit.TransactionSourceHash.String(),
L1BlockHash: deposit.L1BlockHash.String(), L1BlockHash: deposit.L1BlockHash.String(),
Timestamp: deposit.L1BridgeDeposit.Tx.Timestamp, Timestamp: deposit.L1BridgeDeposit.Tx.Timestamp,
...@@ -48,7 +28,7 @@ func newDepositResponse(deposits *database.L1BridgeDepositsResponse) DepositResp ...@@ -48,7 +28,7 @@ func newDepositResponse(deposits *database.L1BridgeDepositsResponse) DepositResp
items[i] = item items[i] = item
} }
return DepositResponse{ return models.DepositResponse{
Cursor: deposits.Cursor, Cursor: deposits.Cursor,
HasNextPage: deposits.HasNextPage, HasNextPage: deposits.HasNextPage,
Items: items, Items: items,
...@@ -57,10 +37,26 @@ func newDepositResponse(deposits *database.L1BridgeDepositsResponse) DepositResp ...@@ -57,10 +37,26 @@ func newDepositResponse(deposits *database.L1BridgeDepositsResponse) DepositResp
// L1DepositsHandler ... Handles /api/v0/deposits/{address} GET requests // L1DepositsHandler ... Handles /api/v0/deposits/{address} GET requests
func (h Routes) L1DepositsHandler(w http.ResponseWriter, r *http.Request) { func (h Routes) L1DepositsHandler(w http.ResponseWriter, r *http.Request) {
address := common.HexToAddress(chi.URLParam(r, "address")) addressValue := chi.URLParam(r, "address")
cursor := r.URL.Query().Get("cursor") cursor := r.URL.Query().Get("cursor")
limitQuery := r.URL.Query().Get("limit") limitQuery := r.URL.Query().Get("limit")
address, err := h.v.ParseValidateAddress(addressValue)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
h.logger.Error("Invalid address param", "param", addressValue)
h.logger.Error(err.Error())
return
}
err = h.v.ValidateCursor(cursor)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
h.logger.Error("Invalid cursor param", "param", cursor)
h.logger.Error(err.Error())
return
}
limit, err := h.v.ParseValidateLimit(limitQuery) limit, err := h.v.ParseValidateLimit(limitQuery)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
......
...@@ -9,8 +9,7 @@ import ( ...@@ -9,8 +9,7 @@ import (
) )
// Validator ... Validates API user request parameters // Validator ... Validates API user request parameters
type Validator struct { type Validator struct{}
}
// ParseValidateLimit ... Validates and parses the limit query parameters // ParseValidateLimit ... Validates and parses the limit query parameters
func (v *Validator) ParseValidateLimit(limit string) (int, error) { func (v *Validator) ParseValidateLimit(limit string) (int, error) {
...@@ -33,7 +32,7 @@ func (v *Validator) ParseValidateLimit(limit string) (int, error) { ...@@ -33,7 +32,7 @@ func (v *Validator) ParseValidateLimit(limit string) (int, error) {
// ParseValidateAddress ... Validates and parses the address query parameter // ParseValidateAddress ... Validates and parses the address query parameter
func (v *Validator) ParseValidateAddress(addr string) (common.Address, error) { func (v *Validator) ParseValidateAddress(addr string) (common.Address, error) {
if common.IsHexAddress(addr) { if !common.IsHexAddress(addr) {
return common.Address{}, errors.New("address must be represented as a valid hexadecimal string") return common.Address{}, errors.New("address must be represented as a valid hexadecimal string")
} }
...@@ -44,3 +43,20 @@ func (v *Validator) ParseValidateAddress(addr string) (common.Address, error) { ...@@ -44,3 +43,20 @@ func (v *Validator) ParseValidateAddress(addr string) (common.Address, error) {
return parsedAddr, nil return parsedAddr, nil
} }
// ValidateCursor ... Validates and parses the cursor query parameter
func (v *Validator) ValidateCursor(cursor string) error {
if cursor == "" {
return nil
}
if len(cursor) != 66 { // 0x + 64 chars
return errors.New("cursor must be a 32 byte hex string")
}
if cursor[:2] != "0x" {
return errors.New("cursor must begin with 0x")
}
return nil
}
...@@ -29,7 +29,7 @@ func Test_ParseValidateAddress(t *testing.T) { ...@@ -29,7 +29,7 @@ func Test_ParseValidateAddress(t *testing.T) {
v := Validator{} v := Validator{}
// (1) Happy case // (1) Happy case
addr := "0x1" addr := "0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5"
_, err := v.ParseValidateAddress(addr) _, err := v.ParseValidateAddress(addr)
require.NoError(t, err, "address should be pass") require.NoError(t, err, "address should be pass")
...@@ -39,7 +39,26 @@ func Test_ParseValidateAddress(t *testing.T) { ...@@ -39,7 +39,26 @@ func Test_ParseValidateAddress(t *testing.T) {
require.Error(t, err, "address must be represented as a valid hexadecimal string") require.Error(t, err, "address must be represented as a valid hexadecimal string")
// (3) Zero address // (3) Zero address
addr = "0x0" addr = "0x0000000000000000000000000000000000000000"
_, err = v.ParseValidateAddress(addr) _, err = v.ParseValidateAddress(addr)
require.Error(t, err, "address cannot be black-hole value") require.Error(t, err, "address cannot be black-hole value")
} }
func Test_ParseValidateCursor(t *testing.T) {
v := Validator{}
// (1) Happy case
cursor := "0xf3fd2eb696dab4263550b938726f9b3606e334cce6ebe27446bc26cb700b94e0"
err := v.ValidateCursor(cursor)
require.NoError(t, err, "cursor should be pass")
// (2) Invalid length
cursor = "0x000"
err = v.ValidateCursor(cursor)
require.Error(t, err, "cursor must be 32 byte hex string")
// (3) Invalid hex
cursor = "0🫡"
err = v.ValidateCursor(cursor)
require.Error(t, err, "cursor must start with 0x")
}
...@@ -3,37 +3,17 @@ package routes ...@@ -3,37 +3,17 @@ package routes
import ( import (
"net/http" "net/http"
"github.com/ethereum-optimism/optimism/indexer/api/models"
"github.com/ethereum-optimism/optimism/indexer/database" "github.com/ethereum-optimism/optimism/indexer/database"
"github.com/ethereum/go-ethereum/common"
"github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5"
) )
type WithdrawalItem struct {
Guid string `json:"guid"`
From string `json:"from"`
To string `json:"to"`
TransactionHash string `json:"transactionHash"`
MessageHash string `json:"messageHash"`
Timestamp uint64 `json:"timestamp"`
L2BlockHash string `json:"l2BlockHash"`
Amount string `json:"amount"`
ProofTransactionHash string `json:"proofTransactionHash"`
ClaimTransactionHash string `json:"claimTransactionHash"`
L1TokenAddress string `json:"l1TokenAddress"`
L2TokenAddress string `json:"l2TokenAddress"`
}
type WithdrawalResponse struct {
Cursor string `json:"cursor"`
HasNextPage bool `json:"hasNextPage"`
Items []WithdrawalItem `json:"items"`
}
// FIXME make a pure function that returns a struct instead of newWithdrawalResponse // FIXME make a pure function that returns a struct instead of newWithdrawalResponse
func newWithdrawalResponse(withdrawals *database.L2BridgeWithdrawalsResponse) WithdrawalResponse { // newWithdrawalResponse ... Converts a database.L2BridgeWithdrawalsResponse to an api.WithdrawalResponse
items := make([]WithdrawalItem, len(withdrawals.Withdrawals)) func newWithdrawalResponse(withdrawals *database.L2BridgeWithdrawalsResponse) models.WithdrawalResponse {
items := make([]models.WithdrawalItem, len(withdrawals.Withdrawals))
for i, withdrawal := range withdrawals.Withdrawals { for i, withdrawal := range withdrawals.Withdrawals {
item := WithdrawalItem{ item := models.WithdrawalItem{
Guid: withdrawal.L2BridgeWithdrawal.TransactionWithdrawalHash.String(), Guid: withdrawal.L2BridgeWithdrawal.TransactionWithdrawalHash.String(),
L2BlockHash: withdrawal.L2BlockHash.String(), L2BlockHash: withdrawal.L2BlockHash.String(),
From: withdrawal.L2BridgeWithdrawal.Tx.FromAddress.String(), From: withdrawal.L2BridgeWithdrawal.Tx.FromAddress.String(),
...@@ -48,7 +28,7 @@ func newWithdrawalResponse(withdrawals *database.L2BridgeWithdrawalsResponse) Wi ...@@ -48,7 +28,7 @@ func newWithdrawalResponse(withdrawals *database.L2BridgeWithdrawalsResponse) Wi
items[i] = item items[i] = item
} }
return WithdrawalResponse{ return models.WithdrawalResponse{
Cursor: withdrawals.Cursor, Cursor: withdrawals.Cursor,
HasNextPage: withdrawals.HasNextPage, HasNextPage: withdrawals.HasNextPage,
Items: items, Items: items,
...@@ -57,10 +37,26 @@ func newWithdrawalResponse(withdrawals *database.L2BridgeWithdrawalsResponse) Wi ...@@ -57,10 +37,26 @@ func newWithdrawalResponse(withdrawals *database.L2BridgeWithdrawalsResponse) Wi
// L2WithdrawalsHandler ... Handles /api/v0/withdrawals/{address} GET requests // L2WithdrawalsHandler ... Handles /api/v0/withdrawals/{address} GET requests
func (h Routes) L2WithdrawalsHandler(w http.ResponseWriter, r *http.Request) { func (h Routes) L2WithdrawalsHandler(w http.ResponseWriter, r *http.Request) {
address := common.HexToAddress(chi.URLParam(r, "address")) addressValue := chi.URLParam(r, "address")
cursor := r.URL.Query().Get("cursor") cursor := r.URL.Query().Get("cursor")
limitQuery := r.URL.Query().Get("limit") limitQuery := r.URL.Query().Get("limit")
address, err := h.v.ParseValidateAddress(addressValue)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
h.logger.Error("Invalid address param", "param", addressValue)
h.logger.Error(err.Error())
return
}
err = h.v.ValidateCursor(cursor)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
h.logger.Error("Invalid cursor param", "param", cursor)
h.logger.Error(err.Error())
return
}
limit, err := h.v.ParseValidateLimit(limitQuery) limit, err := h.v.ParseValidateLimit(limitQuery)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
......
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
"encoding/json" "encoding/json"
"github.com/ethereum-optimism/optimism/indexer/api" "github.com/ethereum-optimism/optimism/indexer/api"
"github.com/ethereum-optimism/optimism/indexer/api/routes" "github.com/ethereum-optimism/optimism/indexer/api/models"
"github.com/ethereum-optimism/optimism/indexer/node" "github.com/ethereum-optimism/optimism/indexer/node"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
) )
...@@ -123,8 +123,8 @@ func (c *Client) HealthCheck() error { ...@@ -123,8 +123,8 @@ func (c *Client) HealthCheck() error {
} }
// GetDepositsByAddress ... Gets a deposit response object provided an L1 address and cursor // GetDepositsByAddress ... Gets a deposit response object provided an L1 address and cursor
func (c *Client) GetDepositsByAddress(l1Address common.Address, cursor string) (*routes.DepositResponse, error) { func (c *Client) GetDepositsByAddress(l1Address common.Address, cursor string) (*models.DepositResponse, error) {
var dResponse *routes.DepositResponse var dResponse *models.DepositResponse
url := c.cfg.BaseURL + api.DepositsPath + l1Address.String() + urlParams url := c.cfg.BaseURL + api.DepositsPath + l1Address.String() + urlParams
endpoint := fmt.Sprintf(url, cursor, c.cfg.PaginationLimit) endpoint := fmt.Sprintf(url, cursor, c.cfg.PaginationLimit)
...@@ -141,8 +141,8 @@ func (c *Client) GetDepositsByAddress(l1Address common.Address, cursor string) ( ...@@ -141,8 +141,8 @@ func (c *Client) GetDepositsByAddress(l1Address common.Address, cursor string) (
} }
// GetAllDepositsByAddress ... Gets all deposits provided a L1 address // GetAllDepositsByAddress ... Gets all deposits provided a L1 address
func (c *Client) GetAllDepositsByAddress(l1Address common.Address) ([]routes.DepositItem, error) { func (c *Client) GetAllDepositsByAddress(l1Address common.Address) ([]models.DepositItem, error) {
var deposits []routes.DepositItem var deposits []models.DepositItem
cursor := "" cursor := ""
for { for {
...@@ -165,8 +165,8 @@ func (c *Client) GetAllDepositsByAddress(l1Address common.Address) ([]routes.Dep ...@@ -165,8 +165,8 @@ func (c *Client) GetAllDepositsByAddress(l1Address common.Address) ([]routes.Dep
} }
// GetAllWithdrawalsByAddress ... Gets all withdrawals provided a L2 address // GetAllWithdrawalsByAddress ... Gets all withdrawals provided a L2 address
func (c *Client) GetAllWithdrawalsByAddress(l2Address common.Address) ([]routes.WithdrawalItem, error) { func (c *Client) GetAllWithdrawalsByAddress(l2Address common.Address) ([]models.WithdrawalItem, error) {
var withdrawals []routes.WithdrawalItem var withdrawals []models.WithdrawalItem
cursor := "" cursor := ""
for { for {
...@@ -188,8 +188,8 @@ func (c *Client) GetAllWithdrawalsByAddress(l2Address common.Address) ([]routes. ...@@ -188,8 +188,8 @@ func (c *Client) GetAllWithdrawalsByAddress(l2Address common.Address) ([]routes.
} }
// GetWithdrawalsByAddress ... Gets a withdrawal response object provided an L2 address and cursor // GetWithdrawalsByAddress ... Gets a withdrawal response object provided an L2 address and cursor
func (c *Client) GetWithdrawalsByAddress(l2Address common.Address, cursor string) (*routes.WithdrawalResponse, error) { func (c *Client) GetWithdrawalsByAddress(l2Address common.Address, cursor string) (*models.WithdrawalResponse, error) {
var wResponse *routes.WithdrawalResponse var wResponse *models.WithdrawalResponse
url := c.cfg.BaseURL + api.WithdrawalsPath + l2Address.String() + urlParams url := c.cfg.BaseURL + api.WithdrawalsPath + l2Address.String() + urlParams
endpoint := fmt.Sprintf(url, cursor, c.cfg.PaginationLimit) endpoint := fmt.Sprintf(url, cursor, c.cfg.PaginationLimit)
......
...@@ -52,7 +52,7 @@ func TestE2EBridgeTransfersStandardBridgeETHDeposit(t *testing.T) { ...@@ -52,7 +52,7 @@ func TestE2EBridgeTransfersStandardBridgeETHDeposit(t *testing.T) {
})) }))
cursor := "" cursor := ""
limit := 0 limit := 100
aliceDeposits, err := testSuite.DB.BridgeTransfers.L1BridgeDepositsByAddress(aliceAddr, cursor, limit) aliceDeposits, err := testSuite.DB.BridgeTransfers.L1BridgeDepositsByAddress(aliceAddr, cursor, limit)
...@@ -118,7 +118,7 @@ func TestE2EBridgeTransfersOptimismPortalETHReceive(t *testing.T) { ...@@ -118,7 +118,7 @@ func TestE2EBridgeTransfersOptimismPortalETHReceive(t *testing.T) {
return l1Header != nil && l1Header.Number.Uint64() >= portalDepositReceipt.BlockNumber.Uint64(), nil return l1Header != nil && l1Header.Number.Uint64() >= portalDepositReceipt.BlockNumber.Uint64(), nil
})) }))
aliceDeposits, err := testSuite.DB.BridgeTransfers.L1BridgeDepositsByAddress(aliceAddr, "", 0) aliceDeposits, err := testSuite.DB.BridgeTransfers.L1BridgeDepositsByAddress(aliceAddr, "", 1)
require.NoError(t, err) require.NoError(t, err)
require.NotNil(t, aliceDeposits) require.NotNil(t, aliceDeposits)
require.Len(t, aliceDeposits.Deposits, 1) require.Len(t, aliceDeposits.Deposits, 1)
...@@ -145,7 +145,7 @@ func TestE2EBridgeTransfersOptimismPortalETHReceive(t *testing.T) { ...@@ -145,7 +145,7 @@ func TestE2EBridgeTransfersOptimismPortalETHReceive(t *testing.T) {
})) }))
// Still nil as the withdrawal did not occur through the standard bridge // Still nil as the withdrawal did not occur through the standard bridge
aliceDeposits, err = testSuite.DB.BridgeTransfers.L1BridgeDepositsByAddress(aliceAddr, "", 0) aliceDeposits, err = testSuite.DB.BridgeTransfers.L1BridgeDepositsByAddress(aliceAddr, "", 1)
require.NoError(t, err) require.NoError(t, err)
require.Nil(t, aliceDeposits.Deposits[0].L1BridgeDeposit.CrossDomainMessageHash) require.Nil(t, aliceDeposits.Deposits[0].L1BridgeDeposit.CrossDomainMessageHash)
} }
...@@ -187,7 +187,7 @@ func TestE2EBridgeTransfersCursoredDeposits(t *testing.T) { ...@@ -187,7 +187,7 @@ func TestE2EBridgeTransfersCursoredDeposits(t *testing.T) {
})) }))
// Get All // Get All
aliceDeposits, err := testSuite.DB.BridgeTransfers.L1BridgeDepositsByAddress(aliceAddr, "", 0) aliceDeposits, err := testSuite.DB.BridgeTransfers.L1BridgeDepositsByAddress(aliceAddr, "", 3)
require.NotNil(t, aliceDeposits) require.NotNil(t, aliceDeposits)
require.NoError(t, err) require.NoError(t, err)
require.Len(t, aliceDeposits.Deposits, 3) require.Len(t, aliceDeposits.Deposits, 3)
...@@ -200,14 +200,14 @@ func TestE2EBridgeTransfersCursoredDeposits(t *testing.T) { ...@@ -200,14 +200,14 @@ func TestE2EBridgeTransfersCursoredDeposits(t *testing.T) {
require.Len(t, aliceDeposits.Deposits, 2) require.Len(t, aliceDeposits.Deposits, 2)
require.True(t, aliceDeposits.HasNextPage) require.True(t, aliceDeposits.HasNextPage)
aliceDeposits, err = testSuite.DB.BridgeTransfers.L1BridgeDepositsByAddress(aliceAddr, aliceDeposits.Cursor, 2) aliceDeposits, err = testSuite.DB.BridgeTransfers.L1BridgeDepositsByAddress(aliceAddr, aliceDeposits.Cursor, 1)
require.NoError(t, err) require.NoError(t, err)
require.NotNil(t, aliceDeposits) require.NotNil(t, aliceDeposits)
require.Len(t, aliceDeposits.Deposits, 1) require.Len(t, aliceDeposits.Deposits, 1)
require.False(t, aliceDeposits.HasNextPage) require.False(t, aliceDeposits.HasNextPage)
// Returns the results in the right order // Returns the results in the right order
aliceDeposits, err = testSuite.DB.BridgeTransfers.L1BridgeDepositsByAddress(aliceAddr, "", 100) aliceDeposits, err = testSuite.DB.BridgeTransfers.L1BridgeDepositsByAddress(aliceAddr, "", 3)
require.NotNil(t, aliceDeposits) require.NotNil(t, aliceDeposits)
require.NoError(t, err) require.NoError(t, err)
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
......
...@@ -26,6 +26,7 @@ import ( ...@@ -26,6 +26,7 @@ import (
/* /*
NOTE - Most of the current tests fetch chain data via direct database queries. These could all NOTE - Most of the current tests fetch chain data via direct database queries. These could all
be transitioned to use the API client instead to better simulate/validate real-world usage. be transitioned to use the API client instead to better simulate/validate real-world usage.
Supporting this would potentially require adding new API endpoints for the specific query lookup types.
*/ */
type E2ETestSuite struct { type E2ETestSuite struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment