Skip to content

Commit 5042403

Browse files
committed
chore: add options tests
1 parent 11453fe commit 5042403

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

infrastructure/w3id/tests/logs/log.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { base58btc } from "multiformats/bases/base58";
1818
import falso from "@ngneat/falso";
1919
import {
2020
BadNextKeySpecifiedError,
21+
BadOptionsSpecifiedError,
2122
BadSignatureError,
2223
MalformedHashChainError,
2324
MalformedIndexChainError,
@@ -97,6 +98,17 @@ function createSigner(keyPair: nacl.SignKeyPair): Signer {
9798
}
9899

99100
describe("LogManager", async () => {
101+
test("GenesisEvent: [Throw at Bad Options]", async () => {
102+
const nextKeyHash = await hash(uint8ArrayToHex(currNextKey.publicKey));
103+
const signer = createSigner(keyPair);
104+
const logEvent = logManager.createLogEvent({
105+
nextKeySigner: signer,
106+
nextKeyHashes: [nextKeyHash],
107+
signer,
108+
});
109+
await expect(logEvent).rejects.toThrow(BadOptionsSpecifiedError);
110+
});
111+
100112
test("GenesisEvent: [Creates Entry]", async () => {
101113
const nextKeyHash = await hash(uint8ArrayToHex(currNextKey.publicKey));
102114
const signer = createSigner(keyPair);
@@ -108,6 +120,20 @@ describe("LogManager", async () => {
108120
expectTypeOf(logEvent).toMatchObjectType<LogEvent>();
109121
});
110122

123+
test("KeyRotation: [Throw At Bad Options]", async () => {
124+
const nextKeyPair = nacl.sign.keyPair();
125+
const nextKeyHash = await hash(uint8ArrayToHex(nextKeyPair.publicKey));
126+
127+
const signer = createSigner(nextKeyPair);
128+
const logEvent = logManager.createLogEvent({
129+
nextKeyHashes: [nextKeyHash],
130+
signer,
131+
id: `@{falso.randUuid()}`,
132+
});
133+
134+
await expect(logEvent).rejects.toThrow(BadOptionsSpecifiedError);
135+
});
136+
111137
test("KeyRotation: [Error At Wrong Next Key]", async () => {
112138
const nextKeyPair = nacl.sign.keyPair();
113139
const nextKeyHash = await hash(uint8ArrayToHex(nextKeyPair.publicKey));

0 commit comments

Comments
 (0)