Fix inconsistency between api doc and code: hermezEthereumAddress => hezEthereumAddress
Arnau B arnaubennassar5@gmail.com
Wed, 16 Dec 2020 12:29:46 +0100
6 files changed,
18 insertions(+),
13 deletions(-)
M
api/account_test.go
→
api/account_test.go
@@ -81,14 +81,14 @@ 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", endpoint, tc.accounts[3].EthAddr, limit) + path = fmt.Sprintf("%s?hezEthereumAddress=%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", endpoint, tc.accounts[0].EthAddr, tc.accounts[0].PublicKey, limit) + path = fmt.Sprintf("%s?hezEthereumAddress=%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{}@@ -143,6 +143,11 @@ fetchedAccounts[len(fetchedAccounts)-1-i].Token.USDUpdate = reversedAccounts[i].Token.USDUpdate
} assert.Equal(t, reversedAccounts[i], fetchedAccounts[len(fetchedAccounts)-1-i]) } + + // 400 + path = fmt.Sprintf("%s?hezEthereumAddress=hez:0x123456", endpoint) + err = doBadReq("GET", path, nil, 400) + assert.NoError(t, err) // Test GetAccount path = fmt.Sprintf("%s/%s", endpoint, fetchedAccounts[2].Idx)
M
api/api.go
→
api/api.go
@@ -72,7 +72,7 @@ // Add coordinator endpoints
if coordinatorEndpoints { // Account server.POST("/account-creation-authorization", a.postAccountCreationAuth) - server.GET("/account-creation-authorization/:hermezEthereumAddress", a.getAccountCreationAuth) + server.GET("/account-creation-authorization/:hezEthereumAddress", a.getAccountCreationAuth) // Transaction server.POST("/transactions-pool", a.postPoolTx) server.GET("/transactions-pool/:id", a.getPoolTx)
M
api/exits_test.go
→
api/exits_test.go
@@ -124,7 +124,7 @@ break
} } path = fmt.Sprintf( - "%s?hermezEthereumAddress=%s&limit=%d", + "%s?hezEthereumAddress=%s&limit=%d", endpoint, account.EthAddr, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testExitsResponse{}, appendIter)@@ -244,7 +244,7 @@ assert.NoError(t, err)
assertExitAPIs(t, flipedExits, fetchedExits) // 400 path = fmt.Sprintf( - "%s?accountIndex=%s&hermezEthereumAddress=%s", + "%s?accountIndex=%s&hezEthereumAddress=%s", endpoint, idx, account.EthAddr, ) err = doBadReq("GET", path, nil, 400)
M
api/parsers.go
→
api/parsers.go
@@ -82,7 +82,7 @@ return nil, tracerr.Wrap(fmt.Errorf("Invalid %s. Must be eithe true or false", name))
} func parseQueryHezEthAddr(c querier) (*ethCommon.Address, error) { - const name = "hermezEthereumAddress" + const name = "hezEthereumAddress" addrStr := c.Query(name) return hezStringToEthAddr(addrStr, name) }@@ -168,7 +168,7 @@ if err != nil {
return nil, nil, nil, nil, tracerr.Wrap(err) } if addr != nil && bjj != nil { - return nil, nil, nil, nil, tracerr.Wrap(errors.New("bjj and hermezEthereumAddress params are incompatible")) + return nil, nil, nil, nil, tracerr.Wrap(errors.New("bjj and hezEthereumAddress params are incompatible")) } // Idx idx, err := parseIdx(c)@@ -176,7 +176,7 @@ if err != nil {
return nil, nil, nil, nil, tracerr.Wrap(err) } if idx != nil && (addr != nil || bjj != nil || tokenID != nil) { - return nil, nil, nil, nil, tracerr.Wrap(errors.New("accountIndex is incompatible with BJJ, hermezEthereumAddress and tokenId")) + return nil, nil, nil, nil, tracerr.Wrap(errors.New("accountIndex is incompatible with BJJ, hezEthereumAddress and tokenId")) } return tokenID, addr, bjj, idx, nil }@@ -264,7 +264,7 @@ if err != nil {
return nil, nil, nil, tracerr.Wrap(err) } if addr != nil && bjj != nil { - return nil, nil, nil, tracerr.Wrap(errors.New("bjj and hermezEthereumAddress params are incompatible")) + return nil, nil, nil, tracerr.Wrap(errors.New("bjj and hezEthereumAddress params are incompatible")) } return tokenIDs, addr, bjj, nil@@ -427,7 +427,7 @@ return &addr, tracerr.Wrap(err)
} func parseParamHezEthAddr(c paramer) (*ethCommon.Address, error) { - const name = "hermezEthereumAddress" + const name = "hezEthereumAddress" addrStr := c.Param(name) return hezStringToEthAddr(addrStr, name) }
M
api/parsers_test.go
→
api/parsers_test.go
@@ -163,7 +163,7 @@ assert.Equal(t, 50, int(*limit))
} func TestParseQueryHezEthAddr(t *testing.T) { - name := "hermezEthereumAddress" + name := "hezEthereumAddress" c := &queryParser{} c.m = make(map[string]string) ethAddr := ethCommon.BigToAddress(big.NewInt(int64(347683)))
M
api/txshistory_test.go
→
api/txshistory_test.go
@@ -269,7 +269,7 @@ account := tc.accounts[2]
fetchedTxs = []testTx{} limit = 7 path = fmt.Sprintf( - "%s?hermezEthereumAddress=%s&limit=%d", + "%s?hezEthereumAddress=%s&limit=%d", endpoint, account.EthAddr, limit, ) err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)@@ -422,7 +422,7 @@ }
assertTxs(t, flipedTxs, fetchedTxs) // 400 path = fmt.Sprintf( - "%s?accountIndex=%s&hermezEthereumAddress=%s", + "%s?accountIndex=%s&hezEthereumAddress=%s", endpoint, idx, account.EthAddr, ) err = doBadReq("GET", path, nil, 400)