Skip to content

Commit

Permalink
Added wait
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed Mar 29, 2024
1 parent 4ed7391 commit fffd813
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 @@ -30,6 +30,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 @@ -217,7 +223,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 @@ -233,9 +239,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 @@ -252,6 +258,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 @@ -267,7 +274,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 @@ -282,7 +289,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 @@ -296,7 +303,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 fffd813

Please sign in to comment.