Skip to content

Commit

Permalink
Merge pull request iden3#49 from krlosMata/feature/fix-smt-update
Browse files Browse the repository at this point in the history
fix smt update
  • Loading branch information
jbaylina authored Aug 31, 2020
2 parents 01da5f9 + 7e93b3f commit d422471
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/smt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions test/smtjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit d422471

Please sign in to comment.