Decode binary ledger header data

This commit is contained in:
wilsonianb
2017-08-16 15:29:23 -05:00
parent de6e86a3ea
commit d528331a37
3 changed files with 45 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
const assert = require('assert');
const fixtures = require('./fixtures/codec-fixtures.json');
const {decode, encode} = require('../src');
const {decode, encode, decodeLedgerData} = require('../src');
function json(object) {
return JSON.stringify(object);
@@ -24,4 +24,14 @@ describe('ripple-binary-codec', function() {
}
makeSuite('transactions', fixtures.transactions);
makeSuite('accountState', fixtures.accountState);
describe('ledgerData', function() {
fixtures.ledgerData.forEach((t, test_n) => {
it(`ledgerData[${test_n}] can decode ${t.binary} to ${json(t.json)}`,
() => {
const decoded = decodeLedgerData(t.binary);
assert.deepEqual(t.json, decoded);
});
});
})
});

View File

@@ -4448,5 +4448,19 @@
"Flags": 0,
"Sequence": 62
}
}],
"ledgerData": [{
"binary": "01E91435016340767BF1C4A3EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F873B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D521276CDE21276CE60A00",
"json": {
"account_hash": "3B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D5",
"close_flags": 0,
"close_time": 556231910,
"close_time_resolution": 10,
"ledger_index": 32052277,
"parent_close_time": 556231902,
"parent_hash": "EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6",
"total_coins": "99994494362043555",
"transaction_hash": "DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F87"
}
}]
}