Skip to content

Commit

Permalink
Test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Subarna-Singh committed Feb 21, 2025
1 parent 4d969e6 commit 07addc3
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,41 @@ exports[`execute apiAddress endpoint bedrock vault should return success 1`] = `
}
`;

exports[`execute apiAddress endpoint coinbase BTC should return success 1`] = `
{
"data": {
"result": [
{
"address": "bc1qkqu7akp4lf3vmkde5l4ydp596wp8fm93m9yptd",
"chainId": "mainnet",
"network": "bitcoin",
},
{
"address": "1xT8bWnZzS339nQLnrdqBW6yz8Nt5KjLC",
"chainId": "mainnet",
"network": "bitcoin",
},
{
"address": "1FprAosJemf7TDvLGaTHbUWms3Z1uLUwJS",
"chainId": "mainnet",
"network": "bitcoin",
},
{
"address": "1CgpdCJAkEQrzgqRh4C2EkyKsGCZxDFPEa",
"chainId": "mainnet",
"network": "bitcoin",
},
],
},
"result": null,
"statusCode": 200,
"timestamps": {
"providerDataReceivedUnixMs": 978347471111,
"providerDataRequestedUnixMs": 978347471111,
},
}
`;

exports[`execute apiAddress endpoint solv should return success 1`] = `
{
"data": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import {
} from '@chainlink/external-adapter-framework/util/testing-utils'
import * as nock from 'nock'
import { ethers } from 'ethers'
import { mockBedRockResponseSuccess, mockSolvResponseSuccess } from './fixtures-api'
import {
mockBedRockResponseSuccess,
mockCoinbaseResponseSuccess,
mockSolvResponseSuccess,
} from './fixtures-api'

const mockExpectedAddresses = [
'0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
Expand Down Expand Up @@ -57,6 +61,7 @@ describe('execute', () => {
oldEnv = JSON.parse(JSON.stringify(process.env))
process.env.RPC_URL = process.env.RPC_URL ?? 'http://localhost:8545'
process.env.BEDROCK_UNIBTC_API_ENDPOINT = 'http://bedrock'
process.env.COINBASE_CBBTC_API_ENDPOINT = 'http://coinbase'
process.env.SOLVBTC_API_ENDPOINT = 'http://solv'
process.env.BACKGROUND_EXECUTE_MS = '0'
process.env.RATE_LIMIT_CAPACITY_SECOND = '500'
Expand Down Expand Up @@ -133,5 +138,15 @@ describe('execute', () => {
expect(response.statusCode).toBe(200)
expect(response.json()).toMatchSnapshot()
})

it('coinbase BTC should return success', async () => {
const data = {
endpoint: 'coinbaseBtcAddress',
}
mockCoinbaseResponseSuccess()
const response = await testAdapter.request(data)
expect(response.statusCode).toBe(200)
expect(response.json()).toMatchSnapshot()
})
})
})
113 changes: 113 additions & 0 deletions packages/sources/por-address-list/test/integration/fixtures-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,118 @@
import nock from 'nock'

export const mockCoinbaseResponseSuccess = (): nock.Scope =>
nock('http://coinbase', {
encodedQueryParams: true,
})
.get('/')
.reply(
200,
() => ({
schema: 'v1',
lastUpdatedAt: '2025-02-21T17:59:48Z',
reservesTotal: {
amount: '26765.13145192',
currency: {
name: 'BTC',
},
network: {
name: 'bitcoin',
},
},
reserveAddresses: [
{
address: 'bc1qkqu7akp4lf3vmkde5l4ydp596wp8fm93m9yptd',
balance: {
amount: '690.00001207',
currency: {
name: 'BTC',
},
network: {
name: 'bitcoin',
},
},
},
{
address: '1xT8bWnZzS339nQLnrdqBW6yz8Nt5KjLC',
balance: {
amount: '480.98450058',
currency: {
name: 'BTC',
},
network: {
name: 'bitcoin',
},
},
},
{
address: '1FprAosJemf7TDvLGaTHbUWms3Z1uLUwJS',
balance: {
amount: '480.98433527',
currency: {
name: 'BTC',
},
network: {
name: 'bitcoin',
},
},
},
{
address: '1CgpdCJAkEQrzgqRh4C2EkyKsGCZxDFPEa',
balance: {
amount: '480.98433527',
currency: {
name: 'BTC',
},
network: {
name: 'bitcoin',
},
},
},
],
wrappedAssetsByNetwork: [
{
amount: '16410.75085686',
currency: {
name: 'CBBTC',
address: '0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf',
},
network: {
name: 'ethereum',
chainId: '1',
},
},
{
amount: '7614.45412467',
currency: {
name: 'CBBTC',
address: '0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf',
},
network: {
name: 'base',
chainId: '8453',
},
},
],
wrappedAssetsTotal: {
amount: '26754.167082',
currency: {
name: 'CBBTC',
},
},
}),
[
'Content-Type',
'application/json',
'Connection',
'close',
'Vary',
'Accept-Encoding',
'Vary',
'Origin',
],
)
.persist()

export const mockBedRockResponseSuccess = (): nock.Scope =>
nock('http://bedrock', {
encodedQueryParams: true,
Expand Down

0 comments on commit 07addc3

Please sign in to comment.