Skip to content

Commit 697fb37

Browse files
authored
Test loading historical dumps (#40)
1 parent 4fa27de commit 697fb37

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

.mocharc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extension": ["ts"],
3-
"spec": "src/**/*.test.ts",
3+
"spec": "{src,test}/**/*.test.ts",
44
"require": "ts-node/register",
55
"timeout": 60000
66
}

test/dumps.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import assert from 'assert/strict';
2+
import fs from 'fs';
3+
import path from 'path';
4+
import { StandardMerkleTree } from '../src/standard';
5+
6+
const DUMPS_DIR = 'test/dumps/';
7+
8+
describe('load dumped trees', () => {
9+
for (const file of fs.readdirSync(DUMPS_DIR).map(filename => path.join(DUMPS_DIR, filename))) {
10+
it(file, function () {
11+
const dump = JSON.parse(fs.readFileSync(file, 'utf-8'));
12+
const tree = StandardMerkleTree.load(dump);
13+
tree.validate();
14+
});
15+
}
16+
});

test/dumps/standard-v1.1_0_6.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"format":"standard-v1","tree":["0x23be0977360f08bb0bd7f709a7d543d2cd779c79c66d74e0441919871647de2b","0x8f7234e8cfe39c08ca84a3a3e3274f574af26fd15165fe29e09cbab742daccd9","0x7b0c6cd04b82bfc0e250030a5d2690c52585e0cc6a4f3bc7909d7723b0236ece","0x03707d7802a71ca56a8ad8028da98c4f1dbec55b31b4a25d536b5309cc20eda9","0xfa914d99a18dc32d9725b3ef1c50426deb40ec8d0885dac8edcc5bfd6d030016","0xc62a8cfa41edc0ef6f6ae27a2985b7d39c7fea770787d7e104696c6e81f64848","0x9a4f64e953595df82d1b4f570d34c4f4f0cfaf729a61e9d60e83e579e1aa283e","0xeba909cf4bb90c6922771d7f126ad0fd11dfde93f3937a196274e1ac20fd2f5b","0x9cf5a63718145ba968a01c1d557020181c5b252f665cf7386d370eddb176517b","0x19ba6c6333e0e9a15bf67523e0676e2f23eb8e574092552d5e888c64a4bb3681","0x9c15a6a0eaeed500fd9eed4cbeab71f797cefcc67bfd46683e4d2e6ff7f06d1c"],"values":[{"value":["a"],"treeIndex":10},{"value":["b"],"treeIndex":9},{"value":["c"],"treeIndex":8},{"value":["d"],"treeIndex":7},{"value":["e"],"treeIndex":6},{"value":["f"],"treeIndex":5}],"leafEncoding":["string"]}

0 commit comments

Comments
 (0)