Initial import

This commit is contained in:
Nicholas Dudfield
2015-09-30 16:28:01 +07:00
parent 7fe8cd541a
commit 65987a83fd
7 changed files with 4626 additions and 0 deletions

64
packages/ripple-binary-codec/.gitignore vendored Normal file
View File

@@ -0,0 +1,64 @@
# .gitignore
# Ignore vim swap files.
*.swp
# Ignore SCons support files.
.sconsign.dblite
# Ignore python compiled files.
*.pyc
# Ignore Macintosh Desktop Services Store files.
.DS_Store
# Ignore backup/temps
*~
# Ignore object files.
*.o
build/
distrib/
tags
bin/rippled
Debug/*.*
Release/*.*
# Ignore locally installed node_modules
node_modules
!test/node_modules
# Ignore tmp directory.
tmp
# Ignore database directory.
db/*.db
db/*.db-*
# Ignore customized configs
rippled.cfg
validators.txt
test/config.js
# Ignore coverage files
/lib-cov
/src-cov
/coverage.html
/coverage
# Ignore IntelliJ files
.idea
# Ignore npm-debug
npm-debug.log
# Ignore dist folder, build for bower
dist/
# Ignore flow output directory
out/
# Ignore perf test cache
scripts/cache
eslintrc

View File

@@ -0,0 +1,64 @@
{
"name": "ripple-binary-codec",
"version": "0.0.1",
"description": "ripple binary codec",
"files": [
"distrib/npm/*",
"bin/*",
"build/*",
"test/*",
"Gulpfile.js"
],
"main": "distrib/npm/",
"directories": {
"test": "test"
},
"dependencies": {
"babel-runtime": "^5.8.20",
"bn.js": "^3.1.1",
"brorand": "^1.0.5",
"elliptic": "^5.1.0",
"hash.js": "^1.0.3",
"ripple-address-codec": "^1.6.0"
},
"devDependencies": {
"assert-diff": "^1.0.1",
"babel": "^5.8.20",
"babel-core": "^5.8.20",
"babel-eslint": "^4.0.5",
"babel-loader": "^5.3.2",
"coveralls": "~2.10.0",
"eslint": "^1.2.1",
"eventemitter2": "^0.4.14",
"istanbul": "~0.3.5",
"lodash": "^3.10.0",
"map-stream": "~0.1.0",
"mocha": "~2.1.0",
"nock": "^0.34.1",
"ripple-lib": "^0.12.4",
"webpack": "~1.5.3",
"yargs": "~1.3.1"
},
"scripts": {
"build": "gulp",
"compile": "babel --optional runtime -d distrib/npm/ src/",
"compile-with-source-maps": "babel --optional runtime -s -t -d distrib/npm/ src/",
"prepublish": "npm test && npm run lint && npm run compile",
"test": "istanbul test _mocha",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"lint": "if ! [ -f eslintrc ]; then curl -o eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/es6/eslintrc'; echo 'parser: babel-eslint' >> eslintrc; fi; eslint -c eslintrc src/*.js test/*.js"
},
"repository": {
"type": "git",
"url": "git://github.com/ripple/ripple-binary-codec.git"
},
"engines": {
"node": ">=0.12.0"
},
"bugs": {
"url": "https://github.com/ripple/ripple-binary-codec/issues"
},
"homepage": "https://github.com/ripple/ripple-binary-codec#readme",
"license": "ISC",
"readmeFilename": "README.md"
}

View File

@@ -0,0 +1 @@
# ripple-binary-codec

View File

@@ -0,0 +1,15 @@
'use strict';
const assert = require('assert');
const coreTypes = require('@niq/ripple-core-types');
const {binary: {bytesToHex, binaryToJSON, serializeObject}} = coreTypes;
exports.binaryToJSON = function(binary) {
assert(typeof binary === 'string');
return binaryToJSON(binary);
};
exports.jsonToBinary = function (json) {
assert(typeof json === 'object');
return bytesToHex(serializeObject(json));
};

View File

@@ -0,0 +1,29 @@
'use strict';
const assert = require('assert');
const fixtures = require('./fixtures/codec-fixtures.json');
const {binaryToJSON, jsonToBinary} = require('../src');
function json(object) {
return JSON.stringify(object);
}
describe('ripple-binary-codec', function() {
function makeSuite(name, entries) {
describe(name, function() {
entries.forEach((t, test_n) => {
it(`${name}[${test_n}] can encode ${json(t.json)} to ${t.binary}`,
() => {
assert.equal(t.binary, jsonToBinary(t.json));
});
it(`${name}[${test_n}] can decode ${t.binary} to ${json(t.json)}`,
() => {
const decoded = binaryToJSON(t.binary);
assert.deepEqual(t.json, decoded);
});
});
});
}
makeSuite('transactions', fixtures.transactions);
makeSuite('accountState', fixtures.accountState);
});

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
--reporter spec --timeout 5000 --slow 500 --compilers js:babel/register