Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gyuguen committed Mar 18, 2024
1 parent 7c726c7 commit 43ff233
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
};
9 changes: 4 additions & 5 deletions src/__tests__/group-signing-panacea-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { v4 as uuidv4 } from "uuid";
import { TextEncoder } from "util";
import { Secp256k1HdWallet } from "@cosmjs/amino";
import assert from "assert";
import { panacead } from "../utils/test-utils";
import {
panaceaWalletOpts,
Expand Down Expand Up @@ -150,10 +149,10 @@ describe("GroupSigningPanaceaClient", () => {
const record = await client
.getPanaceaClient()
.getRecord(ownerAddress, topicName, 0);
assert(record);
expect(record.writerAddress).toEqual(writerAddress);
expect(record.key).toEqual(key);
expect(record.value).toEqual(value);
expect(record).toBeTruthy();
expect(record!.writerAddress).toEqual(writerAddress);
expect(record!.key).toEqual(key);
expect(record!.value).toEqual(value);

client.disconnect();
});
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/panacea-client.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PanaceaClient } from "../client/panacea-client";
import { panacead } from "../utils/test-utils";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { panaceaWalletOpts } from "../client/signing-panacea-client";
import { PanaceaClient } from '../client';
import { panacead } from '../utils/test-utils';
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
import { panaceaWalletOpts } from '../client';

