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

This commit is contained in:
Greg Weisbrod
2021-11-07 20:47:55 -05:00
parent 9f19d771d2
commit b5beeb6668
6 changed files with 11 additions and 42 deletions

21
package-lock.json generated
View File

@@ -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",

View File

@@ -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",

View File

@@ -1,9 +0,0 @@
language: node_js
node_js:
- 10
- 12
- 13
script:
- npm run compile
- npm test
- npm run lint

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)