mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Fix errors when fromItem is not provided
This commit is contained in:
@@ -74,40 +74,40 @@ func TestGetAccounts(t *testing.T) {
|
|||||||
stringIds := strconv.Itoa(int(tc.tokens[2].TokenID)) + "," + strconv.Itoa(int(tc.tokens[5].TokenID)) + "," + strconv.Itoa(int(tc.tokens[6].TokenID))
|
stringIds := strconv.Itoa(int(tc.tokens[2].TokenID)) + "," + strconv.Itoa(int(tc.tokens[5].TokenID)) + "," + strconv.Itoa(int(tc.tokens[6].TokenID))
|
||||||
|
|
||||||
// Filter by BJJ
|
// Filter by BJJ
|
||||||
path := fmt.Sprintf("%s?BJJ=%s&limit=%d&fromItem=", endpoint, tc.accounts[0].PublicKey, limit)
|
path := fmt.Sprintf("%s?BJJ=%s&limit=%d", endpoint, tc.accounts[0].PublicKey, limit)
|
||||||
err := doGoodReqPaginated(path, historydb.OrderAsc, &testAccountsResponse{}, appendIter)
|
err := doGoodReqPaginated(path, historydb.OrderAsc, &testAccountsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Greater(t, len(fetchedAccounts), 0)
|
assert.Greater(t, len(fetchedAccounts), 0)
|
||||||
assert.LessOrEqual(t, len(fetchedAccounts), len(tc.accounts))
|
assert.LessOrEqual(t, len(fetchedAccounts), len(tc.accounts))
|
||||||
fetchedAccounts = []testAccount{}
|
fetchedAccounts = []testAccount{}
|
||||||
// Filter by ethAddr
|
// Filter by ethAddr
|
||||||
path = fmt.Sprintf("%s?hermezEthereumAddress=%s&limit=%d&fromItem=", endpoint, tc.accounts[3].EthAddr, limit)
|
path = fmt.Sprintf("%s?hermezEthereumAddress=%s&limit=%d", endpoint, tc.accounts[3].EthAddr, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testAccountsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testAccountsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Greater(t, len(fetchedAccounts), 0)
|
assert.Greater(t, len(fetchedAccounts), 0)
|
||||||
assert.LessOrEqual(t, len(fetchedAccounts), len(tc.accounts))
|
assert.LessOrEqual(t, len(fetchedAccounts), len(tc.accounts))
|
||||||
fetchedAccounts = []testAccount{}
|
fetchedAccounts = []testAccount{}
|
||||||
// both filters (incompatible)
|
// both filters (incompatible)
|
||||||
path = fmt.Sprintf("%s?hermezEthereumAddress=%s&BJJ=%s&limit=%d&fromItem=", endpoint, tc.accounts[0].EthAddr, tc.accounts[0].PublicKey, limit)
|
path = fmt.Sprintf("%s?hermezEthereumAddress=%s&BJJ=%s&limit=%d", endpoint, tc.accounts[0].EthAddr, tc.accounts[0].PublicKey, limit)
|
||||||
err = doBadReq("GET", path, nil, 400)
|
err = doBadReq("GET", path, nil, 400)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
fetchedAccounts = []testAccount{}
|
fetchedAccounts = []testAccount{}
|
||||||
// Filter by token IDs
|
// Filter by token IDs
|
||||||
path = fmt.Sprintf("%s?tokenIds=%s&limit=%d&fromItem=", endpoint, stringIds, limit)
|
path = fmt.Sprintf("%s?tokenIds=%s&limit=%d", endpoint, stringIds, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testAccountsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testAccountsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Greater(t, len(fetchedAccounts), 0)
|
assert.Greater(t, len(fetchedAccounts), 0)
|
||||||
assert.LessOrEqual(t, len(fetchedAccounts), len(tc.accounts))
|
assert.LessOrEqual(t, len(fetchedAccounts), len(tc.accounts))
|
||||||
fetchedAccounts = []testAccount{}
|
fetchedAccounts = []testAccount{}
|
||||||
// Token Ids + bjj
|
// Token Ids + bjj
|
||||||
path = fmt.Sprintf("%s?tokenIds=%s&BJJ=%s&limit=%d&fromItem=", endpoint, stringIds, tc.accounts[10].PublicKey, limit)
|
path = fmt.Sprintf("%s?tokenIds=%s&BJJ=%s&limit=%d", endpoint, stringIds, tc.accounts[10].PublicKey, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testAccountsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testAccountsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Greater(t, len(fetchedAccounts), 0)
|
assert.Greater(t, len(fetchedAccounts), 0)
|
||||||
assert.LessOrEqual(t, len(fetchedAccounts), len(tc.accounts))
|
assert.LessOrEqual(t, len(fetchedAccounts), len(tc.accounts))
|
||||||
fetchedAccounts = []testAccount{}
|
fetchedAccounts = []testAccount{}
|
||||||
// No filters (checks response content)
|
// No filters (checks response content)
|
||||||
path = fmt.Sprintf("%s?limit=%d&fromItem=", endpoint, limit)
|
path = fmt.Sprintf("%s?limit=%d", endpoint, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testAccountsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testAccountsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, len(tc.accounts), len(fetchedAccounts))
|
assert.Equal(t, len(tc.accounts), len(fetchedAccounts))
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ func TestMain(m *testing.M) {
|
|||||||
// Swagger
|
// Swagger
|
||||||
router := swagger.NewRouter().WithSwaggerFromFile("./swagger.yml")
|
router := swagger.NewRouter().WithSwaggerFromFile("./swagger.yml")
|
||||||
// HistoryDB
|
// HistoryDB
|
||||||
pass := os.Getenv("POSTGRES_PASS")
|
pass := "yourpasswordhere" // os.Getenv("POSTGRES_PASS")
|
||||||
|
|
||||||
database, err := db.InitSQLDB(5432, "localhost", "hermez", pass, "hermez")
|
database, err := db.InitSQLDB(5432, "localhost", "hermez", pass, "hermez")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -456,15 +456,8 @@ func doGoodReqPaginated(
|
|||||||
for {
|
for {
|
||||||
// Calculate fromItem
|
// Calculate fromItem
|
||||||
iterPath := path
|
iterPath := path
|
||||||
if firstIte {
|
if !firstIte {
|
||||||
if order == historydb.OrderDesc {
|
iterPath += "&fromItem=" + strconv.Itoa(int(next))
|
||||||
// Fetch first item in reverse order
|
|
||||||
iterPath += "99999" // Asumption that for testing there won't be any itemID > 99999
|
|
||||||
} else {
|
|
||||||
iterPath += "0"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
iterPath += strconv.Itoa(int(next))
|
|
||||||
}
|
}
|
||||||
// Call API to get this iteration items
|
// Call API to get this iteration items
|
||||||
iterStruct = iterStruct.New()
|
iterStruct = iterStruct.New()
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ func TestGetBatches(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// Get all (no filters)
|
// Get all (no filters)
|
||||||
limit := 3
|
limit := 3
|
||||||
path := fmt.Sprintf("%s?limit=%d&fromItem=", endpoint, limit)
|
path := fmt.Sprintf("%s?limit=%d", endpoint, limit)
|
||||||
err := doGoodReqPaginated(path, historydb.OrderAsc, &testBatchesResponse{}, appendIter)
|
err := doGoodReqPaginated(path, historydb.OrderAsc, &testBatchesResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assertBatches(t, tc.batches, fetchedBatches)
|
assertBatches(t, tc.batches, fetchedBatches)
|
||||||
@@ -128,7 +128,7 @@ func TestGetBatches(t *testing.T) {
|
|||||||
fetchedBatches = []testBatch{}
|
fetchedBatches = []testBatch{}
|
||||||
limit = 2
|
limit = 2
|
||||||
minBatchNum := tc.batches[len(tc.batches)/2].BatchNum
|
minBatchNum := tc.batches[len(tc.batches)/2].BatchNum
|
||||||
path = fmt.Sprintf("%s?minBatchNum=%d&limit=%d&fromItem=", endpoint, minBatchNum, limit)
|
path = fmt.Sprintf("%s?minBatchNum=%d&limit=%d", endpoint, minBatchNum, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBatchesResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBatchesResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
minBatchNumBatches := []testBatch{}
|
minBatchNumBatches := []testBatch{}
|
||||||
@@ -143,7 +143,7 @@ func TestGetBatches(t *testing.T) {
|
|||||||
fetchedBatches = []testBatch{}
|
fetchedBatches = []testBatch{}
|
||||||
limit = 1
|
limit = 1
|
||||||
maxBatchNum := tc.batches[len(tc.batches)/2].BatchNum
|
maxBatchNum := tc.batches[len(tc.batches)/2].BatchNum
|
||||||
path = fmt.Sprintf("%s?maxBatchNum=%d&limit=%d&fromItem=", endpoint, maxBatchNum, limit)
|
path = fmt.Sprintf("%s?maxBatchNum=%d&limit=%d", endpoint, maxBatchNum, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBatchesResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBatchesResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
maxBatchNumBatches := []testBatch{}
|
maxBatchNumBatches := []testBatch{}
|
||||||
@@ -158,7 +158,7 @@ func TestGetBatches(t *testing.T) {
|
|||||||
fetchedBatches = []testBatch{}
|
fetchedBatches = []testBatch{}
|
||||||
limit = 5
|
limit = 5
|
||||||
slotNum := tc.batches[len(tc.batches)/2].SlotNum
|
slotNum := tc.batches[len(tc.batches)/2].SlotNum
|
||||||
path = fmt.Sprintf("%s?slotNum=%d&limit=%d&fromItem=", endpoint, slotNum, limit)
|
path = fmt.Sprintf("%s?slotNum=%d&limit=%d", endpoint, slotNum, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBatchesResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBatchesResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
slotNumBatches := []testBatch{}
|
slotNumBatches := []testBatch{}
|
||||||
@@ -173,7 +173,7 @@ func TestGetBatches(t *testing.T) {
|
|||||||
fetchedBatches = []testBatch{}
|
fetchedBatches = []testBatch{}
|
||||||
limit = 10
|
limit = 10
|
||||||
forgerAddr := tc.batches[len(tc.batches)/2].ForgerAddr
|
forgerAddr := tc.batches[len(tc.batches)/2].ForgerAddr
|
||||||
path = fmt.Sprintf("%s?forgerAddr=%s&limit=%d&fromItem=", endpoint, forgerAddr.String(), limit)
|
path = fmt.Sprintf("%s?forgerAddr=%s&limit=%d", endpoint, forgerAddr.String(), limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBatchesResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBatchesResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
forgerAddrBatches := []testBatch{}
|
forgerAddrBatches := []testBatch{}
|
||||||
@@ -187,7 +187,7 @@ func TestGetBatches(t *testing.T) {
|
|||||||
// All, in reverse order
|
// All, in reverse order
|
||||||
fetchedBatches = []testBatch{}
|
fetchedBatches = []testBatch{}
|
||||||
limit = 6
|
limit = 6
|
||||||
path = fmt.Sprintf("%s?limit=%d&fromItem=", endpoint, limit)
|
path = fmt.Sprintf("%s?limit=%d", endpoint, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderDesc, &testBatchesResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderDesc, &testBatchesResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
flippedBatches := []testBatch{}
|
flippedBatches := []testBatch{}
|
||||||
@@ -201,7 +201,7 @@ func TestGetBatches(t *testing.T) {
|
|||||||
limit = 1
|
limit = 1
|
||||||
maxBatchNum = tc.batches[len(tc.batches)-len(tc.batches)/4].BatchNum
|
maxBatchNum = tc.batches[len(tc.batches)-len(tc.batches)/4].BatchNum
|
||||||
minBatchNum = tc.batches[len(tc.batches)/4].BatchNum
|
minBatchNum = tc.batches[len(tc.batches)/4].BatchNum
|
||||||
path = fmt.Sprintf("%s?minBatchNum=%d&maxBatchNum=%d&limit=%d&fromItem=", endpoint, minBatchNum, maxBatchNum, limit)
|
path = fmt.Sprintf("%s?minBatchNum=%d&maxBatchNum=%d&limit=%d", endpoint, minBatchNum, maxBatchNum, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBatchesResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBatchesResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
minMaxBatchNumBatches := []testBatch{}
|
minMaxBatchNumBatches := []testBatch{}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ func TestGetBids(t *testing.T) {
|
|||||||
// bidderAddress
|
// bidderAddress
|
||||||
fetchedBids = []testBid{}
|
fetchedBids = []testBid{}
|
||||||
bidderAddress := tc.bids[3].Bidder
|
bidderAddress := tc.bids[3].Bidder
|
||||||
path := fmt.Sprintf("%s?bidderAddr=%s&limit=%d&fromItem=", endpoint, bidderAddress.String(), limit)
|
path := fmt.Sprintf("%s?bidderAddr=%s&limit=%d", endpoint, bidderAddress.String(), limit)
|
||||||
err := doGoodReqPaginated(path, historydb.OrderAsc, &testBidsResponse{}, appendIter)
|
err := doGoodReqPaginated(path, historydb.OrderAsc, &testBidsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
bidderAddrBids := []testBid{}
|
bidderAddrBids := []testBid{}
|
||||||
@@ -90,7 +90,7 @@ func TestGetBids(t *testing.T) {
|
|||||||
// slotNum
|
// slotNum
|
||||||
fetchedBids = []testBid{}
|
fetchedBids = []testBid{}
|
||||||
slotNum := tc.bids[3].SlotNum
|
slotNum := tc.bids[3].SlotNum
|
||||||
path = fmt.Sprintf("%s?slotNum=%d&limit=%d&fromItem=", endpoint, slotNum, limit)
|
path = fmt.Sprintf("%s?slotNum=%d&limit=%d", endpoint, slotNum, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBidsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBidsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
slotNumBids := []testBid{}
|
slotNumBids := []testBid{}
|
||||||
@@ -103,7 +103,7 @@ func TestGetBids(t *testing.T) {
|
|||||||
|
|
||||||
// slotNum, in reverse order
|
// slotNum, in reverse order
|
||||||
fetchedBids = []testBid{}
|
fetchedBids = []testBid{}
|
||||||
path = fmt.Sprintf("%s?slotNum=%d&limit=%d&fromItem=", endpoint, slotNum, limit)
|
path = fmt.Sprintf("%s?slotNum=%d&limit=%d", endpoint, slotNum, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderDesc, &testBidsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderDesc, &testBidsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
flippedBids := []testBid{}
|
flippedBids := []testBid{}
|
||||||
@@ -116,7 +116,7 @@ func TestGetBids(t *testing.T) {
|
|||||||
fetchedBids = []testBid{}
|
fetchedBids = []testBid{}
|
||||||
bidderAddress = tc.bids[1].Bidder
|
bidderAddress = tc.bids[1].Bidder
|
||||||
slotNum = tc.bids[1].SlotNum
|
slotNum = tc.bids[1].SlotNum
|
||||||
path = fmt.Sprintf("%s?bidderAddr=%s&slotNum=%d&limit=%d&fromItem=", endpoint, bidderAddress.String(), slotNum, limit)
|
path = fmt.Sprintf("%s?bidderAddr=%s&slotNum=%d&limit=%d", endpoint, bidderAddress.String(), slotNum, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBidsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testBidsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
slotNumBidderAddrBids := []testBid{}
|
slotNumBidderAddrBids := []testBid{}
|
||||||
@@ -129,7 +129,7 @@ func TestGetBids(t *testing.T) {
|
|||||||
|
|
||||||
// 400
|
// 400
|
||||||
// No filters
|
// No filters
|
||||||
path = fmt.Sprintf("%s?limit=%d&fromItem=", endpoint, limit)
|
path = fmt.Sprintf("%s?limit=%d", endpoint, limit)
|
||||||
err = doBadReq("GET", path, nil, 400)
|
err = doBadReq("GET", path, nil, 400)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
// Invalid slotNum
|
// Invalid slotNum
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ func TestGetCoordinators(t *testing.T) {
|
|||||||
|
|
||||||
// All
|
// All
|
||||||
limit := 5
|
limit := 5
|
||||||
path := fmt.Sprintf("%s?limit=%d&fromItem=", endpoint, limit)
|
path := fmt.Sprintf("%s?limit=%d", endpoint, limit)
|
||||||
err := doGoodReqPaginated(path, historydb.OrderAsc, &testCoordinatorsResponse{}, appendIter)
|
err := doGoodReqPaginated(path, historydb.OrderAsc, &testCoordinatorsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assertCoordinators(t, tc.coordinators, fetchedCoordinators)
|
assertCoordinators(t, tc.coordinators, fetchedCoordinators)
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ func TestGetExits(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// Get all (no filters)
|
// Get all (no filters)
|
||||||
limit := 8
|
limit := 8
|
||||||
path := fmt.Sprintf("%s?limit=%d&fromItem=", endpoint, limit)
|
path := fmt.Sprintf("%s?limit=%d", endpoint, limit)
|
||||||
err := doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
err := doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assertExitAPIs(t, tc.exits, fetchedExits)
|
assertExitAPIs(t, tc.exits, fetchedExits)
|
||||||
@@ -124,7 +124,7 @@ func TestGetExits(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?hermezEthereumAddress=%s&limit=%d&fromItem=",
|
"%s?hermezEthereumAddress=%s&limit=%d",
|
||||||
endpoint, account.EthAddr, limit,
|
endpoint, account.EthAddr, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
||||||
@@ -144,7 +144,7 @@ func TestGetExits(t *testing.T) {
|
|||||||
fetchedExits = []testExit{}
|
fetchedExits = []testExit{}
|
||||||
limit = 6
|
limit = 6
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?BJJ=%s&limit=%d&fromItem=",
|
"%s?BJJ=%s&limit=%d",
|
||||||
endpoint, account.PublicKey, limit,
|
endpoint, account.PublicKey, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
||||||
@@ -155,7 +155,7 @@ func TestGetExits(t *testing.T) {
|
|||||||
limit = 5
|
limit = 5
|
||||||
tokenID := tc.exits[0].Token.TokenID
|
tokenID := tc.exits[0].Token.TokenID
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?tokenId=%d&limit=%d&fromItem=",
|
"%s?tokenId=%d&limit=%d",
|
||||||
endpoint, tokenID, limit,
|
endpoint, tokenID, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
||||||
@@ -172,7 +172,7 @@ func TestGetExits(t *testing.T) {
|
|||||||
limit = 4
|
limit = 4
|
||||||
idx := tc.exits[0].AccountIdx
|
idx := tc.exits[0].AccountIdx
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?accountIndex=%s&limit=%d&fromItem=",
|
"%s?accountIndex=%s&limit=%d",
|
||||||
endpoint, idx, limit,
|
endpoint, idx, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
||||||
@@ -189,7 +189,7 @@ func TestGetExits(t *testing.T) {
|
|||||||
limit = 3
|
limit = 3
|
||||||
batchNum := tc.exits[0].BatchNum
|
batchNum := tc.exits[0].BatchNum
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?batchNum=%d&limit=%d&fromItem=",
|
"%s?batchNum=%d&limit=%d",
|
||||||
endpoint, batchNum, limit,
|
endpoint, batchNum, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
||||||
@@ -205,7 +205,7 @@ func TestGetExits(t *testing.T) {
|
|||||||
fetchedExits = []testExit{}
|
fetchedExits = []testExit{}
|
||||||
limit = 7
|
limit = 7
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?&onlyPendingWithdraws=%t&limit=%d&fromItem=",
|
"%s?&onlyPendingWithdraws=%t&limit=%d",
|
||||||
endpoint, true, limit,
|
endpoint, true, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
||||||
@@ -221,7 +221,7 @@ func TestGetExits(t *testing.T) {
|
|||||||
fetchedExits = []testExit{}
|
fetchedExits = []testExit{}
|
||||||
limit = 1
|
limit = 1
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?batchNum=%d&tokeId=%d&limit=%d&fromItem=",
|
"%s?batchNum=%d&tokeId=%d&limit=%d",
|
||||||
endpoint, batchNum, tokenID, limit,
|
endpoint, batchNum, tokenID, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)
|
||||||
@@ -238,7 +238,7 @@ func TestGetExits(t *testing.T) {
|
|||||||
// All, in reverse order
|
// All, in reverse order
|
||||||
fetchedExits = []testExit{}
|
fetchedExits = []testExit{}
|
||||||
limit = 5
|
limit = 5
|
||||||
path = fmt.Sprintf("%s?limit=%d&fromItem=", endpoint, limit)
|
path = fmt.Sprintf("%s?limit=%d", endpoint, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderDesc, &testExitsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderDesc, &testExitsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assertExitAPIs(t, flipedExits, fetchedExits)
|
assertExitAPIs(t, flipedExits, fetchedExits)
|
||||||
@@ -256,7 +256,7 @@ func TestGetExits(t *testing.T) {
|
|||||||
path = fmt.Sprintf("%s?batchNum=999999", endpoint)
|
path = fmt.Sprintf("%s?batchNum=999999", endpoint)
|
||||||
err = doBadReq("GET", path, nil, 404)
|
err = doBadReq("GET", path, nil, 404)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
path = fmt.Sprintf("%s?limit=1000&fromItem=999999", endpoint)
|
path = fmt.Sprintf("%s?fromItem=1000999999", endpoint)
|
||||||
err = doBadReq("GET", path, nil, 404)
|
err = doBadReq("GET", path, nil, 404)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|||||||
15
api/slots.go
15
api/slots.go
@@ -65,11 +65,11 @@ func (a *API) newSlotsAPIFromWinnerBids(fromItem *uint, order string, bids []his
|
|||||||
slotNum := bids[i].SlotNum
|
slotNum := bids[i].SlotNum
|
||||||
slot := a.newSlotAPI(slotNum, currentBlockNum, &bids[i], auctionVars)
|
slot := a.newSlotAPI(slotNum, currentBlockNum, &bids[i], auctionVars)
|
||||||
if order == historydb.OrderAsc {
|
if order == historydb.OrderAsc {
|
||||||
if slot.ItemID >= uint64(*fromItem) {
|
if fromItem == nil || slot.ItemID >= uint64(*fromItem) {
|
||||||
slots = append(slots, slot)
|
slots = append(slots, slot)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if slot.ItemID <= uint64(*fromItem) {
|
if fromItem == nil || slot.ItemID <= uint64(*fromItem) {
|
||||||
slots = append(slots, slot)
|
slots = append(slots, slot)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,11 +80,11 @@ func (a *API) newSlotsAPIFromWinnerBids(fromItem *uint, order string, bids []his
|
|||||||
func (a *API) addEmptySlot(slots []SlotAPI, slotNum int64, currentBlockNum int64, auctionVars *common.AuctionVariables, fromItem *uint, order string) ([]SlotAPI, error) {
|
func (a *API) addEmptySlot(slots []SlotAPI, slotNum int64, currentBlockNum int64, auctionVars *common.AuctionVariables, fromItem *uint, order string) ([]SlotAPI, error) {
|
||||||
emptySlot := a.newSlotAPI(slotNum, currentBlockNum, nil, auctionVars)
|
emptySlot := a.newSlotAPI(slotNum, currentBlockNum, nil, auctionVars)
|
||||||
if order == historydb.OrderAsc {
|
if order == historydb.OrderAsc {
|
||||||
if emptySlot.ItemID >= uint64(*fromItem) {
|
if fromItem == nil || emptySlot.ItemID >= uint64(*fromItem) {
|
||||||
slots = append(slots, emptySlot)
|
slots = append(slots, emptySlot)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if emptySlot.ItemID <= uint64(*fromItem) {
|
if fromItem == nil || emptySlot.ItemID <= uint64(*fromItem) {
|
||||||
slots = append([]SlotAPI{emptySlot}, slots...)
|
slots = append([]SlotAPI{emptySlot}, slots...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,6 +175,9 @@ func getLimitsWithAddr(minSlotNum, maxSlotNum *int64, fromItem, limit *uint, ord
|
|||||||
maxLim = *maxSlotNum
|
maxLim = *maxSlotNum
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
maxLim = *maxSlotNum
|
||||||
|
minLim = *minSlotNum
|
||||||
}
|
}
|
||||||
return minLim, maxLim
|
return minLim, maxLim
|
||||||
}
|
}
|
||||||
@@ -285,11 +288,11 @@ func (a *API) getSlots(c *gin.Context) {
|
|||||||
if slotsBids[j].SlotNum == i {
|
if slotsBids[j].SlotNum == i {
|
||||||
found = true
|
found = true
|
||||||
if order == historydb.OrderAsc {
|
if order == historydb.OrderAsc {
|
||||||
if slotsBids[j].ItemID >= uint64(*fromItem) {
|
if fromItem == nil || slotsBids[j].ItemID >= uint64(*fromItem) {
|
||||||
slots = append(slots, slotsBids[j])
|
slots = append(slots, slotsBids[j])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if slotsBids[j].ItemID <= uint64(*fromItem) {
|
if fromItem == nil || slotsBids[j].ItemID <= uint64(*fromItem) {
|
||||||
slots = append([]SlotAPI{slotsBids[j]}, slots...)
|
slots = append([]SlotAPI{slotsBids[j]}, slots...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ func TestGetSlots(t *testing.T) {
|
|||||||
// All slots with maxSlotNum filter
|
// All slots with maxSlotNum filter
|
||||||
maxSlotNum := tc.slots[len(tc.slots)-1].SlotNum + 5
|
maxSlotNum := tc.slots[len(tc.slots)-1].SlotNum + 5
|
||||||
limit := 1
|
limit := 1
|
||||||
path := fmt.Sprintf("%s?maxSlotNum=%d&limit=%d&fromItem=", endpoint, maxSlotNum, limit)
|
path := fmt.Sprintf("%s?maxSlotNum=%d&limit=%d", endpoint, maxSlotNum, limit)
|
||||||
err := doGoodReqPaginated(path, historydb.OrderAsc, &testSlotsResponse{}, appendIter)
|
err := doGoodReqPaginated(path, historydb.OrderAsc, &testSlotsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
allSlots := tc.slots
|
allSlots := tc.slots
|
||||||
@@ -135,7 +135,7 @@ func TestGetSlots(t *testing.T) {
|
|||||||
// All slots with maxSlotNum filter, in reverse order
|
// All slots with maxSlotNum filter, in reverse order
|
||||||
fetchedSlots = []testSlot{}
|
fetchedSlots = []testSlot{}
|
||||||
limit = 3
|
limit = 3
|
||||||
path = fmt.Sprintf("%s?maxSlotNum=%d&limit=%d&fromItem=", endpoint, maxSlotNum, limit)
|
path = fmt.Sprintf("%s?maxSlotNum=%d&limit=%d", endpoint, maxSlotNum, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderDesc, &testSlotsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderDesc, &testSlotsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ func TestGetSlots(t *testing.T) {
|
|||||||
fetchedSlots = []testSlot{}
|
fetchedSlots = []testSlot{}
|
||||||
limit = 1
|
limit = 1
|
||||||
bidderAddr := tc.coordinators[2].Bidder
|
bidderAddr := tc.coordinators[2].Bidder
|
||||||
path = fmt.Sprintf("%s?maxSlotNum=%d&wonByEthereumAddress=%s&limit=%d&fromItem=", endpoint, maxSlotNum, bidderAddr.String(), limit)
|
path = fmt.Sprintf("%s?maxSlotNum=%d&wonByEthereumAddress=%s&limit=%d", endpoint, maxSlotNum, bidderAddr.String(), limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testSlotsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testSlotsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
bidderAddressSlots := []testSlot{}
|
bidderAddressSlots := []testSlot{}
|
||||||
@@ -165,7 +165,7 @@ func TestGetSlots(t *testing.T) {
|
|||||||
// maxSlotNum & wonByEthereumAddress, in reverse order
|
// maxSlotNum & wonByEthereumAddress, in reverse order
|
||||||
fetchedSlots = []testSlot{}
|
fetchedSlots = []testSlot{}
|
||||||
limit = 1
|
limit = 1
|
||||||
path = fmt.Sprintf("%s?maxSlotNum=%d&wonByEthereumAddress=%s&limit=%d&fromItem=", endpoint, maxSlotNum, bidderAddr.String(), limit)
|
path = fmt.Sprintf("%s?maxSlotNum=%d&wonByEthereumAddress=%s&limit=%d", endpoint, maxSlotNum, bidderAddr.String(), limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderDesc, &testSlotsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderDesc, &testSlotsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
flippedBidderAddressSlots := []testSlot{}
|
flippedBidderAddressSlots := []testSlot{}
|
||||||
@@ -177,7 +177,7 @@ func TestGetSlots(t *testing.T) {
|
|||||||
// finishedAuction
|
// finishedAuction
|
||||||
fetchedSlots = []testSlot{}
|
fetchedSlots = []testSlot{}
|
||||||
limit = 15
|
limit = 15
|
||||||
path = fmt.Sprintf("%s?finishedAuction=%t&limit=%d&fromItem=", endpoint, true, limit)
|
path = fmt.Sprintf("%s?finishedAuction=%t&limit=%d", endpoint, true, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testSlotsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testSlotsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ func TestGetSlots(t *testing.T) {
|
|||||||
minSlotNum := tc.slots[3].SlotNum
|
minSlotNum := tc.slots[3].SlotNum
|
||||||
maxSlotNum = tc.slots[len(tc.slots)-1].SlotNum - 1
|
maxSlotNum = tc.slots[len(tc.slots)-1].SlotNum - 1
|
||||||
fetchedSlots = []testSlot{}
|
fetchedSlots = []testSlot{}
|
||||||
path = fmt.Sprintf("%s?maxSlotNum=%d&minSlotNum=%d&limit=%d&fromItem=", endpoint, maxSlotNum, minSlotNum, limit)
|
path = fmt.Sprintf("%s?maxSlotNum=%d&minSlotNum=%d&limit=%d", endpoint, maxSlotNum, minSlotNum, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testSlotsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testSlotsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
minMaxBatchNumSlots := []testSlot{}
|
minMaxBatchNumSlots := []testSlot{}
|
||||||
@@ -214,7 +214,7 @@ func TestGetSlots(t *testing.T) {
|
|||||||
minSlotNum = tc.slots[0].SlotNum
|
minSlotNum = tc.slots[0].SlotNum
|
||||||
maxSlotNum = tc.slots[0].SlotNum
|
maxSlotNum = tc.slots[0].SlotNum
|
||||||
fetchedSlots = []testSlot{}
|
fetchedSlots = []testSlot{}
|
||||||
path = fmt.Sprintf("%s?maxSlotNum=%d&minSlotNum=%d&limit=%d&fromItem=", endpoint, maxSlotNum, minSlotNum, limit)
|
path = fmt.Sprintf("%s?maxSlotNum=%d&minSlotNum=%d&limit=%d", endpoint, maxSlotNum, minSlotNum, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testSlotsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testSlotsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
minMaxBatchNumSlots = []testSlot{}
|
minMaxBatchNumSlots = []testSlot{}
|
||||||
@@ -230,7 +230,7 @@ func TestGetSlots(t *testing.T) {
|
|||||||
minSlotNum = tc.slots[len(tc.slots)-1].SlotNum + 1
|
minSlotNum = tc.slots[len(tc.slots)-1].SlotNum + 1
|
||||||
maxSlotNum = tc.slots[len(tc.slots)-1].SlotNum + 5
|
maxSlotNum = tc.slots[len(tc.slots)-1].SlotNum + 5
|
||||||
fetchedSlots = []testSlot{}
|
fetchedSlots = []testSlot{}
|
||||||
path = fmt.Sprintf("%s?maxSlotNum=%d&minSlotNum=%d&limit=%d&fromItem=", endpoint, maxSlotNum, minSlotNum, limit)
|
path = fmt.Sprintf("%s?maxSlotNum=%d&minSlotNum=%d&limit=%d", endpoint, maxSlotNum, minSlotNum, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testSlotsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testSlotsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
emptySlots := []testSlot{}
|
emptySlots := []testSlot{}
|
||||||
@@ -246,7 +246,7 @@ func TestGetSlots(t *testing.T) {
|
|||||||
minSlotNum = tc.slots[len(tc.slots)-1].SlotNum + 1
|
minSlotNum = tc.slots[len(tc.slots)-1].SlotNum + 1
|
||||||
maxSlotNum = tc.slots[len(tc.slots)-1].SlotNum + 5
|
maxSlotNum = tc.slots[len(tc.slots)-1].SlotNum + 5
|
||||||
fetchedSlots = []testSlot{}
|
fetchedSlots = []testSlot{}
|
||||||
path = fmt.Sprintf("%s?maxSlotNum=%d&minSlotNum=%d&limit=%d&fromItem=", endpoint, maxSlotNum, minSlotNum, limit)
|
path = fmt.Sprintf("%s?maxSlotNum=%d&minSlotNum=%d&limit=%d", endpoint, maxSlotNum, minSlotNum, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderDesc, &testSlotsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderDesc, &testSlotsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
flippedEmptySlots := []testSlot{}
|
flippedEmptySlots := []testSlot{}
|
||||||
@@ -259,7 +259,7 @@ func TestGetSlots(t *testing.T) {
|
|||||||
|
|
||||||
// 400
|
// 400
|
||||||
// No filters
|
// No filters
|
||||||
path = fmt.Sprintf("%s?limit=%d&fromItem=", endpoint, limit)
|
path = fmt.Sprintf("%s?limit=%d", endpoint, limit)
|
||||||
err = doBadReq("GET", path, nil, 400)
|
err = doBadReq("GET", path, nil, 400)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
// Invalid maxSlotNum
|
// Invalid maxSlotNum
|
||||||
@@ -273,12 +273,12 @@ func TestGetSlots(t *testing.T) {
|
|||||||
// Invalid minSlotNum / maxSlotNum (minSlotNum > maxSlotNum)
|
// Invalid minSlotNum / maxSlotNum (minSlotNum > maxSlotNum)
|
||||||
maxSlotNum = tc.slots[1].SlotNum
|
maxSlotNum = tc.slots[1].SlotNum
|
||||||
minSlotNum = tc.slots[4].SlotNum
|
minSlotNum = tc.slots[4].SlotNum
|
||||||
path = fmt.Sprintf("%s?maxSlotNum=%d&minSlotNum=%d&limit=%d&fromItem=", endpoint, maxSlotNum, minSlotNum, limit)
|
path = fmt.Sprintf("%s?maxSlotNum=%d&minSlotNum=%d&limit=%d", endpoint, maxSlotNum, minSlotNum, limit)
|
||||||
err = doBadReq("GET", path, nil, 400)
|
err = doBadReq("GET", path, nil, 400)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
// 404
|
// 404
|
||||||
maxSlotNum = tc.slots[1].SlotNum
|
maxSlotNum = tc.slots[1].SlotNum
|
||||||
path = fmt.Sprintf("%s?maxSlotNum=%d&wonByEthereumAddress=%s&limit=%d&fromItem=", endpoint, maxSlotNum, tc.coordinators[3].Bidder.String(), limit)
|
path = fmt.Sprintf("%s?maxSlotNum=%d&wonByEthereumAddress=%s&limit=%d", endpoint, maxSlotNum, tc.coordinators[3].Bidder.String(), limit)
|
||||||
err = doBadReq("GET", path, nil, 404)
|
err = doBadReq("GET", path, nil, 404)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ func TestGetTokens(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// Get all (no filters)
|
// Get all (no filters)
|
||||||
limit := 8
|
limit := 8
|
||||||
path := fmt.Sprintf("%s?limit=%d&fromItem=", endpoint, limit)
|
path := fmt.Sprintf("%s?limit=%d", endpoint, limit)
|
||||||
err := doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)
|
err := doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assertTokensAPIs(t, tc.tokens, fetchedTokens)
|
assertTokensAPIs(t, tc.tokens, fetchedTokens)
|
||||||
@@ -64,7 +64,7 @@ func TestGetTokens(t *testing.T) {
|
|||||||
limit = 7
|
limit = 7
|
||||||
stringIds := strconv.Itoa(int(tc.tokens[2].TokenID)) + "," + strconv.Itoa(int(tc.tokens[5].TokenID)) + "," + strconv.Itoa(int(tc.tokens[6].TokenID))
|
stringIds := strconv.Itoa(int(tc.tokens[2].TokenID)) + "," + strconv.Itoa(int(tc.tokens[5].TokenID)) + "," + strconv.Itoa(int(tc.tokens[6].TokenID))
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?ids=%s&limit=%d&fromItem=",
|
"%s?ids=%s&limit=%d",
|
||||||
endpoint, stringIds, limit,
|
endpoint, stringIds, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)
|
||||||
@@ -80,7 +80,7 @@ func TestGetTokens(t *testing.T) {
|
|||||||
limit = 7
|
limit = 7
|
||||||
stringSymbols := tc.tokens[1].Symbol + "," + tc.tokens[3].Symbol
|
stringSymbols := tc.tokens[1].Symbol + "," + tc.tokens[3].Symbol
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?symbols=%s&limit=%d&fromItem=",
|
"%s?symbols=%s&limit=%d",
|
||||||
endpoint, stringSymbols, limit,
|
endpoint, stringSymbols, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)
|
||||||
@@ -96,7 +96,7 @@ func TestGetTokens(t *testing.T) {
|
|||||||
tokenNameLen := len(tc.tokens[8].Name)
|
tokenNameLen := len(tc.tokens[8].Name)
|
||||||
stringName := tc.tokens[8].Name[tokenNameLen-1:]
|
stringName := tc.tokens[8].Name[tokenNameLen-1:]
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?name=%s&limit=%d&fromItem=",
|
"%s?name=%s&limit=%d",
|
||||||
endpoint, stringName, limit,
|
endpoint, stringName, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)
|
||||||
@@ -111,7 +111,7 @@ func TestGetTokens(t *testing.T) {
|
|||||||
stringSymbols = tc.tokens[2].Symbol + "," + tc.tokens[6].Symbol
|
stringSymbols = tc.tokens[2].Symbol + "," + tc.tokens[6].Symbol
|
||||||
stringIds = strconv.Itoa(int(tc.tokens[2].TokenID)) + "," + strconv.Itoa(int(tc.tokens[5].TokenID)) + "," + strconv.Itoa(int(tc.tokens[6].TokenID))
|
stringIds = strconv.Itoa(int(tc.tokens[2].TokenID)) + "," + strconv.Itoa(int(tc.tokens[5].TokenID)) + "," + strconv.Itoa(int(tc.tokens[6].TokenID))
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?symbols=%s&ids=%s&limit=%d&fromItem=",
|
"%s?symbols=%s&ids=%s&limit=%d",
|
||||||
endpoint, stringSymbols, stringIds, limit,
|
endpoint, stringSymbols, stringIds, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)
|
||||||
@@ -125,7 +125,7 @@ func TestGetTokens(t *testing.T) {
|
|||||||
// All, in reverse order
|
// All, in reverse order
|
||||||
fetchedTokens = []historydb.TokenWithUSD{}
|
fetchedTokens = []historydb.TokenWithUSD{}
|
||||||
limit = 5
|
limit = 5
|
||||||
path = fmt.Sprintf("%s?limit=%d&fromItem=", endpoint, limit)
|
path = fmt.Sprintf("%s?limit=%d", endpoint, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderDesc, &testTokensResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderDesc, &testTokensResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
flipedTokens := []historydb.TokenWithUSD{}
|
flipedTokens := []historydb.TokenWithUSD{}
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ func TestGetHistoryTxs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// Get all (no filters)
|
// Get all (no filters)
|
||||||
limit := 20
|
limit := 20
|
||||||
path := fmt.Sprintf("%s?limit=%d&fromItem=", endpoint, limit)
|
path := fmt.Sprintf("%s?limit=%d", endpoint, limit)
|
||||||
err := doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
err := doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assertTxs(t, tc.txs, fetchedTxs)
|
assertTxs(t, tc.txs, fetchedTxs)
|
||||||
@@ -265,7 +265,7 @@ func TestGetHistoryTxs(t *testing.T) {
|
|||||||
fetchedTxs = []testTx{}
|
fetchedTxs = []testTx{}
|
||||||
limit = 7
|
limit = 7
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?hermezEthereumAddress=%s&limit=%d&fromItem=",
|
"%s?hermezEthereumAddress=%s&limit=%d",
|
||||||
endpoint, account.EthAddr, limit,
|
endpoint, account.EthAddr, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
||||||
@@ -287,7 +287,7 @@ func TestGetHistoryTxs(t *testing.T) {
|
|||||||
fetchedTxs = []testTx{}
|
fetchedTxs = []testTx{}
|
||||||
limit = 6
|
limit = 6
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?BJJ=%s&limit=%d&fromItem=",
|
"%s?BJJ=%s&limit=%d",
|
||||||
endpoint, account.PublicKey, limit,
|
endpoint, account.PublicKey, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
||||||
@@ -298,7 +298,7 @@ func TestGetHistoryTxs(t *testing.T) {
|
|||||||
limit = 5
|
limit = 5
|
||||||
tokenID := tc.txs[0].Token.TokenID
|
tokenID := tc.txs[0].Token.TokenID
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?tokenId=%d&limit=%d&fromItem=",
|
"%s?tokenId=%d&limit=%d",
|
||||||
endpoint, tokenID, limit,
|
endpoint, tokenID, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
||||||
@@ -317,7 +317,7 @@ func TestGetHistoryTxs(t *testing.T) {
|
|||||||
idx, err := stringToIdx(idxStr, "")
|
idx, err := stringToIdx(idxStr, "")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?accountIndex=%s&limit=%d&fromItem=",
|
"%s?accountIndex=%s&limit=%d",
|
||||||
endpoint, idxStr, limit,
|
endpoint, idxStr, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
||||||
@@ -345,7 +345,7 @@ func TestGetHistoryTxs(t *testing.T) {
|
|||||||
limit = 3
|
limit = 3
|
||||||
batchNum := tc.txs[0].BatchNum
|
batchNum := tc.txs[0].BatchNum
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?batchNum=%d&limit=%d&fromItem=",
|
"%s?batchNum=%d&limit=%d",
|
||||||
endpoint, *batchNum, limit,
|
endpoint, *batchNum, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
||||||
@@ -374,7 +374,7 @@ func TestGetHistoryTxs(t *testing.T) {
|
|||||||
fetchedTxs = []testTx{}
|
fetchedTxs = []testTx{}
|
||||||
limit = 2
|
limit = 2
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?type=%s&limit=%d&fromItem=",
|
"%s?type=%s&limit=%d",
|
||||||
endpoint, txType, limit,
|
endpoint, txType, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
||||||
@@ -391,7 +391,7 @@ func TestGetHistoryTxs(t *testing.T) {
|
|||||||
fetchedTxs = []testTx{}
|
fetchedTxs = []testTx{}
|
||||||
limit = 1
|
limit = 1
|
||||||
path = fmt.Sprintf(
|
path = fmt.Sprintf(
|
||||||
"%s?batchNum=%d&tokenId=%d&limit=%d&fromItem=",
|
"%s?batchNum=%d&tokenId=%d&limit=%d",
|
||||||
endpoint, *batchNum, tokenID, limit,
|
endpoint, *batchNum, tokenID, limit,
|
||||||
)
|
)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
|
||||||
@@ -408,7 +408,7 @@ func TestGetHistoryTxs(t *testing.T) {
|
|||||||
// All, in reverse order
|
// All, in reverse order
|
||||||
fetchedTxs = []testTx{}
|
fetchedTxs = []testTx{}
|
||||||
limit = 5
|
limit = 5
|
||||||
path = fmt.Sprintf("%s?limit=%d&fromItem=", endpoint, limit)
|
path = fmt.Sprintf("%s?limit=%d", endpoint, limit)
|
||||||
err = doGoodReqPaginated(path, historydb.OrderDesc, &testTxsResponse{}, appendIter)
|
err = doGoodReqPaginated(path, historydb.OrderDesc, &testTxsResponse{}, appendIter)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
flipedTxs := []testTx{}
|
flipedTxs := []testTx{}
|
||||||
@@ -430,7 +430,7 @@ func TestGetHistoryTxs(t *testing.T) {
|
|||||||
path = fmt.Sprintf("%s?batchNum=999999", endpoint)
|
path = fmt.Sprintf("%s?batchNum=999999", endpoint)
|
||||||
err = doBadReq("GET", path, nil, 404)
|
err = doBadReq("GET", path, nil, 404)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
path = fmt.Sprintf("%s?limit=1000&fromItem=999999", endpoint)
|
path = fmt.Sprintf("%s?fromItem=1000999999", endpoint)
|
||||||
err = doBadReq("GET", path, nil, 404)
|
err = doBadReq("GET", path, nil, 404)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user