arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
Merge pull request #336 from hermeznetwork/fix/api1

Fix/api1
laisolizq 37299818+laisolizq@users.noreply.github.com
Wed, 09 Dec 2020 16:08:01 +0100
commit

d5f579aec5db2420467392c0214c6bc813933e1f

parent

f229f49f0edb8cca142e2e5b847c4de83a1c2408

M api/account_test.go → api/account_test.go

@@ -74,40 +74,40 @@ limit := 5

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 - 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) assert.NoError(t, err) assert.Greater(t, len(fetchedAccounts), 0) assert.LessOrEqual(t, len(fetchedAccounts), len(tc.accounts)) fetchedAccounts = []testAccount{} // 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) assert.NoError(t, err) assert.Greater(t, len(fetchedAccounts), 0) assert.LessOrEqual(t, len(fetchedAccounts), len(tc.accounts)) fetchedAccounts = []testAccount{} // 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) assert.NoError(t, err) fetchedAccounts = []testAccount{} // 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) assert.NoError(t, err) assert.Greater(t, len(fetchedAccounts), 0) assert.LessOrEqual(t, len(fetchedAccounts), len(tc.accounts)) fetchedAccounts = []testAccount{} // 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) assert.NoError(t, err) assert.Greater(t, len(fetchedAccounts), 0) assert.LessOrEqual(t, len(fetchedAccounts), len(tc.accounts)) fetchedAccounts = []testAccount{} // 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) assert.NoError(t, err) assert.Equal(t, len(tc.accounts), len(fetchedAccounts))
M api/api_test.go → api/api_test.go

@@ -456,15 +456,8 @@ totalReceived := 0

for { // Calculate fromItem iterPath := path - if firstIte { - if order == historydb.OrderDesc { - // 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)) + if !firstIte { + iterPath += "&fromItem=" + strconv.Itoa(int(next)) } // Call API to get this iteration items iterStruct = iterStruct.New()
M api/batch_test.go → api/batch_test.go

@@ -119,7 +119,7 @@ }

} // Get all (no filters) 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) assert.NoError(t, err) assertBatches(t, tc.batches, fetchedBatches)

@@ -128,7 +128,7 @@ // minBatchNum

fetchedBatches = []testBatch{} limit = 2 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) assert.NoError(t, err) minBatchNumBatches := []testBatch{}

@@ -143,7 +143,7 @@ // maxBatchNum

fetchedBatches = []testBatch{} limit = 1 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) assert.NoError(t, err) maxBatchNumBatches := []testBatch{}

@@ -158,7 +158,7 @@ // slotNum

fetchedBatches = []testBatch{} limit = 5 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) assert.NoError(t, err) slotNumBatches := []testBatch{}

@@ -173,7 +173,7 @@ // forgerAddr

fetchedBatches = []testBatch{} limit = 10 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) assert.NoError(t, err) forgerAddrBatches := []testBatch{}

@@ -187,7 +187,7 @@

// All, in reverse order fetchedBatches = []testBatch{} 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) assert.NoError(t, err) flippedBatches := []testBatch{}

@@ -201,7 +201,7 @@ fetchedBatches = []testBatch{}

limit = 1 maxBatchNum = tc.batches[len(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) assert.NoError(t, err) minMaxBatchNumBatches := []testBatch{}
M api/bids_test.go → api/bids_test.go

@@ -76,7 +76,7 @@ limit := 3

// bidderAddress fetchedBids = []testBid{} 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) assert.NoError(t, err) bidderAddrBids := []testBid{}

@@ -90,7 +90,7 @@

// slotNum fetchedBids = []testBid{} 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) assert.NoError(t, err) slotNumBids := []testBid{}

@@ -103,7 +103,7 @@ assertBids(t, slotNumBids, fetchedBids)

// slotNum, in reverse order 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) assert.NoError(t, err) flippedBids := []testBid{}

@@ -116,7 +116,7 @@ // Mixed filters

fetchedBids = []testBid{} bidderAddress = tc.bids[1].Bidder 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) assert.NoError(t, err) slotNumBidderAddrBids := []testBid{}

@@ -129,7 +129,7 @@ assertBids(t, slotNumBidderAddrBids, fetchedBids)

// 400 // 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) assert.NoError(t, err) // Invalid slotNum
M api/coordinator_test.go → api/coordinator_test.go

@@ -53,7 +53,7 @@ }

// All 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) assert.NoError(t, err) assertCoordinators(t, tc.coordinators, fetchedCoordinators)
M api/exits_test.go → api/exits_test.go

