Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raykyri committed Aug 15, 2024
1 parent f3b42aa commit 2d042a4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
POSTGRES_USER: commonwealth
POSTGRES_DB: common_test
POSTGRES_PASSWORD: edgeware
POSTGRES_FEDERATION_DB_URL: postgresql://commonwealth:edgeware@localhost/common_test
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
Expand Down Expand Up @@ -99,6 +100,7 @@ jobs:
POSTGRES_USER: commonwealth
POSTGRES_DB: common_test
POSTGRES_PASSWORD: edgeware
POSTGRES_FEDERATION_DB_URL: postgresql://commonwealth:edgeware@localhost/common_test
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
Expand Down Expand Up @@ -158,6 +160,7 @@ jobs:
POSTGRES_USER: commonwealth
POSTGRES_DB: common_test
POSTGRES_PASSWORD: edgeware
POSTGRES_FEDERATION_DB_URL: postgresql://commonwealth:edgeware@localhost/common_test
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
Expand Down Expand Up @@ -274,6 +277,7 @@ jobs:
POSTGRES_USER: commonwealth
POSTGRES_DB: common_test
POSTGRES_PASSWORD: edgeware
POSTGRES_FEDERATION_DB_URL: postgresql://commonwealth:edgeware@localhost/common_test
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
Expand Down Expand Up @@ -350,6 +354,7 @@ jobs:
POSTGRES_USER: commonwealth
POSTGRES_DB: common_test
POSTGRES_PASSWORD: edgeware
POSTGRES_FEDERATION_DB_URL: postgresql://commonwealth:edgeware@localhost/common_test
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
Expand Down Expand Up @@ -398,6 +403,7 @@ jobs:
POSTGRES_USER: commonwealth
POSTGRES_DB: common_test
POSTGRES_PASSWORD: edgeware
POSTGRES_FEDERATION_DB_URL: postgresql://commonwealth:edgeware@localhost/common_test
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
Expand Down Expand Up @@ -481,5 +487,3 @@ jobs:
with:
parallel-finished: true
carryforward: "cosmos-devnet-test-coverage"


14 changes: 8 additions & 6 deletions libs/shared/src/canvas/runtime/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ export const contract = {
});
},
// TODO: not implemented (packages/commonwealth/server/routes/threads/update_thread_handler.ts)
async updateThread(db, { thread_id, title, body, link, topic }, { did, id, timestamp }) {
async updateThread(db, { thread_id, title, body, link, topic }, { did, timestamp }) {
const t = await db.get("threads", thread_id);
if (!t || !t.id) throw new Error("invalid thread");
if (t.author !== did) throw new Error("invalid thread");
db.set('threads', { id: t.id as string, author: t.author, community: t.community, title, body, link, topic, updated_at: timestamp });
},
async deleteThread(db, { thread_id }, { did, id }) {
const t = await db.get("threads", thread_id);
if (!t || !t.id) throw new Error("invalid thread");
if (t.author !== did) throw new Error("invalid thread");
db.delete("threads", t.id as string);
},
async comment(db, { thread_id, body, parent_comment_id }, { did, id, timestamp }) {
Expand All @@ -84,9 +86,9 @@ export const contract = {
async deleteComment(db, { comment_id }, { did, id }) {
const c = await db.get("comments", comment_id);
if (!c || !c.id) throw new Error("invalid comment");
db.delete("comments", c.id);
db.delete("comments", c.id as string);
},
async reactThread(db, { thread_id, value }, { did, id, timestamp }) {
async reactThread(db, { thread_id, value }, { did, timestamp }) {
if (value !== 'like' && value !== 'dislike') {
throw new Error('Invalid reaction');
}
Expand All @@ -98,7 +100,7 @@ export const contract = {
updated_at: timestamp,
});
},
async unreactThread(db, { thread_id, value }, { did, id, timestamp }) {
async unreactThread(db, { thread_id }, { did, timestamp }) {
db.set("thread_reactions", {
id: `${thread_id}/${did}`,
author: did,
Expand All @@ -107,7 +109,7 @@ export const contract = {
updated_at: timestamp
});
},
async reactComment(db, { comment_id, value }, { did, id, timestamp }) {
async reactComment(db, { comment_id, value }, { did, timestamp }) {
if (value !== 'like' && value !== 'dislike') {
throw new Error('Invalid reaction');
}
Expand All @@ -119,7 +121,7 @@ export const contract = {
updated_at: timestamp,
});
},
async unreactComment(db, { comment_id, value }, { did, id, timestamp }) {
async unreactComment(db, { comment_id }, { did, timestamp }) {
db.set("comment_reactions", {
id: `${comment_id}/${did}`,
author: did,
Expand Down
14 changes: 6 additions & 8 deletions libs/shared/src/canvas/runtime/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ export const CANVAS_TOPIC = topic;

export const startCanvasNode = async () => {
console.log('canvas: starting');

const path =
process.env.POSTGRES_FEDERATION_DB_URL ??
'postgresql://commonwealth:edgeware@localhost/federation';
const app = await Canvas.initialize({
topic,
path:
process.env.DATABASE_URL_CANVAS ??
'postgresql://commonwealth:edgeware@localhost/canvas',
path,
contract,
signers: getSessionSigners(),
bootstrapList: [], // TODO
bootstrapList: [], // TODO: app.libp2p.start()
});

// TODO
// app.libp2p.start()

return app;
};

Expand Down

0 comments on commit 2d042a4

Please sign in to comment.