Skip to content

Commit

Permalink
fix(test): Use new API to assert metric value (stephenh#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
Poytr1 committed Sep 4, 2022
1 parent 7c7a8cd commit 3f31d42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions sdk/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,10 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
let res: O11yResult | null
if (instruction.parsed) {
res = processor.handleInstruction(JSON.parse(new TextDecoder().decode(instruction.parsed)))
} else {
} else if (instruction.instructionData) {
res = processor.handleInstruction(instruction.instructionData)
} else {
continue
}
if (res) {
try {
Expand All @@ -309,7 +311,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
console.error('error processing instruction ' + e.toString())
}
} else {
console.error(
console.warn(
`Failed to decode the instruction: ${instruction.instructionData} with slot: ${instruction.slot}`
)
}
Expand Down
8 changes: 4 additions & 4 deletions sdk/src/test/solana.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { HandlerType, ProcessInstructionsRequest } from '..'
import Long from 'long'
import { TextEncoder } from 'util'
import { TestProcessorServer } from './test-processor-server'
import { MetricValueToNumber } from './metric-utils'
import { firstCounterValue } from './metric-utils'

describe('Test Solana Example', () => {
const service = new TestProcessorServer()
Expand Down Expand Up @@ -37,7 +37,7 @@ describe('Test Solana Example', () => {
const res = await service.processInstructions(request)
expect(res.result?.counters).length(3)
expect(res.result?.gauges).length(0)
expect(MetricValueToNumber(res.result?.counters[0].metricValue)).equal(5000000000n)
expect(firstCounterValue(res.result, 'deposit_pool_total_value')).equal(5000000000n)
})

test('Check wormhole token bridge instruction dispatch', async () => {
Expand All @@ -59,7 +59,7 @@ describe('Test Solana Example', () => {
expect(res.result?.counters).length(2)
expect(res.result?.gauges).length(0)
expect(res.result?.counters[0].metadata?.blockNumber.toInt()).equal(0)
expect(MetricValueToNumber(res.result?.counters[0].metricValue)).equal(1000000n)
expect(firstCounterValue(res.result, 'total_transfer_amount')).equal(1000000n)
expect(res.result?.counters[0].runtimeInfo?.from).equals(HandlerType.INSTRUCTION)
})

Expand Down Expand Up @@ -87,7 +87,7 @@ describe('Test Solana Example', () => {
expect(res.result?.counters).length(1)
expect(res.result?.gauges).length(0)
expect(res.result?.counters[0].metadata?.blockNumber.toInt()).equal(0)
expect(MetricValueToNumber(res.result?.counters[0].metricValue)).equal(12000000000000)
expect(firstCounterValue(res.result, 'totalWeth_supply')).equal(12000000000000)
expect(res.result?.counters[0].runtimeInfo?.from).equals(HandlerType.INSTRUCTION)
})
})

0 comments on commit 3f31d42

Please sign in to comment.