tests: added extra namehash test vectors
This commit is contained in:
parent
cd075d05f2
commit
e8a408565e
@ -2,22 +2,24 @@ import assert from "assert";
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
hashMessage,
|
hashMessage,
|
||||||
|
namehash, isValidName,
|
||||||
solidityPacked, solidityPackedKeccak256, solidityPackedSha256,
|
solidityPacked, solidityPackedKeccak256, solidityPackedSha256,
|
||||||
isError
|
isError
|
||||||
} from "../index.js";
|
} from "../index.js";
|
||||||
|
|
||||||
import { loadTests } from "./utils.js"
|
import { loadTests } from "./utils.js"
|
||||||
|
|
||||||
import type { TestCaseSolidityHash } from "./types.js";
|
import type { TestCaseNamehash, TestCaseSolidityHash } from "./types.js";
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
import { dnsEncode, isValidName, namehash } from "../index.js";
|
//import { dnsEncode, isValidName, namehash } from "../index.js";
|
||||||
|
|
||||||
describe("Tests Namehash", function() {
|
describe("Tests Namehash", function() {
|
||||||
const tests = loadTests<TestCaseNamehash>("namehash");
|
const tests = loadTests<TestCaseNamehash>("namehash");
|
||||||
for (const test of tests) {
|
for (const test of tests) {
|
||||||
it(`hashes ENS names: ${ JSON.stringify(test.ensName) }`, function() {
|
if (test.error) {
|
||||||
|
} else {
|
||||||
|
it(`hashes ENS name: ${ JSON.stringify(test.name) }`, function() {
|
||||||
const actual = namehash(test.ensName);
|
const actual = namehash(test.ensName);
|
||||||
|
|
||||||
assert.equal(actual, test.namehash, "namehash");
|
assert.equal(actual, test.namehash, "namehash");
|
||||||
@ -28,8 +30,10 @@ describe("Tests Namehash", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
describe("Tests Bad ENS Names", function() {
|
describe("Tests Bad ENS Names", function() {
|
||||||
const badTests: Array<{ ensName: any, prefix: string }> = [
|
const badTests: Array<{ ensName: any, prefix: string }> = [
|
||||||
{ ensName: ".", prefix: "missing component" },
|
{ ensName: ".", prefix: "missing component" },
|
||||||
|
@ -107,7 +107,8 @@ export interface TestCaseHash {
|
|||||||
export interface TestCaseNamehash {
|
export interface TestCaseNamehash {
|
||||||
name: string;
|
name: string;
|
||||||
ensName: string;
|
ensName: string;
|
||||||
namehash: string;
|
error?: string;
|
||||||
|
namehash?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TestCaseTypedDataDomain {
|
export interface TestCaseTypedDataDomain {
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user