Skip to content

Commit

Permalink
Added wait
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed Feb 28, 2024
1 parent 0e1e600 commit d62c1a3
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions crosschain-resolver/test/testResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000'
const EMPTY_BYTES32 =
'0x0000000000000000000000000000000000000000000000000000000000000000'

// looks like there are time dependencies for verification to success, hence adding a dalay
const wait = async x => {
return new Promise(resolve => {
setTimeout(resolve, 3000, 2 * x);
});
};

type ethersObj = typeof ethersT &
Omit<HardhatEthersHelpers, 'provider'> & {
Expand Down Expand Up @@ -218,7 +224,7 @@ describe('Crosschain Resolver', () => {
const result = await l2contract['addr(bytes32)'](node)
expect(ethers.getAddress(result)).to.equal(addr);
await provider.send("evm_mine", []);

await wait(1);
const i = new ethers.Interface(["function addr(bytes32) returns(address)"])
const calldata = i.encodeFunctionData("addr", [node])
const result2 = await target.resolve(encodedname, calldata, { enableCcipRead: true })
Expand All @@ -234,9 +240,9 @@ describe('Crosschain Resolver', () => {
const result = await l2contract['addr(bytes32)'](node)
expect(ethers.getAddress(result)).to.equal(addr);
await provider.send("evm_mine", []);

const i = new ethers.Interface(["function addr(bytes32) returns(address)"])
const calldata = i.encodeFunctionData("addr", [node])
await wait(1);
const result2 = await target.resolve(encodedname, calldata, { enableCcipRead: true })
const decoded = i.decodeFunctionResult("addr", result2)
expect(decoded[0]).to.equal(addr);
Expand All @@ -253,6 +259,7 @@ describe('Crosschain Resolver', () => {
const result = await l2contract['addr(bytes32)'](subnode)
expect(ethers.getAddress(result)).to.equal(addr);
await provider.send("evm_mine", []);
await wait(1);
const i = new ethers.Interface(["function addr(bytes32) returns(address)"])
const calldata = i.encodeFunctionData("addr", [subnode])

Expand All @@ -269,7 +276,7 @@ describe('Crosschain Resolver', () => {
await l2contract.clearRecords(node)
await l2contract['setAddr(bytes32,uint256,bytes)'](node, coinType, addr)
await provider.send("evm_mine", []);

await wait(1);
const i = new ethers.Interface(["function addr(bytes32,uint256) returns(bytes)"])
const calldata = i.encodeFunctionData("addr", [node, coinType])
const result2 = await target.resolve(encodedname, calldata, { enableCcipRead: true })
Expand All @@ -284,7 +291,7 @@ describe('Crosschain Resolver', () => {
await l2contract.clearRecords(node)
await l2contract.setText(node, key, value)
await provider.send("evm_mine", []);

await wait(1);
const i = new ethers.Interface(["function text(bytes32,string) returns(string)"])
const calldata = i.encodeFunctionData("text", [node, key])
const result2 = await target.resolve(encodedname, calldata, { enableCcipRead: true })
Expand All @@ -298,7 +305,7 @@ describe('Crosschain Resolver', () => {
await l2contract.clearRecords(node)
await l2contract.setContenthash(node, contenthash)
await provider.send("evm_mine", []);

await wait(1);
const i = new ethers.Interface(["function contenthash(bytes32) returns(bytes)"])
const calldata = i.encodeFunctionData("contenthash", [node])
const result2 = await target.resolve(encodedname, calldata, { enableCcipRead: true })
Expand Down

0 comments on commit d62c1a3

Please sign in to comment.