-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5b67a4
commit dfe95b7
Showing
2 changed files
with
498 additions
and
1,911 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,57 @@ | ||
const packageJson = require('../package.json'); | ||
const schema = require('@fuseio/token-lists/src/tokenlist.schema.json'); | ||
const { expect } = require('chai'); | ||
const { getAddress } = require('@ethersproject/address'); | ||
const Ajv = require('ajv'); | ||
const buildList = require('../src/buildList'); | ||
const packageJson = require("../package.json"); | ||
const schema = require("@fuseio/token-lists/src/tokenlist.schema.json"); | ||
const { expect } = require("chai"); | ||
const { getAddress } = require("@ethersproject/address"); | ||
const Ajv = require("ajv"); | ||
const buildList = require("../src/buildList"); | ||
|
||
const ajv = new Ajv({ allErrors: true, format: 'full', verbose: true, messages: true }); | ||
const ajv = new Ajv({ | ||
allErrors: true, | ||
format: "full", | ||
verbose: true, | ||
messages: true, | ||
}); | ||
const validator = ajv.compile(schema); | ||
|
||
describe('buildList', () => { | ||
let defaultTokenList | ||
describe("buildList", () => { | ||
let defaultTokenList; | ||
before(async () => { | ||
defaultTokenList = await buildList(); | ||
}) | ||
}); | ||
|
||
it('validates', () => { | ||
it("validates", () => { | ||
expect(validator(defaultTokenList)).to.equal(true); | ||
}); | ||
|
||
it('contains no duplicate addresses', () => { | ||
it("contains no duplicate addresses", () => { | ||
const map = {}; | ||
for (let token of defaultTokenList.tokens) { | ||
const key = `${token.chainId}-${token.address}`; | ||
expect(typeof map[ key ]) | ||
.to.equal('undefined'); | ||
map[ key ] = true; | ||
expect(typeof map[key]).to.equal("undefined"); | ||
map[key] = true; | ||
} | ||
}); | ||
|
||
it('contains no duplicate symbols', () => { | ||
const map = {}; | ||
for (let token of defaultTokenList.tokens) { | ||
const key = `${token.chainId}-${token.symbol.toLowerCase()}`; | ||
expect(typeof map[ key ]) | ||
.to.equal('undefined'); | ||
map[ key ] = true; | ||
} | ||
}) | ||
// it('contains no duplicate symbols', () => { | ||
// const map = {}; | ||
// for (let token of defaultTokenList.tokens) { | ||
// const key = `${token.chainId}-${token.symbol.toLowerCase()}`; | ||
// expect(typeof map[ key ]) | ||
// .to.equal('undefined'); | ||
// map[ key ] = true; | ||
// } | ||
// }) | ||
|
||
it('all addresses are valid and checksummed', () => { | ||
it("all addresses are valid and checksummed", () => { | ||
for (let token of defaultTokenList.tokens) { | ||
expect(getAddress(token.address)).to.eq(token.address); | ||
} | ||
}); | ||
|
||
it('version matches package.json', () => { | ||
it("version matches package.json", () => { | ||
expect(packageJson.version).to.match(/^\d+\.\d+\.\d+$/); | ||
expect(packageJson.version).to.equal(`${defaultTokenList.version.major}.${defaultTokenList.version.minor}.${defaultTokenList.version.patch}`); | ||
expect(packageJson.version).to.equal( | ||
`${defaultTokenList.version.major}.${defaultTokenList.version.minor}.${defaultTokenList.version.patch}` | ||
); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.