2019-11-08 18:55:41 +00:00
|
|
|
const eztz = require('eztz-lib')
|
|
|
|
|
|
|
|
import {
|
2020-04-11 00:49:55 +00:00
|
|
|
Binance, Cosmos, Tezos, Tron, IoTeX, Waves, Kava, Terra,
|
|
|
|
assetFolderAllowedFiles,
|
2020-06-10 06:22:54 +00:00
|
|
|
chainFolderAllowedFiles,
|
2019-11-08 18:55:41 +00:00
|
|
|
chainsFolderPath,
|
2020-04-11 00:49:55 +00:00
|
|
|
ethSidechains,
|
|
|
|
findFiles,
|
|
|
|
getBinanceBEP2Symbols,
|
2019-11-08 18:55:41 +00:00
|
|
|
getChainAssetLogoPath,
|
2020-04-11 00:49:55 +00:00
|
|
|
getChainAssetPath,
|
|
|
|
getChainAssetsPath,
|
2020-06-10 06:22:54 +00:00
|
|
|
getChainFolderFilesList,
|
2020-04-11 00:49:55 +00:00
|
|
|
getChainBlacklistPath,
|
|
|
|
getChainLogoPath,
|
|
|
|
getChainValidatorAssetLogoPath,
|
2019-11-08 18:55:41 +00:00
|
|
|
getChainValidatorsAssets,
|
|
|
|
getChainValidatorsListPath,
|
2020-04-11 00:49:55 +00:00
|
|
|
getChainWhitelistPath,
|
|
|
|
getChainAssetsList,
|
2020-04-23 18:24:03 +00:00
|
|
|
getChainValidatorsList,
|
2019-11-08 18:55:41 +00:00
|
|
|
isChecksum,
|
2020-04-11 03:07:01 +00:00
|
|
|
isLogoDimentionOK,
|
|
|
|
isLogoSizeOK,
|
2020-04-11 00:49:55 +00:00
|
|
|
isLowerCase,
|
|
|
|
isPathDir,
|
|
|
|
isPathExistsSync,
|
|
|
|
isTRC10, isTRC20, isWavesAddress,
|
2020-01-21 09:20:02 +00:00
|
|
|
isValidJSON,
|
2020-04-11 00:49:55 +00:00
|
|
|
isAssetInfoOK,
|
2020-02-20 06:02:05 +00:00
|
|
|
isValidatorHasAllKeys,
|
2020-04-11 00:49:55 +00:00
|
|
|
mapList,
|
|
|
|
pricingFolderPath,
|
|
|
|
readDirSync,
|
|
|
|
readFileSync,
|
2020-02-20 06:02:05 +00:00
|
|
|
rootDirAllowedFiles,
|
2020-04-04 05:22:45 +00:00
|
|
|
stakingChains,
|
2019-11-08 18:55:41 +00:00
|
|
|
} from "./helpers"
|
2020-05-20 21:52:27 +00:00
|
|
|
import { ValidatorModel, mapTiker, TickerType } from "./models";
|
2020-01-28 20:55:19 +00:00
|
|
|
import { getHandle } from "../../script/gen_info";
|
2020-04-11 00:49:55 +00:00
|
|
|
|
2019-11-08 18:55:41 +00:00
|
|
|
describe("Check repository root dir", () => {
|
|
|
|
const dirActualFiles = readDirSync(".")
|
|
|
|
test("Root should contains only predefined files", () => {
|
|
|
|
dirActualFiles.forEach(file => {
|
|
|
|
expect(rootDirAllowedFiles.indexOf(file), `File "${file}" should not be in root or added to predifined list`).not.toBe(-1)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe(`Test "blockchains" folder`, () => {
|
|
|
|
const foundChains = readDirSync(chainsFolderPath)
|
|
|
|
|
|
|
|
test(`Chain should have "logo.png" image`, () => {
|
|
|
|
foundChains.forEach(chain => {
|
|
|
|
const chainLogoPath = getChainLogoPath(chain)
|
|
|
|
expect(isPathExistsSync(chainLogoPath), `File missing at path "${chainLogoPath}"`).toBe(true)
|
2020-04-11 03:07:01 +00:00
|
|
|
const [isOk, msg] = isLogoDimentionOK(chainLogoPath)
|
2019-11-19 20:22:38 +00:00
|
|
|
expect(isOk, msg).toBe(true)
|
2019-11-08 18:55:41 +00:00
|
|
|
})
|
2019-11-19 20:22:38 +00:00
|
|
|
})
|
2019-11-08 18:55:41 +00:00
|
|
|
|
|
|
|
test("Chain folder must have lowercase naming", () => {
|
|
|
|
foundChains.forEach(chain => {
|
|
|
|
expect(isLowerCase(chain), `Chain folder must be in lowercase "${chain}"`).toBe(true)
|
|
|
|
})
|
2019-11-19 20:22:38 +00:00
|
|
|
})
|
2019-11-08 18:55:41 +00:00
|
|
|
|
2020-05-30 21:56:53 +00:00
|
|
|
describe(`Asset folder should contain only predefined list of files`, () => {
|
2020-02-20 06:02:05 +00:00
|
|
|
readDirSync(chainsFolderPath).forEach(chain => {
|
|
|
|
const assetsPath = getChainAssetsPath(chain)
|
|
|
|
|
|
|
|
if (isPathExistsSync(assetsPath)) {
|
|
|
|
test(`Test asset folder allowed files on chain: ${chain}`, () => {
|
|
|
|
readDirSync(assetsPath).forEach(address => {
|
|
|
|
const assetFiles = getChainAssetPath(chain, address)
|
|
|
|
readDirSync(assetFiles).forEach(assetFolderFile => {
|
2020-03-20 20:48:55 +00:00
|
|
|
expect(assetFolderAllowedFiles.indexOf(assetFolderFile),`File "${assetFolderFile}" not allowed at this path: ${assetsPath}`).not.toBe(-1)
|
2020-02-20 06:02:05 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-06-10 06:22:54 +00:00
|
|
|
describe(`Chain folder should contain only predefined list of files`, () => {
|
|
|
|
readDirSync(chainsFolderPath).forEach(chain => {
|
|
|
|
getChainFolderFilesList(chain).forEach(file => {
|
|
|
|
expect(chainFolderAllowedFiles.indexOf(file),`File "${typeof file}" ${file} not allowed in chain folder: ${chain}`).not.toBe(-1)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2019-11-08 18:55:41 +00:00
|
|
|
describe("Check Ethereum side-chain folders", () => {
|
|
|
|
ethSidechains.forEach(chain => {
|
|
|
|
test(`Test chain ${chain} folder`, () => {
|
|
|
|
|
2020-04-11 00:49:55 +00:00
|
|
|
getChainAssetsList(chain).forEach(address => {
|
|
|
|
const assetPath = getChainAssetPath(chain, address)
|
2020-03-20 22:16:45 +00:00
|
|
|
expect(isPathDir(assetPath), `Expect directory at path: ${assetPath}`).toBe(true)
|
|
|
|
|
2020-04-11 00:49:55 +00:00
|
|
|
const checksum = isChecksum(address)
|
2020-03-20 22:16:45 +00:00
|
|
|
expect(checksum, `Expect asset at path ${assetPath} in checksum`).toBe(true)
|
2020-01-17 08:31:42 +00:00
|
|
|
|
2020-04-11 00:49:55 +00:00
|
|
|
const lowercase = isLowerCase(address)
|
2020-01-17 08:31:42 +00:00
|
|
|
if (lowercase) {
|
2020-04-11 00:49:55 +00:00
|
|
|
expect(checksum, `Lowercase address ${address} on chain ${chain} should be in checksum`).toBe(true)
|
2020-01-17 08:31:42 +00:00
|
|
|
}
|
2019-11-08 18:55:41 +00:00
|
|
|
|
2020-04-11 00:49:55 +00:00
|
|
|
const assetLogoPath = getChainAssetLogoPath(chain, address)
|
2019-11-08 18:55:41 +00:00
|
|
|
expect(isPathExistsSync(assetLogoPath), `Missing file at path "${assetLogoPath}"`).toBe(true)
|
2020-04-11 00:49:55 +00:00
|
|
|
|
2020-04-11 03:07:01 +00:00
|
|
|
const [isDimentionOK, dimensionMsg] = isLogoDimentionOK(assetLogoPath)
|
|
|
|
expect(isDimentionOK, dimensionMsg).toBe(true)
|
|
|
|
|
|
|
|
const [isLogoOK, sizeMsg] = isLogoSizeOK(assetLogoPath)
|
|
|
|
expect(isLogoOK, sizeMsg).toBe(true)
|
2020-04-11 00:49:55 +00:00
|
|
|
|
2020-04-15 23:29:52 +00:00
|
|
|
const [isInfoOK, InfoMsg] = isAssetInfoOK(chain, address)
|
|
|
|
expect(isInfoOK, InfoMsg).toBe(true)
|
2019-11-08 18:55:41 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe(`Check "binace" folder`, () => {
|
2020-06-10 22:43:17 +00:00
|
|
|
it("Asset must exist on chain", async () => {
|
2019-11-08 18:55:41 +00:00
|
|
|
const tokenSymbols = await getBinanceBEP2Symbols()
|
|
|
|
const assets = readDirSync(getChainAssetsPath(Binance))
|
|
|
|
|
|
|
|
assets.forEach(asset => {
|
|
|
|
expect(tokenSymbols.indexOf(asset), `Asset ${asset} missing on chain`).not.toBe(-1)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe(`Check "tron" folder`, () => {
|
|
|
|
const path = getChainAssetsPath(Tron)
|
|
|
|
|
|
|
|
test("Expect asset to be TRC10 or TRC20", () => {
|
|
|
|
readDirSync(path).forEach(asset => {
|
2020-05-30 21:56:53 +00:00
|
|
|
expect(isTRC10(asset) || isTRC20(asset), `Asset ${asset} at path ${path} non TRC10 nor TRC20`).toBe(true)
|
2019-11-08 18:55:41 +00:00
|
|
|
|
|
|
|
const assetsLogoPath = getChainAssetLogoPath(Tron, asset)
|
|
|
|
expect(isPathExistsSync(assetsLogoPath), `Missing file at path "${assetsLogoPath}"`).toBe(true)
|
2020-04-11 03:07:01 +00:00
|
|
|
const [isOk, msg] = isLogoDimentionOK(assetsLogoPath)
|
2019-11-19 20:22:38 +00:00
|
|
|
expect(isOk, msg).toBe(true)
|
|
|
|
})
|
2019-11-08 18:55:41 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe("Check Staking chains", () => {
|
|
|
|
test("Make sure tests added for new staking chain", () => {
|
2020-04-04 05:22:45 +00:00
|
|
|
expect(stakingChains.length).toBe(7)
|
2019-11-08 18:55:41 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
stakingChains.forEach(chain => {
|
2020-04-23 18:24:03 +00:00
|
|
|
const validatorsListPath = getChainValidatorsListPath(chain)
|
|
|
|
const validatorsList = getChainValidatorsList(chain)
|
2020-04-04 05:22:45 +00:00
|
|
|
|
|
|
|
test(`Chain ${chain} validator must have correct structure and valid JSON format`, () => {
|
2020-01-21 09:20:02 +00:00
|
|
|
validatorsList.forEach((val: ValidatorModel) => {
|
2020-04-04 05:22:45 +00:00
|
|
|
expect(isValidatorHasAllKeys(val), `Some key and/or type missing for validator ${JSON.stringify(val)}`).toBe(true)
|
2020-04-23 18:24:03 +00:00
|
|
|
expect(isValidJSON(validatorsListPath), `Not valid json file at path ${validatorsListPath}`).toBe(true)
|
2019-11-08 18:55:41 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2019-11-19 20:22:38 +00:00
|
|
|
test(`Chain ${chain} validator must have corresponding asset logo`, () => {
|
2019-11-08 18:55:41 +00:00
|
|
|
validatorsList.forEach(({ id }) => {
|
|
|
|
const path = getChainValidatorAssetLogoPath(chain, id)
|
|
|
|
expect(isPathExistsSync(path), `Chain ${chain} asset ${id} logo must be present at path ${path}`).toBe(true)
|
2019-11-19 20:22:38 +00:00
|
|
|
|
2020-04-11 03:07:01 +00:00
|
|
|
const [isOk, msg] = isLogoDimentionOK(path)
|
2019-11-19 20:22:38 +00:00
|
|
|
expect(isOk, msg).toBe(true)
|
2019-11-08 18:55:41 +00:00
|
|
|
})
|
2019-11-19 20:22:38 +00:00
|
|
|
})
|
2019-11-08 18:55:41 +00:00
|
|
|
|
|
|
|
const chainValidatorsAssetsList = getChainValidatorsAssets(chain)
|
|
|
|
switch (chain) {
|
|
|
|
case Cosmos:
|
|
|
|
testCosmosValidatorsAddress(chainValidatorsAssetsList)
|
|
|
|
break;
|
2020-04-04 05:22:45 +00:00
|
|
|
case Kava:
|
|
|
|
testKavaValidatorsAddress(chainValidatorsAssetsList)
|
|
|
|
break;
|
|
|
|
case Terra:
|
|
|
|
testTerraValidatorsAddress(chainValidatorsAssetsList)
|
|
|
|
break;
|
2019-11-08 18:55:41 +00:00
|
|
|
case Tezos:
|
|
|
|
testTezosValidatorsAssets(chainValidatorsAssetsList)
|
|
|
|
break;
|
|
|
|
case Tron:
|
|
|
|
testTronValidatorsAssets(chainValidatorsAssetsList)
|
|
|
|
break;
|
2020-04-04 05:22:45 +00:00
|
|
|
case Waves:
|
|
|
|
testWavesValidatorsAssets(chainValidatorsAssetsList)
|
|
|
|
break;
|
2020-04-08 20:12:50 +00:00
|
|
|
// case Solana:
|
|
|
|
// testSolanaValidatorsAssets(chainValidatorsAssetsList)
|
|
|
|
// break;
|
2020-04-04 05:22:45 +00:00
|
|
|
// TODO Add IoTex when taking suported by Trust
|
2019-11-08 18:55:41 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-12-18 20:04:18 +00:00
|
|
|
test("Make sure validator has corresponding logo", () => {
|
|
|
|
validatorsList.forEach(val => {
|
|
|
|
expect(chainValidatorsAssetsList.indexOf(val.id), `Expecting image asset for validator ${val.id} on chain ${chain}`)
|
|
|
|
.toBeGreaterThanOrEqual(0)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
test("Make sure validator asset logo has corresponding info", () => {
|
|
|
|
chainValidatorsAssetsList.forEach(valAssetLogoID => {
|
|
|
|
expect(validatorsList.filter(v => v.id === valAssetLogoID).length, `Expect validator logo ${valAssetLogoID} to have info`)
|
|
|
|
.toBe(1)
|
|
|
|
})
|
2019-11-19 20:22:38 +00:00
|
|
|
})
|
2019-11-08 18:55:41 +00:00
|
|
|
})
|
2019-11-19 20:22:38 +00:00
|
|
|
})
|
2019-11-08 18:55:41 +00:00
|
|
|
})
|
|
|
|
|
2020-04-04 05:22:45 +00:00
|
|
|
function testTezosValidatorsAssets(assets: string[]) {
|
2019-11-08 18:55:41 +00:00
|
|
|
test("Tezos assets must be correctly formated tz1 address", () => {
|
|
|
|
assets.forEach(addr => {
|
|
|
|
expect(eztz.crypto.checkAddress(addr), `Ivalid Tezos address: ${addr}`).toBe(true)
|
2019-11-19 20:22:38 +00:00
|
|
|
})
|
2019-11-08 18:55:41 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-04-04 05:22:45 +00:00
|
|
|
function testTronValidatorsAssets(assets: string[]) {
|
2019-11-08 18:55:41 +00:00
|
|
|
test("TRON assets must be correctly formated", () => {
|
|
|
|
assets.forEach(addr => {
|
|
|
|
expect(isTRC20(addr), `Address ${addr} should be TRC20`).toBe(true)
|
2019-11-19 20:22:38 +00:00
|
|
|
})
|
2019-11-08 18:55:41 +00:00
|
|
|
})
|
|
|
|
}
|
2020-04-04 05:22:45 +00:00
|
|
|
function testWavesValidatorsAssets(assets: string[]) {
|
|
|
|
test("WAVES assets must have correct format", () => {
|
|
|
|
assets.forEach(addr => {
|
|
|
|
expect(isWavesAddress(addr), `Address ${addr} should be WAVES formated`).toBe(true)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
2019-11-08 18:55:41 +00:00
|
|
|
|
2020-04-11 00:49:55 +00:00
|
|
|
// function testSolanaValidatorsAssets(assets: string[]) {
|
|
|
|
// test("Solana assets must have correct format", () => {
|
|
|
|
// assets.forEach(addr => {
|
|
|
|
// expect(isSolanaAddress(addr), `Address ${addr} should be Solana formated`).toBe(true)
|
|
|
|
// })
|
|
|
|
// })
|
|
|
|
// }
|
2020-04-08 20:12:50 +00:00
|
|
|
|
2020-04-04 05:22:45 +00:00
|
|
|
function testCosmosValidatorsAddress(assets: string[]) {
|
|
|
|
test("Cosmos assets must have correct format", () => {
|
2019-11-08 18:55:41 +00:00
|
|
|
assets.forEach(addr => {
|
|
|
|
expect(addr.startsWith("cosmosvaloper1"), `Address ${addr} should start from "cosmosvaloper1"`).toBe(true)
|
|
|
|
expect(addr.length, `Address ${addr} should have length 52`).toBe(52)
|
|
|
|
expect(isLowerCase(addr), `Address ${addr} should be in lowercase`).toBe(true)
|
2019-11-19 20:22:38 +00:00
|
|
|
})
|
2019-11-08 18:55:41 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-04-04 05:22:45 +00:00
|
|
|
function testKavaValidatorsAddress(assets: string[]) {
|
|
|
|
test("Kava assets must have correct format", () => {
|
|
|
|
assets.forEach(addr => {
|
|
|
|
expect(addr.startsWith("kavavaloper1"), `Address ${addr} should start from "kavavaloper1"`).toBe(true)
|
|
|
|
expect(addr.length, `Address ${addr} should have length 50`).toBe(50)
|
|
|
|
expect(isLowerCase(addr), `Address ${addr} should be in lowercase`).toBe(true)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function testTerraValidatorsAddress(assets: string[]) {
|
|
|
|
test("Terra assets must have correct format", () => {
|
|
|
|
assets.forEach(addr => {
|
|
|
|
expect(addr.startsWith("terravaloper1"), `Address ${addr} should start from "terravaloper1"`).toBe(true)
|
|
|
|
expect(addr.length, `Address ${addr} should have length 51`).toBe(51)
|
|
|
|
expect(isLowerCase(addr), `Address ${addr} should be in lowercase`).toBe(true)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-12-04 05:03:39 +00:00
|
|
|
describe("Test Coinmarketcap mapping", () => {
|
2020-05-20 21:52:27 +00:00
|
|
|
const cmcMap: mapTiker[] = JSON.parse(readFileSync("./pricing/coinmarketcap/mapping.json"))
|
2019-12-04 05:03:39 +00:00
|
|
|
|
|
|
|
test("Must have items", () => {
|
|
|
|
expect(cmcMap.length, `CMC map must have items`).toBeGreaterThan(0)
|
|
|
|
})
|
|
|
|
|
2019-12-18 22:05:09 +00:00
|
|
|
test(`Items must be sorted by "id" in ascending order`, () => {
|
2019-12-04 05:03:39 +00:00
|
|
|
cmcMap.forEach((el, i) => {
|
|
|
|
if (i > 0) {
|
2019-12-18 22:05:09 +00:00
|
|
|
const prevID = cmcMap[i - 1].id
|
|
|
|
const curID = el.id
|
|
|
|
expect(curID, `Item ${curID} must be greather or equal to ${prevID}`)
|
|
|
|
.toBeGreaterThanOrEqual(prevID)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
test(`Items must be sorted by "coin" in ascending order if have same "id"`, () => {
|
|
|
|
cmcMap.forEach((el, i) => {
|
|
|
|
if (i > 0) {
|
|
|
|
const prevEl = cmcMap[i - 1]
|
|
|
|
|
|
|
|
const prevCoin = prevEl.coin
|
|
|
|
const prevID = cmcMap[i - 1].id
|
|
|
|
|
|
|
|
const curCoin = el.coin
|
|
|
|
const curID = el.id
|
|
|
|
|
|
|
|
if (prevID == curID) {
|
|
|
|
expect(curCoin, `Item ${JSON.stringify(el)} must be greather or equal to ${JSON.stringify(prevEl)}`)
|
|
|
|
.toBeGreaterThanOrEqual(prevCoin)
|
|
|
|
}
|
|
|
|
|
2019-12-04 05:03:39 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
test("Properies value shoud not contain spaces", () => {
|
|
|
|
cmcMap.forEach(el => {
|
|
|
|
Object.keys(el).forEach(key => {
|
|
|
|
const val = el[key]
|
|
|
|
if (typeof val === "string") {
|
|
|
|
expect(val.indexOf(" ") >= 0, ` Property value "${val}" should not contain space`).toBe(false)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Params should have value and correct type", () => {
|
|
|
|
cmcMap.forEach(el => {
|
|
|
|
const {coin, type, id, token_id} = el
|
|
|
|
|
|
|
|
expect(typeof coin, `Coin ${coin} must be type "number"`).toBe("number")
|
|
|
|
|
|
|
|
expect(["token", "coin"], `Element with id ${id} has wrong type: "${type}"`).toContain(type)
|
|
|
|
if (type === "token") {
|
|
|
|
expect(token_id, `token_id ${token_id} with id ${id} must be type not empty`).toBeTruthy()
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type === "coin") {
|
|
|
|
expect(el, `Element with id ${id} should not have property "token_id"`).not.toHaveProperty("token_id")
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test(`"token_id" should be in correct format`, async () => {
|
2020-05-20 21:52:27 +00:00
|
|
|
const bep2Symbols = await getBinanceBEP2Symbols()
|
2019-12-04 05:03:39 +00:00
|
|
|
|
|
|
|
cmcMap.forEach(el => {
|
|
|
|
const {coin, token_id, type, id} = el
|
|
|
|
switch (coin) {
|
2020-05-20 21:52:27 +00:00
|
|
|
case 60:
|
|
|
|
if (type === TickerType.Token) {
|
|
|
|
expect(isChecksum(token_id), `"token_id" ${token_id} with id ${id} must be in checksum`).toBe(true)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 195:
|
|
|
|
if (type === TickerType.Token) {
|
|
|
|
expect(isTRC10(token_id) || isTRC20(token_id), `"token_id" ${token_id} with id ${id} must be in TRC10 or TRC20`).toBe(true)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 714:
|
|
|
|
if (type === TickerType.Token) {
|
|
|
|
expect(bep2Symbols.indexOf(token_id), `"token_id" ${token_id} with id ${id} must be BEP2 symbol`).toBeGreaterThan(0)
|
|
|
|
break;
|
|
|
|
}
|
2019-12-04 05:03:39 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2020-05-20 21:52:27 +00:00
|
|
|
|
|
|
|
test(`"token_id" shoud be unique`, () => {
|
|
|
|
const mappedList = cmcMap.reduce((acm, val) => {
|
|
|
|
if (val.hasOwnProperty("token_id")) {
|
|
|
|
if (acm.hasOwnProperty(val.token_id)) {
|
|
|
|
acm[val.token_id] == ++acm[val.token_id]
|
|
|
|
} else {
|
|
|
|
acm[val.token_id] = 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return acm
|
|
|
|
}, {})
|
|
|
|
|
|
|
|
cmcMap.forEach(el => {
|
|
|
|
if (el.hasOwnProperty("token_id")) {
|
|
|
|
expect(mappedList[el.token_id], `CMC map ticker with "token_id" ${el.token_id} shoud be unique`).toBeLessThanOrEqual(0)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2019-12-04 05:03:39 +00:00
|
|
|
})
|
2020-01-05 04:51:15 +00:00
|
|
|
|
2020-01-16 21:10:59 +00:00
|
|
|
describe("Test blacklist and whitelist", () => {
|
2020-01-05 04:51:15 +00:00
|
|
|
const assetsChains = readDirSync(chainsFolderPath).filter(chain => isPathExistsSync(getChainAssetsPath(chain)))
|
|
|
|
|
|
|
|
assetsChains.forEach(chain => {
|
|
|
|
const whiteList = JSON.parse(readFileSync(getChainWhitelistPath(chain)))
|
|
|
|
const blackList = JSON.parse(readFileSync(getChainBlacklistPath(chain)))
|
|
|
|
|
|
|
|
test(`Whitelist should not contain assets from blacklist on ${chain} chain`, () => {
|
2020-04-21 21:24:41 +00:00
|
|
|
const blacklistMap = mapList(blackList)
|
2020-01-05 04:51:15 +00:00
|
|
|
whiteList.forEach(a => {
|
2020-04-21 21:24:41 +00:00
|
|
|
expect(a in blacklistMap, `Found whitelist asset ${a} in blacklist on chain ${chain}`).toBe(false)
|
2020-01-05 04:51:15 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
test(`Blacklist should not contain assets from whitelist on ${chain} chain`, () => {
|
2020-04-21 21:24:41 +00:00
|
|
|
const whitelistMap = mapList(whiteList)
|
2020-01-05 04:51:15 +00:00
|
|
|
blackList.forEach(a => {
|
2020-04-21 21:24:41 +00:00
|
|
|
expect(a in whitelistMap, `Found blacklist asset ${a} in whitelist on chain ${chain}`).toBe(false)
|
2020-01-05 04:51:15 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2020-01-28 20:55:19 +00:00
|
|
|
describe("Test coins info.json file", () => {
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2020-01-14 23:02:14 +00:00
|
|
|
describe("Test all JSON files to have valid content", () => {
|
|
|
|
const files = [
|
|
|
|
...findFiles(chainsFolderPath, 'json'),
|
|
|
|
...findFiles(pricingFolderPath, 'json')
|
|
|
|
]
|
|
|
|
|
|
|
|
files.forEach(file => {
|
|
|
|
expect(isValidJSON(file), `${file} path contains invalid JSON`).toBe(true)
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2020-01-28 20:55:19 +00:00
|
|
|
describe("Test helper functions", () => {
|
|
|
|
test(`Test getHandle`, () => {
|
|
|
|
const urls = [
|
|
|
|
{
|
|
|
|
url: "https://twitter.com/aeternity",
|
|
|
|
expected: "aeternity"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: "https://www.reddit.com/r/Aeternity",
|
|
|
|
expected: "Aeternity"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
urls.forEach(u => {
|
|
|
|
expect(getHandle(u.url), `Getting handle from url ${u}`).toBe(u.expected)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|