Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNi245 committed Sep 7, 2023
1 parent 8814065 commit 73333e3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions test/contracts/ERC3668Resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,19 @@ describe('ERC3668Resolver Test', () => {
'function resolveWithContext(bytes calldata name,bytes calldata data,bytes calldata context) external view returns (bytes memory result)',
]);

const result = ethers.utils.defaultAbiCoder.encode(['bytes'], [alice.address]);
const result = ethers.utils.hexlify(alice.address)

const name = ethers.utils.dnsEncode('alice.eth');
const data = iface.encodeFunctionData('addr', [ethers.utils.namehash('alice.eth')]);
const extraData = iface.encodeFunctionData('resolveWithContext', [name, data, alice.address]);
const response = await signAndEncodeResponse(signer, erc3668Resolver.address, result, extraData);

const encodedResponse = await erc3668Resolver.resolveWithProof(response, extraData);
const [decodedResponse] = ethers.utils.defaultAbiCoder.decode(['bytes'], encodedResponse);
const resolvedResponse = await erc3668Resolver.resolveWithProof(response, extraData);
console.log(resolvedResponse)

expect(ethers.utils.getAddress(decodedResponse)).to.equal(alice.address);
const ethersFormated = new ethers.providers.Formatter().callAddress(resolvedResponse)

expect(ethers.utils.getAddress(ethersFormated)).to.equal(alice.address);
});
it('ResolveWithProf for sub domain using verifier ', async () => {
await erc3668Resolver.connect(alice).setVerifierForDomain(
Expand All @@ -500,17 +502,18 @@ describe('ERC3668Resolver Test', () => {
'function resolveWithContext(bytes calldata name,bytes calldata data,bytes calldata context) external view returns (bytes memory result)',
]);

const result = ethers.utils.defaultAbiCoder.encode(['bytes'], [alice.address]);
const result = ethers.utils.hexlify(alice.address)

const name = ethers.utils.dnsEncode('foo.alice.eth');
const data = iface.encodeFunctionData('addr', [ethers.utils.namehash('foo.alice.eth')]);
const extraData = iface.encodeFunctionData('resolveWithContext', [name, data, alice.address]);
const response = await signAndEncodeResponse(signer, erc3668Resolver.address, result, extraData);

const encodedResponse = await erc3668Resolver.resolveWithProof(response, extraData);
const [decodedResponse] = ethers.utils.defaultAbiCoder.decode(['bytes'], encodedResponse);
const resolvedResponse = await erc3668Resolver.resolveWithProof(response, extraData);

const ethersFormated = new ethers.providers.Formatter().callAddress(resolvedResponse)

expect(ethers.utils.getAddress(decodedResponse)).to.equal(alice.address);
expect(ethers.utils.getAddress(ethersFormated)).to.equal(alice.address);
});
});
describe('Metadata', () => {
Expand Down

0 comments on commit 73333e3

Please sign in to comment.