Update enum definitions and dependencies * Remove redundant bytes from field definitions * Remove "date-generated" given hand editing * Remove ripple-lib test dependency * Fix linting errors introduced by updated eslint/eslintrc * Ensure STObject.toJSON returns a plain object

This commit is contained in:
Nicholas Dudfield
2016-05-09 18:46:51 +07:00
parent 3680303256
commit bfd022786c
50 changed files with 62 additions and 278 deletions

View File

@@ -1,5 +1,3 @@
'use strict';
const assert = require('assert-diff');
const {Amount} = require('../src/coretypes');

View File

@@ -1,5 +1,3 @@
'use strict';
const assert = require('assert');
const fixtures = require('./fixtures/codec-fixtures.json');
const {decode, encode} = require('../src');

View File

@@ -1,7 +1,5 @@
/* eslint-disable func-style */
'use strict';
const coreTypes = require('../src/coretypes');
const _ = require('lodash');
@@ -157,11 +155,19 @@ function transactionParsingTests() {
}
assert(parser.end());
});
it('can be done with higher level apis', () => {
const parser = makeParser(transaction.binary);
const jsonFromBinary = readJSON(parser);
assert.deepEqual(jsonFromBinary, tx_json);
});
it('readJSON (binary.decode) does not return STObject ', () => {
const parser = makeParser(transaction.binary);
const jsonFromBinary = readJSON(parser);
assert((jsonFromBinary instanceof coreTypes.STObject) === false);
assert(_.isPlainObject(jsonFromBinary));
});
}
function amountParsingTests() {
@@ -322,35 +328,8 @@ function pathSetBinaryTests() {
});
}
function parseLedger4320278() {
let ripple = require('ripple-lib');
if (ripple._DEPRECATED) {
ripple = ripple._DEPRECATED;
}
ripple.Amount.strict_mode = false;
ripple = false;
it(`can parse object`, () => {
this.timeout(30e3);
const json = loadFixture('as-ledger-4320278.json');
json.forEach((e, i) => {
const expected = e.json;
const actual = readJSON(makeParser(e.binary));
actual.index = expected.index;
// const actual = new ripple.SerializedObject(e.binary).to_json();
try {
assert.deepEqual(actual, expected);
} catch (error) {
console.log('error', i, !ripple && error);
}
});
});
}
describe('BinaryParser', function() {
function dataDrivenTests() {
describe.skip('as-ledger-4320278.json', parseLedger4320278);
describe('Amount parsing tests', amountParsingTests);
describe('Field Tests', fieldParsingTests);
describe('Parsing nested objects', nestedObjectTests);

View File

@@ -1,7 +1,5 @@
/* eslint-disable func-style */
'use strict';
const BN = require('bn.js');
const assert = require('assert-diff');
const lib = require('../src/coretypes');
@@ -78,7 +76,7 @@ function UIntTest() {
function parseLedger4320278() {
it(`can parse object`, done => {
it('can parse object', done => {
this.timeout(30e3);
const json = loadFixture('as-ledger-4320278.json');
json.forEach(e => {
@@ -89,7 +87,7 @@ function parseLedger4320278() {
}
function deliverMinTest() {
it(`can serialize DeliverMin`, () => {
it('can serialize DeliverMin', () => {
assert.strictEqual(encode(deliverMinTx), deliverMinTxBinary);
});
}

View File

@@ -1,5 +1,3 @@
'use strict';
const assert = require('assert');
const bytesUtils = require('../src/utils/bytes-utils');
const {slice, compareBytes, parseBytes, bytesToHex} = bytesUtils;

View File

@@ -926,7 +926,7 @@
},
{
"type_name": "Vector256",
"name": "Features",
"name": "Amendments",
"nth_of_type": 3,
"type": 19,
"expected_hex": "0313"

View File

@@ -1,5 +1,3 @@
'use strict';
const assert = require('assert-diff');
const {Hash160, Hash256, Currency, AccountID} = require('../src/coretypes');

View File

@@ -1,5 +1,3 @@
'use strict';
const assert = require('assert');
const {loadFixture} = require('./utils');
const ledgerHashes = require('../src/ledger-hashes');

View File

@@ -1 +1 @@
--reporter spec --slow 500 --compilers js:babel/register
--reporter spec --slow 500 --compilers js:babel-register

View File

@@ -1,5 +1,3 @@
'use strict';
const assert = require('assert-diff');
const {quality, binary: {bytesToHex}} = require('../src/coretypes');

View File

@@ -1,5 +1,3 @@
'use strict';
const assert = require('assert-diff');
const {ShaMap} = require('../src/shamap.js');
const {binary: {serializeObject}, Hash256, HashPrefix}

View File

@@ -1,5 +1,3 @@
'use strict';
const _ = require('lodash');
const assert = require('assert-diff');
const {encodeForSigning, encodeForMultisigning} = require('../src');

View File

@@ -1,5 +1,3 @@
'use strict';
const _ = require('lodash');
const assert = require('assert');
const coreTypes = require('../src/types');

View File

@@ -1,5 +1,3 @@
'use strict';
const assert = require('assert');
const coreTypes = require('../src/coretypes');
/* eslint-disable no-unused-vars */

View File

@@ -1,5 +1,3 @@
'use strict';
const intercept = require('intercept-stdout');
const fs = require('fs');
const fsExtra = require('fs-extra');