describe("Panacea client", () => {
it("connect", async () => {
Expand Down
26 changes: 23 additions & 3 deletions src/__tests__/signing-panacea-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { panacead } from "../utils/test-utils";
import {
panaceaWalletOpts,
SigningPanaceaClient,
} from "../client/signing-panacea-client";
} from '../client';
import { v4 } from "uuid";
import { PanaceaClient } from "../client/panacea-client";
import { PanaceaClient } from '../client';
import { Secp256k1 } from "../crypto";
import { DIDDocument } from "../proto/panacea/did/v2/did";
import { DidUtil } from "../did";
Expand Down Expand Up @@ -46,6 +46,7 @@ describe("", () => {
});

it("All aol test", async () => {
console.log(`create topic. ownerAddress(${ownerAddress}), topicName(${topicName})`);
const createTopicReq = {
ownerAddress: ownerAddress,
topicName: topicName,
Expand All @@ -65,7 +66,9 @@ describe("", () => {
expect(createTopicReq.description).toBe(topic?.description);
expect(0).toBe(topic?.totalWriters.toNumber());
expect(0).toBe(topic?.totalRecords.toNumber());
console.log(`create topic success. ownerAddress(${ownerAddress}), topicName(${topicName})`);

console.log(`add writer. ownerAddress(${ownerAddress}), writer(${ownerAddress}) topicName(${topicName})`);
const addWriterReq = {
ownerAddress: ownerAddress,
writerAddress: ownerAddress,
Expand All @@ -90,9 +93,12 @@ describe("", () => {
.getWriter(ownerAddress, topicName, ownerAddress);
expect(addWriterReq.moniker).toBe(writer?.moniker);
expect(addWriterReq.description).toBe(writer?.description);
console.log(`add writer success. ownerAddress(${ownerAddress}), writer(${ownerAddress}) topicName(${topicName})`);

const key = new TextEncoder().encode("key1");
const value = new TextEncoder().encode("value1");

console.log(`add record. ownerAddress(${ownerAddress}), writer(${ownerAddress}) topicName(${topicName}) key(${key.toString()}) value(${value.toString()})`);
const addRecordRes = await client.addRecord(
{
key: key,
Expand All @@ -119,6 +125,7 @@ describe("", () => {
expect(record?.key.toString()).toBe(key.toString());
expect(record?.value.toString()).toBe(value.toString());
expect(record?.writerAddress).toBe(ownerAddress);
console.log(`add record success. ownerAddress(${ownerAddress}), writer(${ownerAddress}) topicName(${topicName}) key(${key.toString()}) value(${value.toString()})`);
});
});

Expand Down Expand Up @@ -148,6 +155,7 @@ describe("", () => {
const didDocument = generateDidDocument(privKey);
let signature = DidUtil.signDidDocument(privKey, didDocument);

console.log(`create did. did(${didDocument.id}) verificationMethodId(${didDocument.verificationMethods[0].id})`);
const createDidReq = {
did: didDocument.id,
document: didDocument,
Expand All @@ -156,7 +164,6 @@ describe("", () => {
fromAddress: fromAddress,
};
let res = await client.createDid(createDidReq, "auto");
console.log("create", res);
expect(isDeliverTxSuccess(res)).toBeTruthy();

let getDIDDocumentWithSeq = await client
Expand All @@ -174,7 +181,9 @@ describe("", () => {
didDocument,
getDIDDocumentWithSeq.sequence,
);
console.log(`create did success. did(${didDocument.id}) verificationMethodId(${didDocument.verificationMethods[0].id})`);

console.log(`update did. did(${didDocument.id}) verificationMethodId(${didDocument.verificationMethods[0].id})`);
const updateDidReq = {
did: didDocument.id,
document: didDocument,
Expand All @@ -193,6 +202,7 @@ describe("", () => {
console.log(getDIDDocumentWithSeq?.sequence.toNumber());
assert(getDIDDocumentWithSeq);
expect(getDIDDocumentWithSeq.document).toEqual(didDocument);
console.log(`update did success. did(${didDocument.id}) verificationMethodId(${didDocument.verificationMethods[0].id})`);
});

it("create DID with offline signer", async () => {
Expand Down Expand Up @@ -275,6 +285,7 @@ describe("", () => {
data: "no data",
creator: fromAddress,
};
console.log(`create denom. denomId(${denomId}) creator(${fromAddress})`);
let res = await client.createDenom(createDenomReq, fee);
expect(isDeliverTxSuccess(res)).toBeTruthy();

Expand All @@ -288,7 +299,9 @@ describe("", () => {
expect(denom!.uri).toBe("");
expect(denom!.uriHash).toBe("");
expect(denom!.owner).toBe(fromAddress);
console.log(`create denom success. denomId(${denomId}) creator(${fromAddress})`);

console.log(`update denom. denomId(${denomId}) creator(${fromAddress})`);
const updateDenomReq = {
id: denomId,
name: "mediboc test update denom",
Expand All @@ -312,8 +325,10 @@ describe("", () => {
expect(denom!.uri).toBe(updateDenomReq.uri);
expect(denom!.uriHash).toBe(updateDenomReq.uriHash);
expect(denom!.owner).toBe(fromAddress);
console.log(`update denom success. denomId(${denomId}) creator(${fromAddress})`);

const pnftId = v4();
console.log(`mint pnft. denomId(${denomId}) pnftId(${pnftId}) creator(${fromAddress})`);
const firstPnftReq = {
denomId: denomId,
id: pnftId,
Expand All @@ -336,13 +351,15 @@ describe("", () => {
expect(pnft!.uriHash).toBe("");
expect(pnft!.creator).toBe(fromAddress);
expect(pnft!.owner).toBe(fromAddress);
console.log(`mint pnft success. denomId(${denomId}) pnftId(${pnftId}) creator(${fromAddress})`);

const transferPnftReq = {
denomId: denomId,
id: pnftId,
sender: fromAddress,
receiver: toAddress,
};
console.log(`transfer pnft. denomId(${denomId}) pnftId(${pnftId}) creator(${fromAddress}) to(${toAddress}`);
res = await client.transferPNFT(transferPnftReq, fee);
expect(isDeliverTxSuccess(res)).toBeTruthy();

Expand All @@ -357,6 +374,7 @@ describe("", () => {
expect(pnft!.uriHash).toBe("");
expect(pnft!.creator).toBe(fromAddress);
expect(pnft!.owner).toBe(toAddress);
console.log(`transfer pnft success. denomId(${denomId}) pnftId(${pnftId}) creator(${fromAddress}) to(${toAddress}`);

////////////////////// Burn Pnft////////////////////////

Expand All @@ -368,6 +386,7 @@ describe("", () => {
data: "no data",
creator: fromAddress,
};
console.log(`burn pnft. denomId(${denomId}) pnftId(${secondPNftReq.id}) creator(${fromAddress})`);
res = await client.mintPNFT(secondPNftReq, fee);
expect(isDeliverTxSuccess(res)).toBeTruthy();

Expand All @@ -382,6 +401,7 @@ describe("", () => {

pnft = await client.getPanaceaClient().getPnft(denomId, secondPNftReq.id);
expect(pnft).toBeUndefined();
console.log(`burn pnft success. denomId(${denomId}) pnftId(${secondPNftReq.id}) creator(${fromAddress})`);
});
});
});
Expand Down

0 comments on commit 43ff233

Please sign in to comment.