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