Browse Source

Merge pull request #49 from krlosMata/feature/fix-smt-update

fix smt update
master
Jordi Baylina 4 years ago
committed by GitHub
parent
commit
d422471b5b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions
  1. +1
    -1
      src/smt.js
  2. +9
    -0
      test/smtjs.js

+ 1
- 1
src/smt.js

@ -58,10 +58,10 @@ class SMT {
res.newRoot = rtNew;
await this.db.multiDel(dels);
await this.db.multiIns(ins);
await this.db.setRoot(rtNew);
this.root = rtNew;
await this.db.multiDel(dels);
return res;
}

+ 9
- 0
test/smtjs.js

@ -161,4 +161,13 @@ describe("SMT Javascript test", function () {
assert(Fr.eq(tree1.root, tree2.root));
});
it("Should test update with same key-value", async () => {
const tree1 = await smt.newMemEmptyTrie();
await tree1.insert(8,88);
await tree1.update(8,88);
const res = await tree1.db.get(tree1.root);
assert.notEqual(res, undefined);
});
});

Loading…
Cancel
Save