Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixFan1992 committed Jan 23, 2025
1 parent 048d314 commit 392f455
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 1,213 deletions.
14 changes: 7 additions & 7 deletions test/integration/ResponseListener.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {
} from '../../src'
import { setupLocalTestnetFixture } from '../utils'

import { Contract, Wallet, ethers } from 'ethers'
import { Wallet, ethers, BaseContract } from 'ethers'

describe('Functions toolkit classes', () => {
let linkTokenAddress: string
let functionsRouterAddress: string
let exampleClient: Contract
let exampleClient: BaseContract
let close: () => Promise<void>
let allowlistedUser_A: Wallet

Expand Down Expand Up @@ -57,7 +57,7 @@ describe('Functions toolkit classes', () => {
functionsRouterAddress,
})

const succReqTx = await exampleClient.sendRequest(
const succReqTx = await exampleClient.getFunction('sendRequest')(
'return Functions.encodeUint256(1)',
1,
[],
Expand All @@ -80,7 +80,7 @@ describe('Functions toolkit classes', () => {
expect(succResponse.returnDataBytesHexstring).toBe('0x')
expect(succResponse.fulfillmentCode).toBe(FulfillmentCode.FULFILLED)

const errReqTx = await exampleClient.sendRequest(
const errReqTx = await exampleClient.getFunction('sendRequest')(
'return Functions.encodeUint256(1',
1,
[],
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('Functions toolkit classes', () => {
functionsRouterAddress,
})

const succReqTx = await exampleClient.sendRequest(
const succReqTx = await exampleClient.getFunction('sendRequest')(
'return Functions.encodeUint256(1)',
1,
[],
Expand All @@ -153,7 +153,7 @@ describe('Functions toolkit classes', () => {
expect(succResponse.returnDataBytesHexstring).toBe('0x')
expect(succResponse.fulfillmentCode).toBe(FulfillmentCode.FULFILLED)

const errReqTx = await exampleClient.sendRequest(
const errReqTx = await exampleClient.getFunction('sendRequest')(
'return Functions.encodeUint256(1',
1,
[],
Expand Down Expand Up @@ -216,7 +216,7 @@ describe('Functions toolkit classes', () => {
const subIdString = subscriptionId.toString()
functionsListener.listenForResponses(subIdString, responseCallback)

await exampleClient.sendRequest(
await exampleClient.getFunction('sendRequest')(
'return Functions.encodeUint256(1)',
1,
[],
Expand Down
8 changes: 6 additions & 2 deletions test/integration/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { mockOffchainSecretsEndpoints, mockGatewayUrl } from './apiFixture'
import { setupLocalTestnetFixture } from '../utils'

import { Wallet, ethers, BaseContract, toBigInt } from 'ethers'
import { Wallet, ethers, BaseContract, toBigInt, EventLog } from 'ethers'

jest.retryTimes(2, { logErrorsBeforeRetry: true })

Expand Down Expand Up @@ -1092,7 +1092,11 @@ describe('Functions toolkit classes', () => {
reqReceipt.blockHash,
)

const commitmentData = oracleRequestEvent[0].args![9]
// only EventLog has args. Log does not have args.
// check the type of oracleRequestEvent[0] and make sure it is EventLog
expect(typeof oracleRequestEvent[0]).toBe('EventLog')
const eventLog = oracleRequestEvent[0] as EventLog
const commitmentData = eventLog.args![9]

const commitment: RequestCommitment = {
requestId: commitmentData[0],
Expand Down
Loading

0 comments on commit 392f455

Please sign in to comment.