-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { expect, test, describe } from "bun:test"; | ||
import { createRoomCreateEvent, roomCreateEvent } from "../m.room.create"; | ||
import { signEvent } from "../../signEvent"; | ||
import { generateId } from "../../authentication"; | ||
import { createSignedEvent } from "./createSignedEvent"; | ||
import { generateKeyPairsFromString } from "../../keys"; | ||
|
||
describe("makeSignedEvent", () => { | ||
test("it should return the same payload, following create event > sign > generate id", async () => { | ||
const signature = await generateKeyPairsFromString( | ||
"ed25519 a_XRhW YjbSyfqQeGto+OFswt+XwtJUUooHXH5w+czSgawN63U", | ||
); | ||
|
||
const event = roomCreateEvent({ | ||
roomId: "!uTqsSSWabZzthsSCNf:hs1", | ||
sender: "@admin:hs1", | ||
ts: 1733069433734, | ||
}); | ||
const signed = await signEvent(event, signature); | ||
const id = generateId(signed); | ||
|
||
const makeSignedEvent = createSignedEvent(signature); | ||
const result = await createRoomCreateEvent(makeSignedEvent)({ | ||
roomId: "!uTqsSSWabZzthsSCNf:hs1", | ||
sender: "@admin:hs1", | ||
ts: 1733069433734, | ||
}); | ||
|
||
expect({ | ||
event: signed, | ||
_id: id, | ||
// @ts-ignore | ||
}).toStrictEqual(result); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { expect, test } from "bun:test"; | ||
import { createRoom } from "./createRoom"; | ||
import { createSignedEvent } from "../events/utils/createSignedEvent"; | ||
import { generateKeyPairsFromString } from "../keys"; | ||
|
||
test("createRoom", async () => { | ||
const signature = await generateKeyPairsFromString( | ||
"ed25519 a_XRhW YjbSyfqQeGto+OFswt+XwtJUUooHXH5w+czSgawN63U", | ||
); | ||
|
||
const makeSignedEvent = createSignedEvent(signature); | ||
|
||
const { roomId, events } = await createRoom( | ||
"@sender:hs1", | ||
"username", | ||
makeSignedEvent, | ||
"!roomId:hs1", | ||
); | ||
|
||
expect(events).toBeArrayOfSize(6); | ||
}); |