-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #833 from MoralisWeb3/main-to-beta-merge-2
merge main to beta.
- Loading branch information
Showing
35 changed files
with
666 additions
and
778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 36 additions & 24 deletions
60
packages/evmApi/integration/mocks/endpoints/endpointWeights.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,38 @@ | ||
import { rest } from 'msw'; | ||
import { EVM_API_ROOT, MOCK_API_KEY } from '../config'; | ||
import { MockScenarios } from '@moralisweb3/test-utils'; | ||
|
||
// TODO: we need to fix this test. | ||
const mockEndpointWeightss = 'getBlock'; | ||
const response = [ | ||
{ | ||
endpoint: 'getBlock', | ||
path: '/block/{block_number_or_hash}', | ||
price: 5, | ||
rateLimitCost: 5, | ||
}, | ||
{ | ||
endpoint: 'getContractEvents', | ||
path: '/{address}/events', | ||
price: 2, | ||
rateLimitCost: 2, | ||
}, | ||
{ | ||
endpoint: 'getTransactions', | ||
path: '/transaction/{transaction_hash}', | ||
price: 1, | ||
rateLimitCost: 1, | ||
}, | ||
// ... | ||
]; | ||
|
||
export const mockEndpointWeights = rest.get(`${EVM_API_ROOT}/info/endpointWeights`, (req, res, ctx) => { | ||
const apiKey = req.headers.get('x-api-key'); | ||
|
||
if (apiKey !== MOCK_API_KEY) { | ||
return res(ctx.status(401)); | ||
} | ||
|
||
const value = mockEndpointWeightss; | ||
|
||
if (!value) { | ||
return res(ctx.status(404)); | ||
} | ||
|
||
return res( | ||
ctx.status(200), | ||
ctx.json({ | ||
endpoint: value, | ||
}), | ||
); | ||
}); | ||
export const mockEndpointWeights = MockScenarios.create( | ||
{ | ||
name: 'mockEndpointWeights', | ||
getParams: () => ({}), | ||
url: '/info/endpointWeights', | ||
method: 'get', | ||
}, | ||
[ | ||
{ | ||
condition: {}, | ||
response: response as never, | ||
}, | ||
], | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
bb045cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test coverage