Adjust test suite to match ethereum-ens implementation

master
Dan Finlay 8 years ago
parent 6bbabba298
commit df0a5920df
No known key found for this signature in database
GPG Key ID: 931102F24B36007A

@ -1,4 +1,4 @@
const sha3 = require('js-sha3').keccak_256 const sha3 = require('js-sha3').sha3_256
const uts46 = require('idna-uts46') const uts46 = require('idna-uts46')
module.exports = function namehash (inputName) { module.exports = function namehash (inputName) {
@ -19,7 +19,6 @@ module.exports = function namehash (inputName) {
const remainderHash = namehash(remainder).substr(2) const remainderHash = namehash(remainder).substr(2)
const labelHash = sha3(label) const labelHash = sha3(label)
if (remainderHash.match(/^0+$/)) { if (remainderHash.match(/^0+$/)) {
return '0x' + labelHash return '0x' + labelHash
} }

@ -19,6 +19,7 @@ test('empty param', (t) => {
t.equal(output, expected) t.equal(output, expected)
}) })
/*
test('TLD eth', (t) => { test('TLD eth', (t) => {
t.plan(1) t.plan(1)
const input = 'eth' const input = 'eth'
@ -26,6 +27,7 @@ test('TLD eth', (t) => {
const output = namehash(input) const output = namehash(input)
t.equal(output, expected) t.equal(output, expected)
}) })
*/
/* /*
* Commented out because it turns out the EIP has incorrect specs: * Commented out because it turns out the EIP has incorrect specs:
@ -33,6 +35,15 @@ test('TLD eth', (t) => {
* *
* The correct specs are here, but too sparse to use: * The correct specs are here, but too sparse to use:
* http://docs.ens.domains/en/latest/introduction.html#namehash * http://docs.ens.domains/en/latest/introduction.html#namehash
*/
test('TLD eth', (t) => {
t.plan(1)
const input = 'eth'
const expected = '0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae'
const output = namehash(input)
t.equal(output, expected)
})
test('foo.eth', (t) => { test('foo.eth', (t) => {
t.plan(1) t.plan(1)
const input = 'foo.eth' const input = 'foo.eth'
@ -40,4 +51,3 @@ test('foo.eth', (t) => {
const output = namehash(input) const output = namehash(input)
t.equal(output, expected) t.equal(output, expected)
}) })
*/

Loading…
Cancel
Save