@@ -100,7 +100,7 @@ }

} // Get all (no filters) 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) assert.NoError(t, err) assertExitAPIs(t, tc.exits, fetchedExits)

@@ -124,7 +124,7 @@ break

} } path = fmt.Sprintf( - "%s?hermezEthereumAddress=%s&limit=%d&fromItem=", + "%s?hermezEthereumAddress=%s&limit=%d", endpoint, account.EthAddr, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)

@@ -144,7 +144,7 @@ // Get by bjj

fetchedExits = []testExit{} limit = 6 path = fmt.Sprintf( - "%s?BJJ=%s&limit=%d&fromItem=", + "%s?BJJ=%s&limit=%d", endpoint, account.PublicKey, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)

@@ -155,7 +155,7 @@ fetchedExits = []testExit{}

limit = 5 tokenID := tc.exits[0].Token.TokenID path = fmt.Sprintf( - "%s?tokenId=%d&limit=%d&fromItem=", + "%s?tokenId=%d&limit=%d", endpoint, tokenID, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)

@@ -172,7 +172,7 @@ fetchedExits = []testExit{}

limit = 4 idx := tc.exits[0].AccountIdx path = fmt.Sprintf( - "%s?accountIndex=%s&limit=%d&fromItem=", + "%s?accountIndex=%s&limit=%d", endpoint, idx, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)

@@ -189,7 +189,7 @@ fetchedExits = []testExit{}

limit = 3 batchNum := tc.exits[0].BatchNum path = fmt.Sprintf( - "%s?batchNum=%d&limit=%d&fromItem=", + "%s?batchNum=%d&limit=%d", endpoint, batchNum, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)

@@ -205,7 +205,7 @@ // OnlyPendingWithdraws

fetchedExits = []testExit{} limit = 7 path = fmt.Sprintf( - "%s?&onlyPendingWithdraws=%t&limit=%d&fromItem=", + "%s?&onlyPendingWithdraws=%t&limit=%d", endpoint, true, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)

@@ -221,7 +221,7 @@ // Multiple filters

fetchedExits = []testExit{} limit = 1 path = fmt.Sprintf( - "%s?batchNum=%d&tokeId=%d&limit=%d&fromItem=", + "%s?batchNum=%d&tokeId=%d&limit=%d", endpoint, batchNum, tokenID, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)

@@ -238,7 +238,7 @@ assertExitAPIs(t, mixedExits, fetchedExits)

// All, in reverse order fetchedExits = []testExit{} 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) assert.NoError(t, err) assertExitAPIs(t, flipedExits, fetchedExits)

@@ -256,7 +256,7 @@ // 404

path = fmt.Sprintf("%s?batchNum=999999", endpoint) err = doBadReq("GET", path, nil, 404) 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) assert.NoError(t, err) }
M api/parsers.go → api/parsers.go

@@ -14,8 +14,6 @@ "github.com/hermeznetwork/tracerr"

"github.com/iden3/go-iden3-crypto/babyjub" ) -const exitIdx = "hez:EXIT:1" - // Query parsers type querier interface {

@@ -453,8 +451,5 @@ return "hez:" + addr.String()

} func idxToHez(idx common.Idx, tokenSymbol string) string { - if idx == 1 { - return exitIdx - } return "hez:" + tokenSymbol + ":" + strconv.Itoa(int(idx)) }
M api/slots.go → api/slots.go

@@ -65,11 +65,11 @@ for i := range bids {

slotNum := bids[i].SlotNum slot := a.newSlotAPI(slotNum, currentBlockNum, &bids[i], auctionVars) if order == historydb.OrderAsc { - if slot.ItemID >= uint64(*fromItem) { + if fromItem == nil || slot.ItemID >= uint64(*fromItem) { slots = append(slots, slot) } } else { - if slot.ItemID <= uint64(*fromItem) { + if fromItem == nil || slot.ItemID <= uint64(*fromItem) { slots = append(slots, slot) } }

@@ -80,11 +80,11 @@

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) if order == historydb.OrderAsc { - if emptySlot.ItemID >= uint64(*fromItem) { + if fromItem == nil || emptySlot.ItemID >= uint64(*fromItem) { slots = append(slots, emptySlot) } } else { - if emptySlot.ItemID <= uint64(*fromItem) { + if fromItem == nil || emptySlot.ItemID <= uint64(*fromItem) { slots = append([]SlotAPI{emptySlot}, slots...) } }

@@ -175,6 +175,9 @@ } else {

maxLim = *maxSlotNum } } + } else { + maxLim = *maxSlotNum + minLim = *minSlotNum } return minLim, maxLim }

