mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
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:
@@ -1,9 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 10
|
||||
- 12
|
||||
- 13
|
||||
script:
|
||||
- npm run compile
|
||||
- npm test
|
||||
- npm run lint
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user