Skip to content

Commit

Permalink
Fix boba link api and tests (#596)
Browse files Browse the repository at this point in the history
(cherry picked from commit 42c2a59)
  • Loading branch information
boyuan-chen authored and InoMurko committed Feb 18, 2023
1 parent f7b9965 commit d9be67e
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 19 deletions.
12 changes: 6 additions & 6 deletions integration-tests/test/bobalink.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe('BobaLink Test\n', async () => {
const response = await asyncBobaLinkGetQuote({
body: JSON.stringify({params: [input]}
)}, null)
res.end(JSON.stringify(response))
res.end(response.body)
server.emit('success', body)
}
if (req.url === '/invalidapi') {
Expand All @@ -205,9 +205,9 @@ describe('BobaLink Test\n', async () => {
res.writeHead(400, { 'Content-Type': 'text/plain' })
res.end('Expected content-type: application/json')
}
}).listen(apiPort)
URL = `http://${ip.address()}:${apiPort}`
/* eslint-enable */
}).listen(apiPort)
URL = `http://${ip.address()}:${apiPort}`
/* eslint-enable */
})

it('test of local compute endpoint: should return price', async () => {
Expand Down Expand Up @@ -287,7 +287,7 @@ describe('BobaLink Test\n', async () => {
})
const res = await resp.json()
const result = utils.defaultAbiCoder.decode(
['uint256', 'uint256', 'int256', 'uint80'],
['uint256', 'uint256', 'int256', 'uint256'],
res.result
)
expect(Number(result[0])).to.equal(32 * 3)
Expand All @@ -308,7 +308,7 @@ describe('BobaLink Test\n', async () => {
)
expect(chainLinkQuoteEvents[0].args.CLRoundId).to.equal(lastRoundId)
expect(chainLinkQuoteEvents[0].args.CLLatestRoundId).to.eq(lastRoundId)
}).retries(3)
})

it('should get a single quote via bobalink using test api', async () => {
await EthOracleHC.updateHCUrl(`${URL}/bobalink-test-api`)
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/test/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ export const waitForAndExecute = async (
repeat: number,
intervalMs?: number,
) => {
while (repeat >= 0) {
while (repeat > 0) {
try {
await fn()
break
Expand All @@ -433,6 +433,7 @@ export const waitForAndExecute = async (
await sleep(intervalMs || 1000)
}
}
await fn()
}

// // eslint-disable-next-line @typescript-eslint/no-shadow
Expand Down
2 changes: 1 addition & 1 deletion ops_boba/api/bobalink-api/bobalink_getQuote.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const getResponse = (statusCode, result) => {
return {
headers,
statusCode,
result,
body: JSON.stringify({ result }),
}
}

Expand Down
32 changes: 32 additions & 0 deletions ops_boba/api/bobalink-api/serverless-bobabeam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
service: sls-bobabeam-bobalink # NOTE: update this with your service name

provider:
name: aws
runtime: nodejs12.x
stackName: sls-bobabeam-bobalink
stage: prod
region: us-east-1

package:
exclude:
- .gitignore
- node_modules
individually: true

functions:
bobalink_getQuote:
handler: bobalink_getQuote.exportHandler
memorySize: 10240 # optional, in MB, default is 1024
timeout: 60 # optional, in seconds, default is 6
events:
- http:
path: get.quote
method: post
cors: true
- schedule:
rate: rate(10 minutes)
description: 'Warm up get token'
name: 'sls-bobabeam-bobalink-bobalink_getQuote'
layers:
- ${file(env.yml):LAYERS}

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ provider:
stackName: sls-boba-bobalink
stage: prod
region: us-east-1
role: ${file(env.yml):ROLE}

package:
exclude:
Expand All @@ -19,17 +18,15 @@ functions:
handler: bobalink_getQuote.exportHandler
memorySize: 10240 # optional, in MB, default is 1024
timeout: 60 # optional, in seconds, default is 6
vpc:
securityGroupIds:
- ${file(env.yml):SECURITY_GROUPS}
subnetIds:
- ${file(env.yml):SUBNET_ID_1}
- ${file(env.yml):SUBNET_ID_2}
events:
- http:
path: get.quote
method: post
cors: true
- schedule:
rate: rate(10 minutes)
description: 'Warm up get token'
name: 'sls-boba-bobalink-bobalink_getQuote'
layers:
- ${file(env.yml):LAYERS}

8 changes: 4 additions & 4 deletions packages/boba/bobalink/src/utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export const BobaLinkPairs = {
},
},
31338: {
'0x4631BCAbD6dF18D94796344963cB60d44a4136b6': {
'0x5067457698Fd6Fa1C6964e416b3f42713513B3dD': {
pair: 'ETH / USD',
decimals: 8,
l2ContractAddress: '0xA4899D35897033b927acFCf422bc745916139776',
l2ContractAddress: '0x4b6aB5F819A515382B0dEB6935D793817bB4af28',
},
'0x07882Ae1ecB7429a84f1D53048d35c4bB2056877': {
'0xffa7CA1AEEEbBc30C874d32C7e22F052BbEa0429': {
pair: 'BTC / USD',
decimals: 8,
l2ContractAddress: '0xA7c59f010700930003b33aB25a7a0679C860f29c',
l2ContractAddress: '0xab16A69A5a8c12C732e0DEFF4BE56A70bb64c926',
},
},
}

0 comments on commit d9be67e

Please sign in to comment.