ledger.test.js 948 B

1234567891011121314151617181920212223242526272829
  1. const { loadFixture } = require('./utils')
  2. const {
  3. transactionTreeHash,
  4. ledgerHash,
  5. accountStateHash,
  6. } = require('../dist/ledger-hashes')
  7. describe('Ledger Hashes', function () {
  8. function testFactory(ledgerFixture) {
  9. describe(`can calculate hashes for ${ledgerFixture}`, function () {
  10. const ledger = loadFixture(ledgerFixture)
  11. test('computes correct account state hash', function () {
  12. expect(accountStateHash(ledger.accountState).toHex()).toBe(
  13. ledger.account_hash,
  14. )
  15. })
  16. test('computes correct transaction tree hash', function () {
  17. expect(transactionTreeHash(ledger.transactions).toHex()).toBe(
  18. ledger.transaction_hash,
  19. )
  20. })
  21. test('computes correct ledger header hash', function () {
  22. expect(ledgerHash(ledger).toHex()).toBe(ledger.hash)
  23. })
  24. })
  25. }
  26. testFactory('ledger-full-40000.json')
  27. testFactory('ledger-full-38129.json')
  28. })