Skip to content

Commit

Permalink
feat: fix all testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
anhnd350309 committed Jan 12, 2025
1 parent dffdb00 commit 50b42db
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/node/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = "0.4.4";
export const VERSION = "0.5.0";
5 changes: 4 additions & 1 deletion packages/object/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ export class DRPObject implements IDRPObject {
?.split("\n")[2]
?.trim()
.split(" ")[1];
if (callerName?.startsWith("DRPObject.resolveConflicts")) {
return Reflect.apply(applyTarget, thisArg, args);
}
if (!callerName?.startsWith("Proxy."))
obj.callFn(
fullPropKey,
Expand Down Expand Up @@ -285,7 +288,7 @@ export class DRPObject implements IDRPObject {

// check if the given peer has write permission
private _checkWriterPermission(peerId: string): boolean {
return this.acl ? (this.acl as IACL).query_isAdmin(peerId) : true;
return this.acl ? (this.acl as IACL).query_isWriter(peerId) : true;
}

// apply the operation to the DRP
Expand Down
4 changes: 2 additions & 2 deletions packages/object/tests/hashgraph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe("HashGraph for AddWinSet tests", () => {
const linearOps = obj1.hashGraph.linearizeOperations();
const expectedOps: Operation[] = [
{ type: "add", value: 1, vertexType: "drp" },
{ type: "add", value: 1, vertexType: "drp" },
{ type: "remove", value: 1, vertexType: "drp" },
];
expect(linearOps).toEqual(expectedOps);
});
Expand Down Expand Up @@ -743,7 +743,7 @@ describe("Writer permission tests", () => {

obj2.merge(obj1.hashGraph.getAllVertices());
expect(drp2.query_contains(1)).toBe(true);
expect(acl2.query_isAdmin("peer2")).toBe(true);
expect(acl2.query_isWriter("peer2")).toBe(true);

drp2.add(4);
obj1.merge(obj2.hashGraph.getAllVertices());
Expand Down
28 changes: 14 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 50b42db

Please sign in to comment.