Skip to content

Commit

Permalink
update resolveCallback into handleCall method
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanrikulu committed Jul 12, 2023
1 parent af575ee commit 873d201
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions tests/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,31 @@ export class MockProvider extends BaseProvider {
}

let bytes = arrayify(result);
const { urls, callData } = CCIP_READ_INTERFACE.decodeErrorResult(
'OffchainLookup',
bytes
);
const {
urls,
callData,
callbackFunction,
extraData,
} = CCIP_READ_INTERFACE.decodeErrorResult('OffchainLookup', bytes);

const response = await this.sendRPC(
provider.fetcher,
urls,
params.transaction.to,
callData
);

let encodedResult = ethers.utils.defaultAbiCoder.encode(
['bytes'],
[response]
);
let encodedData = CCIP_READ_INTERFACE.encodeFunctionData(callbackFunction, [
response,
extraData,
]);
params.transaction.data = encodedData;

let resultCallback = await provider.parent.perform('call', params);

return {
transaction: params.transaction,
result: encodedResult,
result: resultCallback,
};
}

Expand Down Expand Up @@ -185,10 +191,7 @@ describe('End to end test', () => {
Server
);

async function fetcher(
_url: string,
json?: string
) {
async function fetcher(_url: string, json?: string) {
const { sender: to, data } = JSON.parse(json as string);
const ret = await supertest(server).get(`/${to}/${data}.json`);
return ret;
Expand Down Expand Up @@ -248,18 +251,9 @@ describe('End to end test', () => {
const dnsName = hexEncodeName(TEST_NAME);
const response = await resolver.resolve(dnsName, callData);

const extraData = ethers.utils.defaultAbiCoder.encode(
['bytes', 'bytes'],
[dnsName, callData]
);

const resultCallback = await resolver.resolveCallback(
response,
extraData
);
const resultData = Resolver.decodeFunctionResult(
'addr(bytes32)',
resultCallback
response
);

expect(resultData).to.deep.equal([TEST_ADDRESS]);
Expand Down

0 comments on commit 873d201

Please sign in to comment.