diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 892a9567c..4bad86f74 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -6,8 +6,7 @@ const base = require('@polkadot/dev/config/eslint.cjs'); module.exports = { ...base, ignorePatterns: [ - ...base.ignorePatterns, - '**/deno/*.ts' + ...base.ignorePatterns ], parserOptions: { ...base.parserOptions, diff --git a/.gitignore b/.gitignore index b114883ad..8667f66c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,8 @@ --test-* _book/ build/ -build-cjs/ -build-esm/ -build-deno/ -build-docs/ +build-*/ coverage/ -docs/.vuepress/dist/ node_modules/ tmp/ /import_map.json @@ -29,6 +25,4 @@ npm-debug.log* package-lock.json yarn-debug.log* yarn-error.log* -store.db -store.db.compacted tsconfig.*buildinfo diff --git a/package.json b/package.json index 46273a3db..dc198f076 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "@babel/core": "^7.18.6", - "@polkadot/dev": "^0.67.69", + "@polkadot/dev": "^0.67.73", "@types/jest": "^28.1.4" }, "resolutions": { diff --git a/packages/util/src/bi/sqrt.spec.ts b/packages/util/src/bi/sqrt.spec.ts index c83f4f534..87912b70a 100644 --- a/packages/util/src/bi/sqrt.spec.ts +++ b/packages/util/src/bi/sqrt.spec.ts @@ -5,7 +5,7 @@ import { BN } from '../bn'; import { SQRT_MAX_SAFE_INTEGER } from './sqrt'; import { nSqrt } from '.'; -const TESTS: [string | number | BN | bigint, string | number][] = [ +export const SQRT_TESTS: [string | number | BN | bigint, string | number][] = [ [0, 0], [1, 1], [4, 2], @@ -45,7 +45,7 @@ describe('nSqrt', (): void => { ).toEqual(true); }); - TESTS.forEach(([value, expected], index): void => { + SQRT_TESTS.forEach(([value, expected], index): void => { it(`calcs for test #${index}`, (): void => { expect( nSqrt(value) === BigInt(expected) diff --git a/packages/util/src/bn/sqrt.spec.ts b/packages/util/src/bn/sqrt.spec.ts index fd1797e57..be8d74b81 100644 --- a/packages/util/src/bn/sqrt.spec.ts +++ b/packages/util/src/bn/sqrt.spec.ts @@ -1,32 +1,10 @@ // Copyright 2017-2022 @polkadot/util authors & contributors // SPDX-License-Identifier: Apache-2.0 +import { SQRT_TESTS } from '../bi/sqrt.spec'; import { SQRT_MAX_SAFE_INTEGER } from './sqrt'; import { BN, bnSqrt } from '.'; -const TESTS: [string | number | BN | bigint, string | number][] = [ - [0, 0], - [1, 1], - [4, 2], - [256 * 256, 256], - [Number.MAX_SAFE_INTEGER, 94906265], - [new BN(Number.MAX_SAFE_INTEGER).iaddn(256), 94906265], - [12345678n * 12345679n, 12345678], - // test cases below from https://github.com/Aisse-258/bigint-isqrt/blob/f5254b9750841959022461c1353437a07a08f501/test/sqrt-test.js - [ - '54866395443885995655625', - '234235768925' - ], - [ - '82120471531550314555681345949499512621827274120673745141541602816614526075010755373654280259022317599142038423759320355177481886719814621305828811322920076213800348341464996337890625', - '9062034624274524065844376014975805577107171799890766992670739972241112960081909332275390625' - ], - [ - '2068290204957779940494571454815902632050207752627007664813877111611972735314294907791993008455381265730624848057015476004143868408297250386512042711005577373327434315310235583583151773358353534031397385969275475421659036494173765903706963544628565027679444680637920371210258368358706248446698622704138943704561842220533563976838506992543814273403403362954987589637283890281226038798503294069403370486523697009383229578343444337394508531937972775639593763364402389410142290440075517598007930025487176173228232153685095699851764630884360483051570513804913157899314303269924424908606245851172031453725690942288677622973423417902662711606364188470325930406288190754356367655606430407552275285889968860367977288564364154999338284288438279464648663835830140826171534470717958048887869721791862539529444820484648908879364324577951008050851801647916673254009490596379549192296404841454780884358889449367135382779230574781333008561195244620152128505091883408484094800737142399855337799331037607433934520934135669364954550499058123797911762228642423567268540444910163468496805547450495819213412636594319148417857753712526066272727725420886898680432958409892237191284583904066400736417812258327303739879128916456683685232170600928808798462776174857486589598776587550843543720784829419478239563366491666155716208452087857080883906200829769222868347286071365156305396955420561718593130305703074908891135467193627721682044757187980688062367562451981939375400543212890625', - '45478458691536369397924851088318871329614555665525810477032568598360481742967756704524034986984134271202405190906906195123751965012732122548540879928668891416468847696038707003466943811913626146981446753434347552196868717612248915137033581428310504778371173112125038060138252719589122657221314190626986951627417768579641354255445988772645883238873672997347648890137913979299598785628581961589739331483895853398160785485300758458294999124984266041998145956341386549681176624661615465976970855592467853824812945820721933491609237311130118125761849911376495970746282571994312288380577879004620824004760109618074670810797544446334767103935754106103208789391060008291027361311679876439695844637933763721093782805837690830230712890625' - ] -]; - describe('bnSqrt', (): void => { it('fails on < 0 roots', (): void => { expect( @@ -46,7 +24,7 @@ describe('bnSqrt', (): void => { ).toEqual(true); }); - TESTS.forEach(([value, expected], index): void => { + SQRT_TESTS.forEach(([value, expected], index): void => { it(`calcs for test #${index}`, (): void => { expect( bnSqrt(value).eq(new BN(expected)) diff --git a/yarn.lock b/yarn.lock index 0348f100a..e88061eeb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2045,9 +2045,9 @@ __metadata: languageName: node linkType: hard -"@polkadot/dev@npm:^0.67.69": - version: 0.67.69 - resolution: "@polkadot/dev@npm:0.67.69" +"@polkadot/dev@npm:^0.67.73": + version: 0.67.73 + resolution: "@polkadot/dev@npm:0.67.73" dependencies: "@babel/cli": ^7.18.6 "@babel/core": ^7.18.6 @@ -2136,7 +2136,7 @@ __metadata: polkadot-exec-rollup: scripts/polkadot-exec-rollup.mjs polkadot-exec-tsc: scripts/polkadot-exec-tsc.mjs polkadot-exec-webpack: scripts/polkadot-exec-webpack.mjs - checksum: e500a308d445756338ece0c9318cf801b291fa677bb21907337c4e662be7c26821f46aba2a41d1da927777d4745e4b456a82d071f79d47b9b66c57c10ad6a5df + checksum: 01afdfab153b4c86832389fb806cc3b0a338e6125ca6280ffbcad39758a6fcad5005161c21f922788dd4ec8a320ca7b7c7f5862c00c141170c0d7a554caf8ed7 languageName: node linkType: hard @@ -9438,7 +9438,7 @@ resolve@^2.0.0-next.3: resolution: "root-workspace-0b6124@workspace:." dependencies: "@babel/core": ^7.18.6 - "@polkadot/dev": ^0.67.69 + "@polkadot/dev": ^0.67.73 "@types/jest": ^28.1.4 languageName: unknown linkType: soft