@@ -285,11 +288,11 @@ for j := range slotsBids {

if slotsBids[j].SlotNum == i { found = true if order == historydb.OrderAsc { - if slotsBids[j].ItemID >= uint64(*fromItem) { + if fromItem == nil || slotsBids[j].ItemID >= uint64(*fromItem) { slots = append(slots, slotsBids[j]) } } else { - if slotsBids[j].ItemID <= uint64(*fromItem) { + if fromItem == nil || slotsBids[j].ItemID <= uint64(*fromItem) { slots = append([]SlotAPI{slotsBids[j]}, slots...) } }
M api/slots_test.go → api/slots_test.go

@@ -122,7 +122,7 @@ }

// All slots with maxSlotNum filter maxSlotNum := tc.slots[len(tc.slots)-1].SlotNum + 5 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) assert.NoError(t, err) allSlots := tc.slots

@@ -135,7 +135,7 @@

// All slots with maxSlotNum filter, in reverse order fetchedSlots = []testSlot{} 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) assert.NoError(t, err)

@@ -149,7 +149,7 @@ // maxSlotNum & wonByEthereumAddress

fetchedSlots = []testSlot{} limit = 1 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) assert.NoError(t, err) bidderAddressSlots := []testSlot{}

@@ -165,7 +165,7 @@

// maxSlotNum & wonByEthereumAddress, in reverse order fetchedSlots = []testSlot{} 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) assert.NoError(t, err) flippedBidderAddressSlots := []testSlot{}

@@ -177,7 +177,7 @@

// finishedAuction fetchedSlots = []testSlot{} 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) assert.NoError(t, err)

@@ -198,7 +198,7 @@ limit = 10

minSlotNum := tc.slots[3].SlotNum maxSlotNum = tc.slots[len(tc.slots)-1].SlotNum - 1 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) assert.NoError(t, err) minMaxBatchNumSlots := []testSlot{}

@@ -214,7 +214,7 @@ limit = 15

minSlotNum = tc.slots[0].SlotNum maxSlotNum = tc.slots[0].SlotNum 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) assert.NoError(t, err) minMaxBatchNumSlots = []testSlot{}

@@ -230,7 +230,7 @@ limit = 2

minSlotNum = tc.slots[len(tc.slots)-1].SlotNum + 1 maxSlotNum = tc.slots[len(tc.slots)-1].SlotNum + 5 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) assert.NoError(t, err) emptySlots := []testSlot{}

@@ -246,7 +246,7 @@ limit = 4

minSlotNum = tc.slots[len(tc.slots)-1].SlotNum + 1 maxSlotNum = tc.slots[len(tc.slots)-1].SlotNum + 5 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) assert.NoError(t, err) flippedEmptySlots := []testSlot{}

@@ -259,7 +259,7 @@ assertSlots(t, flippedEmptySlots, fetchedSlots)

// 400 // 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) assert.NoError(t, err) // Invalid maxSlotNum

@@ -273,12 +273,12 @@ assert.NoError(t, err)

// Invalid minSlotNum / maxSlotNum (minSlotNum > maxSlotNum) maxSlotNum = tc.slots[1].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) assert.NoError(t, err) // 404 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) assert.NoError(t, err) }
M api/token_test.go → api/token_test.go

@@ -54,7 +54,7 @@ }

} // Get all (no filters) 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) assert.NoError(t, err) assertTokensAPIs(t, tc.tokens, fetchedTokens)

@@ -64,7 +64,7 @@ fetchedTokens = []historydb.TokenWithUSD{}

limit = 7 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( - "%s?ids=%s&limit=%d&fromItem=", + "%s?ids=%s&limit=%d", endpoint, stringIds, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)

@@ -80,7 +80,7 @@ fetchedTokens = []historydb.TokenWithUSD{}

limit = 7 stringSymbols := tc.tokens[1].Symbol + "," + tc.tokens[3].Symbol path = fmt.Sprintf( - "%s?symbols=%s&limit=%d&fromItem=", + "%s?symbols=%s&limit=%d", endpoint, stringSymbols, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)

@@ -96,7 +96,7 @@ limit = 5

tokenNameLen := len(tc.tokens[8].Name) stringName := tc.tokens[8].Name[tokenNameLen-1:] path = fmt.Sprintf( - "%s?name=%s&limit=%d&fromItem=", + "%s?name=%s&limit=%d", endpoint, stringName, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)

