mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-21 20:55:48 +00:00
Initial import
This commit is contained in:
29
packages/ripple-binary-codec/test/binary-json-test.js
Normal file
29
packages/ripple-binary-codec/test/binary-json-test.js
Normal 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);
|
||||
});
|
||||
Reference in New Issue
Block a user