From b5beeb66684773ee7d1c18858ee7cbbf99188eec Mon Sep 17 00:00:00 2001 From: Greg Weisbrod Date: Sun, 7 Nov 2021 20:47:55 -0500 Subject: [PATCH] migrate ripple-address-codec tests back to javascript for now - jest and mocha cannot be used in the same typescript project due to type name conflicts --- package-lock.json | 21 ------------------- package.json | 1 - packages/ripple-address-codec/.travis.yml | 9 -------- .../src/{index.test.ts => index.test.js} | 12 +++++------ .../src/{utils.test.ts => utils.test.js} | 2 +- .../{xrp-codec.test.ts => xrp-codec.test.js} | 8 +++---- 6 files changed, 11 insertions(+), 42 deletions(-) delete mode 100644 packages/ripple-address-codec/.travis.yml rename packages/ripple-address-codec/src/{index.test.ts => index.test.js} (96%) rename packages/ripple-address-codec/src/{utils.test.ts => utils.test.js} (96%) rename packages/ripple-address-codec/src/{xrp-codec.test.ts => xrp-codec.test.js} (97%) diff --git a/package-lock.json b/package-lock.json index cd562bd8..b11f1554 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,6 @@ }, "devDependencies": { "@types/chai": "^4.2.21", - "@types/jest": "^26.0.7", "@types/lodash": "^4.14.136", "@types/mocha": "^9.0.0", "@types/node": "^16.4.3", @@ -3076,16 +3075,6 @@ "@types/istanbul-lib-report": "*" } }, - "node_modules/@types/jest": { - "version": "26.0.24", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-26.0.24.tgz", - "integrity": "sha512-E/X5Vib8BWqZNRlDxj9vYXhsDwPYbPINqKF9BsnSoon4RQ0D9moEuLD8txgyypFLH7J4+Lho9Nr/c8H0Fi+17w==", - "dev": true, - "dependencies": { - "jest-diff": "^26.0.0", - "pretty-format": "^26.0.0" - } - }, "node_modules/@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", @@ -20593,16 +20582,6 @@ "@types/istanbul-lib-report": "*" } }, - "@types/jest": { - "version": "26.0.24", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-26.0.24.tgz", - "integrity": "sha512-E/X5Vib8BWqZNRlDxj9vYXhsDwPYbPINqKF9BsnSoon4RQ0D9moEuLD8txgyypFLH7J4+Lho9Nr/c8H0Fi+17w==", - "dev": true, - "requires": { - "jest-diff": "^26.0.0", - "pretty-format": "^26.0.0" - } - }, "@types/json-schema": { "version": "7.0.9", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", diff --git a/package.json b/package.json index 7d1793f0..3da04749 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ }, "devDependencies": { "@types/chai": "^4.2.21", - "@types/jest": "^26.0.7", "@types/lodash": "^4.14.136", "@types/mocha": "^9.0.0", "@types/node": "^16.4.3", diff --git a/packages/ripple-address-codec/.travis.yml b/packages/ripple-address-codec/.travis.yml deleted file mode 100644 index d99cdfc8..00000000 --- a/packages/ripple-address-codec/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: node_js -node_js: -- 10 -- 12 -- 13 -script: -- npm run compile -- npm test -- npm run lint diff --git a/packages/ripple-address-codec/src/index.test.ts b/packages/ripple-address-codec/src/index.test.js similarity index 96% rename from packages/ripple-address-codec/src/index.test.ts rename to packages/ripple-address-codec/src/index.test.js index 5203c498..cfab6eaf 100644 --- a/packages/ripple-address-codec/src/index.test.ts +++ b/packages/ripple-address-codec/src/index.test.js @@ -1,9 +1,9 @@ -import { +const { classicAddressToXAddress, xAddressToClassicAddress, isValidXAddress, encodeXAddress -} from './index' +} = require('./index') const testCases = [ [ @@ -146,9 +146,9 @@ const testCases = [ for (const i in testCases) { const testCase = testCases[i] - const classicAddress = testCase[0] as string - const tag = testCase[1] !== false ? testCase[1] as number : false - const xAddress = isTestAddress ? testCase[3] as string : testCase[2] as string + const classicAddress = testCase[0] + const tag = testCase[1] !== false ? testCase[1] : false + const xAddress = isTestAddress ? testCase[3] : testCase[2] test(`Converts ${classicAddress}${tag ? ':' + tag : ''} to ${xAddress}${network}`, () => { expect(classicAddressToXAddress(classicAddress, tag, isTestAddress)).toBe(xAddress) const myClassicAddress = xAddressToClassicAddress(xAddress) @@ -191,7 +191,7 @@ const testCases = [ highAndLowAccounts.forEach(accountId => { [false, 0, 1, MAX_32_BIT_UNSIGNED_INT].forEach(t => { - const tag = (t as number | false) + const tag = (t | false) const xAddress = encodeXAddress(accountId, tag, isTestAddress) test(`Encoding ${accountId.toString('hex')}${tag ? ':' + tag : ''} to ${xAddress} has expected length`, () => { expect(xAddress.length).toBe(47) diff --git a/packages/ripple-address-codec/src/utils.test.ts b/packages/ripple-address-codec/src/utils.test.js similarity index 96% rename from packages/ripple-address-codec/src/utils.test.ts rename to packages/ripple-address-codec/src/utils.test.js index 54d4653f..f14e9084 100644 --- a/packages/ripple-address-codec/src/utils.test.ts +++ b/packages/ripple-address-codec/src/utils.test.js @@ -1,4 +1,4 @@ -import {seqEqual, concatArgs} from './utils' +const {seqEqual, concatArgs} = require('./utils') test('two sequences are equal', () => { expect(seqEqual([1, 2, 3], [1, 2, 3])).toBe(true) diff --git a/packages/ripple-address-codec/src/xrp-codec.test.ts b/packages/ripple-address-codec/src/xrp-codec.test.js similarity index 97% rename from packages/ripple-address-codec/src/xrp-codec.test.ts rename to packages/ripple-address-codec/src/xrp-codec.test.js index 61e121ae..6b226dc4 100644 --- a/packages/ripple-address-codec/src/xrp-codec.test.ts +++ b/packages/ripple-address-codec/src/xrp-codec.test.js @@ -1,10 +1,10 @@ -import * as api from './xrp-codec' +const api = require('./xrp-codec') -function toHex(bytes: Buffer) { +function toHex(bytes) { return Buffer.from(bytes).toString('hex').toUpperCase() } -function toBytes(hex: string) { +function toBytes(hex) { return Buffer.from(hex, 'hex') } @@ -16,7 +16,7 @@ function toBytes(hex: string) { * @param base58 Base58-encoded string to decode * @param hex Hexadecimal representation of expected decoded data */ -function makeEncodeDecodeTest(encoder: Function, decoder: Function, base58: string, hex: string) { +function makeEncodeDecodeTest(encoder, decoder, base58, hex) { test(`can translate between ${hex} and ${base58}`, function() { const actual = encoder(toBytes(hex)) expect(actual).toBe(base58)