@@ -111,7 +111,7 @@ limit = 5

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)) path = fmt.Sprintf( - "%s?symbols=%s&ids=%s&limit=%d&fromItem=", + "%s?symbols=%s&ids=%s&limit=%d", endpoint, stringSymbols, stringIds, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testTokensResponse{}, appendIter)

@@ -125,7 +125,7 @@

// All, in reverse order fetchedTokens = []historydb.TokenWithUSD{} 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) assert.NoError(t, err) flipedTokens := []historydb.TokenWithUSD{}
M api/txshistory_test.go → api/txshistory_test.go

@@ -256,7 +256,7 @@ }

} // Get all (no filters) 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) assert.NoError(t, err) assertTxs(t, tc.txs, fetchedTxs)

@@ -265,7 +265,7 @@ account := tc.accounts[2]

fetchedTxs = []testTx{} limit = 7 path = fmt.Sprintf( - "%s?hermezEthereumAddress=%s&limit=%d&fromItem=", + "%s?hermezEthereumAddress=%s&limit=%d", endpoint, account.EthAddr, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)

@@ -287,7 +287,7 @@ // Get by bjj

fetchedTxs = []testTx{} limit = 6 path = fmt.Sprintf( - "%s?BJJ=%s&limit=%d&fromItem=", + "%s?BJJ=%s&limit=%d", endpoint, account.PublicKey, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)

@@ -298,7 +298,7 @@ fetchedTxs = []testTx{}

limit = 5 tokenID := tc.txs[0].Token.TokenID path = fmt.Sprintf( - "%s?tokenId=%d&limit=%d&fromItem=", + "%s?tokenId=%d&limit=%d", endpoint, tokenID, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)

@@ -317,7 +317,7 @@ idxStr := tc.txs[0].ToIdx

idx, err := stringToIdx(idxStr, "") assert.NoError(t, err) path = fmt.Sprintf( - "%s?accountIndex=%s&limit=%d&fromItem=", + "%s?accountIndex=%s&limit=%d", endpoint, idxStr, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)

@@ -345,7 +345,7 @@ fetchedTxs = []testTx{}

limit = 3 batchNum := tc.txs[0].BatchNum path = fmt.Sprintf( - "%s?batchNum=%d&limit=%d&fromItem=", + "%s?batchNum=%d&limit=%d", endpoint, *batchNum, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)

@@ -374,7 +374,7 @@ for _, txType := range txTypes {

fetchedTxs = []testTx{} limit = 2 path = fmt.Sprintf( - "%s?type=%s&limit=%d&fromItem=", + "%s?type=%s&limit=%d", endpoint, txType, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)

@@ -391,7 +391,7 @@ // Multiple filters

fetchedTxs = []testTx{} limit = 1 path = fmt.Sprintf( - "%s?batchNum=%d&tokenId=%d&limit=%d&fromItem=", + "%s?batchNum=%d&tokenId=%d&limit=%d", endpoint, *batchNum, tokenID, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)

@@ -408,7 +408,7 @@ assertTxs(t, mixedTxs, fetchedTxs)

// All, in reverse order fetchedTxs = []testTx{} 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) assert.NoError(t, err) flipedTxs := []testTx{}

@@ -430,7 +430,7 @@ // 404

path = fmt.Sprintf("%s?batchNum=999999", endpoint) err = doBadReq("GET", path, nil, 404) 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) assert.NoError(t, err) }
M db/l2db/l2db_test.go → db/l2db/l2db_test.go

@@ -170,7 +170,7 @@ // find token

token := tokens[expected.TokenID] // If the token has value in USD setted if token.USDUpdate != nil { - assert.Equal(t, token.USDUpdate.Unix(), actual.AbsoluteFeeUpdate.Unix()) + assert.Less(t, token.USDUpdate.Unix()-3, actual.AbsoluteFeeUpdate.Unix()) expected.AbsoluteFeeUpdate = actual.AbsoluteFeeUpdate // Set expected fee f := new(big.Float).SetInt(expected.Amount)
M db/migrations/0001.sql → db/migrations/0001.sql

@@ -85,9 +85,6 @@ RETURNS VARCHAR

AS $BODY$ BEGIN - IF $1 = 1 THEN - RETURN 'hez:EXIT:1'; - END IF; RETURN 'hez:' || $2 || ':' || $1; END; $BODY$