From d9be67e23285e947f1e680c911e2694e9d4bc6f2 Mon Sep 17 00:00:00 2001 From: Boyuan-Chen <46272347+Boyuan-Chen@users.noreply.github.com> Date: Sat, 18 Feb 2023 13:06:04 -0500 Subject: [PATCH] Fix boba link api and tests (#596) (cherry picked from commit 42c2a5993d21129b6f2a8c5941b2f3d70b424209) --- integration-tests/test/bobalink.spec.ts | 12 +++---- integration-tests/test/shared/utils.ts | 3 +- .../api/bobalink-api/bobalink_getQuote.js | 2 +- .../api/bobalink-api/serverless-bobabeam.yml | 32 +++++++++++++++++++ ...{serverless.yml => serverless-mainnet.yml} | 11 +++---- packages/boba/bobalink/src/utils/chains.ts | 8 ++--- 6 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 ops_boba/api/bobalink-api/serverless-bobabeam.yml rename ops_boba/api/bobalink-api/{serverless.yml => serverless-mainnet.yml} (74%) diff --git a/integration-tests/test/bobalink.spec.ts b/integration-tests/test/bobalink.spec.ts index 9304e1cf9c..b491adf263 100644 --- a/integration-tests/test/bobalink.spec.ts +++ b/integration-tests/test/bobalink.spec.ts @@ -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') { @@ -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 () => { @@ -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) @@ -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`) diff --git a/integration-tests/test/shared/utils.ts b/integration-tests/test/shared/utils.ts index 9d6a797acf..1850b28c0a 100644 --- a/integration-tests/test/shared/utils.ts +++ b/integration-tests/test/shared/utils.ts @@ -424,7 +424,7 @@ export const waitForAndExecute = async ( repeat: number, intervalMs?: number, ) => { - while (repeat >= 0) { + while (repeat > 0) { try { await fn() break @@ -433,6 +433,7 @@ export const waitForAndExecute = async ( await sleep(intervalMs || 1000) } } + await fn() } // // eslint-disable-next-line @typescript-eslint/no-shadow diff --git a/ops_boba/api/bobalink-api/bobalink_getQuote.js b/ops_boba/api/bobalink-api/bobalink_getQuote.js index 07dc13d00c..322fabbc1a 100644 --- a/ops_boba/api/bobalink-api/bobalink_getQuote.js +++ b/ops_boba/api/bobalink-api/bobalink_getQuote.js @@ -49,7 +49,7 @@ const getResponse = (statusCode, result) => { return { headers, statusCode, - result, + body: JSON.stringify({ result }), } } diff --git a/ops_boba/api/bobalink-api/serverless-bobabeam.yml b/ops_boba/api/bobalink-api/serverless-bobabeam.yml new file mode 100644 index 0000000000..64025b6266 --- /dev/null +++ b/ops_boba/api/bobalink-api/serverless-bobabeam.yml @@ -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} + diff --git a/ops_boba/api/bobalink-api/serverless.yml b/ops_boba/api/bobalink-api/serverless-mainnet.yml similarity index 74% rename from ops_boba/api/bobalink-api/serverless.yml rename to ops_boba/api/bobalink-api/serverless-mainnet.yml index 2408317663..27db9aa095 100644 --- a/ops_boba/api/bobalink-api/serverless.yml +++ b/ops_boba/api/bobalink-api/serverless-mainnet.yml @@ -6,7 +6,6 @@ provider: stackName: sls-boba-bobalink stage: prod region: us-east-1 - role: ${file(env.yml):ROLE} package: exclude: @@ -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} diff --git a/packages/boba/bobalink/src/utils/chains.ts b/packages/boba/bobalink/src/utils/chains.ts index 649aaeca49..11432b9d4d 100644 --- a/packages/boba/bobalink/src/utils/chains.ts +++ b/packages/boba/bobalink/src/utils/chains.ts @@ -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', }, }, }