Files
xahau.js/packages/ripple-binary-codec/test/ledger.test.js
Nathan Nichols b14f055c6c Linter config lints test directory (#99)
Modify eslint config to lint ./test/
2020-08-21 17:04:14 -05:00

30 lines
959 B
JavaScript

const { loadFixture } = require("./utils");
const {
transactionTreeHash,
ledgerHash,
accountStateHash,
} = require("../dist/ledger-hashes");
describe("Ledger Hashes", function () {
function testFactory(ledgerFixture) {
describe(`can calculate hashes for ${ledgerFixture}`, function () {
const ledger = loadFixture(ledgerFixture);
test("computes correct account state hash", function () {
expect(accountStateHash(ledger.accountState).toHex()).toBe(
ledger.account_hash
);
});
test("computes correct transaction tree hash", function () {
expect(transactionTreeHash(ledger.transactions).toHex()).toBe(
ledger.transaction_hash
);
});
test("computes correct ledger header hash", function () {
expect(ledgerHash(ledger).toHex()).toBe(ledger.hash);
});
});
}
testFactory("ledger-full-40000.json");
testFactory("ledger-full-38129.json");
});