Skip to content

Commit

Permalink
test: finalize unit test refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
devceline committed Dec 4, 2023
1 parent 4985f12 commit 9b5ee28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 2 additions & 5 deletions misc/identity-keys/src/identity-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ export class IdentityKeys implements IIdentityKeys {

const cacaoPayload = {
aud: encodeEd25519Key(pubKeyHex),
iss: composeDidPkh(accountId),
statement,
domain,
iss: composeDidPkh(accountId),
nonce: generateRandomBytes32(),

iat: new Date().toISOString(),
version: "1",
resources: [
Expand Down Expand Up @@ -129,10 +128,8 @@ export class IdentityKeys implements IIdentityKeys {
},
}

console.log(cacao)

try {
await axios.post(url, cacao);
await axios.post(url, { cacao });
} catch (e) {

throw new Error(`Failed to register on keyserver: ${e}`);
Expand Down
8 changes: 5 additions & 3 deletions misc/identity-keys/test/identity-keys.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@ describe("@walletconnect/identity-keys", () => {
// rejectedWith & rejected are not supported on this version of chai
let failMessage = "";

const signature = await wallet.signMessage("otherMessage");
await identityKeys
.registerIdentity({
registerParams,
signature: "badSignature",
signature,
})
.catch((err) => (failMessage = err.message));

expect(failMessage).eq(
`Failed to register on keyserver: AxiosError: Request failed with status code 400`,
expect(failMessage).match(
new RegExp(`Provided an invalid signature. Signature ${signature} by account
${accountId} is not a valid signature for message .*`),
);

const keys = identityKeys.identityKeys.getAll();
Expand Down

0 comments on commit 9b5ee28

Please sign in to comment.