Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Amxx committed Mar 4, 2024
1 parent 7ee1181 commit 6ff294d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
39 changes: 22 additions & 17 deletions src/simple.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ testProp('reject out of bounds value index', [tree], (t, [tree]) => {
});

// We need at least 2 leaves for internal node hashing to come into play
testProp('reject loading dump with wrong node hash', [ fc.array(leaf, { minLength: 2 }) ] , (t, leaves) => {
testProp('reject loading dump with wrong node hash', [fc.array(leaf, { minLength: 2 })], (t, leaves) => {
const dump = SimpleMerkleTree.of(leaves, { nodeHash: reverseNodeHash }).dump();
t.throws(() => SimpleMerkleTree.load(dump, otherNodeHash), new InvariantError('Merkle tree is invalid'));
});
Expand All @@ -156,22 +156,27 @@ test('reject unrecognized tree dump', t => {

test('reject malformed tree dump', t => {
t.throws(
() => SimpleMerkleTree.load({
format: 'simple-v1',
tree: [zero],
values: [
{
value: '0x0000000000000000000000000000000000000000000000000000000000000001',
treeIndex: 0,
},
],
}),
new InvariantError('Merkle tree does not contain the expected value')
() =>
SimpleMerkleTree.load({
format: 'simple-v1',
tree: [zero],
values: [
{
value: '0x0000000000000000000000000000000000000000000000000000000000000001',
treeIndex: 0,
},
],
}),
new InvariantError('Merkle tree does not contain the expected value'),
);

t.throws(() => SimpleMerkleTree.load({
format: 'simple-v1',
tree: [zero, zero, zero],
values: [{ value: zero, treeIndex: 2 }],
}), new InvariantError('Merkle tree is invalid'));
t.throws(
() =>
SimpleMerkleTree.load({
format: 'simple-v1',
tree: [zero, zero, zero],
values: [{ value: zero, treeIndex: 2 }],
}),
new InvariantError('Merkle tree is invalid'),
);
});
26 changes: 14 additions & 12 deletions src/standard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,24 @@ test('reject unrecognized tree dump', t => {

test('reject malformed tree dump', t => {
t.throws(
() => StandardMerkleTree.load({
format: 'standard-v1',
tree: [zero],
values: [{ value: ['0'], treeIndex: 0 }],
leafEncoding: ['uint256'],
}),
() =>
StandardMerkleTree.load({
format: 'standard-v1',
tree: [zero],
values: [{ value: ['0'], treeIndex: 0 }],
leafEncoding: ['uint256'],
}),
new InvariantError('Merkle tree does not contain the expected value'),
);

t.throws(
() => StandardMerkleTree.load({
format: 'standard-v1',
tree: [zero, zero, keccak256(keccak256(zero))],
values: [{ value: ['0'], treeIndex: 2 }],
leafEncoding: ['uint256'],
}),
() =>
StandardMerkleTree.load({
format: 'standard-v1',
tree: [zero, zero, keccak256(keccak256(zero))],
values: [{ value: ['0'], treeIndex: 2 }],
leafEncoding: ['uint256'],
}),
new InvariantError('Merkle tree is invalid'),
);
});

0 comments on commit 6ff294d

Please sign in to comment.