Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #195 from hermeznetwork/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mmilenkovic authored Jul 6, 2021
2 parents 87a02b0 + 1431f25 commit 0f42460
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,14 @@ async function getConfig (axiosConfig) {
return extractJSON(axios.get(`${baseApiUrl}/${API_VERSION}/config`, axiosConfig))
}

/**
* GET request to the /health endpoint
* @returns {Object} Response data
*/
async function getHealth (axiosConfig) {
return extractJSON(axios.get(`${baseApiUrl}/${API_VERSION}/health`, axiosConfig))
}

export {
PaginationOrder,
_getPageData,
Expand All @@ -379,5 +387,6 @@ export {
postCreateAccountAuthorization,
getCreateAccountAuthorization,
getConfig,
getPoolTransactions
getPoolTransactions,
getHealth
}
2 changes: 1 addition & 1 deletion src/tx-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ async function generateL2Transaction (tx, bjj, token) {
if (type === TxType.TransferToEthAddr) {
toHezEthereumAddress = tx.to
} else if (type === TxType.TransferToBJJ) {
toHezEthereumAddress = tx.toAuxEthAddr.toLowerCase() || INTERNAL_ACCOUNT_ETH_ADDR.toLowerCase()
toHezEthereumAddress = (tx.toAuxEthAddr || INTERNAL_ACCOUNT_ETH_ADDR).toLowerCase()
} else {
toHezEthereumAddress = null
}
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,11 @@ test('#_getPageData', () => {
const pageData = CoordinatorAPI._getPageData(32, CoordinatorAPI.PaginationOrder.ASC, 20)
expect(pageData).toEqual({ fromItem: 32, order: CoordinatorAPI.PaginationOrder.ASC, limit: 20 })
})

test('#getHealth', async () => {
CoordinatorAPI.setBaseApiUrl(mockUrlAPI)

const res = await CoordinatorAPI.getHealth()
expect(res).toBeDefined()
expect(res.status).toBe('UP')
})

0 comments on commit 0f42460

Please sign in to comment.