Skip to content

Commit

Permalink
fix: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HinsonSIDAN committed Aug 2, 2024
1 parent 00f84be commit 6e1a4aa
Show file tree
Hide file tree
Showing 28 changed files with 49 additions and 69 deletions.
10 changes: 5 additions & 5 deletions apps/docs/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CodeGroup } from '@/components/Code';
import { Prose } from '@/components/Prose';
import Markdown from 'react-markdown';
import { CodeGroup } from "@/components/Code";
import { Prose } from "@/components/Prose";
import Markdown from "react-markdown";

export default function Home() {
return (
Expand Down Expand Up @@ -35,8 +35,8 @@ export default function Home() {
Mesh with npm:
</p>

<CodeGroup title="" code={`npm install @meshsdk/core @meshsdk/react`}>
<Markdown>npm install @meshsdk/core @meshsdk/react</Markdown>
<CodeGroup title="" code={`npm install @meshsdk/core`}>
<Markdown>npm install @meshsdk/core</Markdown>
</CodeGroup>

{/* <Resources /> */}
Expand Down
13 changes: 3 additions & 10 deletions packages/config-jest/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@ const jestConfig: Config = {
testEnvironment: "node",
testMatch: ["**/packages/**/*.test.ts"],
setupFiles: ["dotenv/config"],
preset: "ts-jest/presets/default-esm",
preset: "ts-jest",
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
},
],
"^.+\\.[jt]s?$": "ts-jest",
},
transformIgnorePatterns: [
"/node_modules/(?!@meshsdk/core-csl)", // Add exceptions for ESM packages
],
transformIgnorePatterns: ["/node_modules/(?!@meshsdk/.*)"],
};

export default jestConfig;
3 changes: 2 additions & 1 deletion packages/mesh-common/test/data/mesh/aliases.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
mTxOutRef,
outputReference,
txOutRef,
} from "../../../src";
} from "@meshsdk/common";

import { serializeData } from "./common";

const testHash = "baefdc6c5b191be372a794cd8d40d839ec0dbdd3c28957267dc81700";
Expand Down
3 changes: 1 addition & 2 deletions packages/mesh-common/test/data/mesh/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Data } from "@meshsdk/common";
import { castDataToPlutusData } from "@meshsdk/core-csl";

import { Data } from "../../../src";

export const serializeData = (mesh: Data, json: any) => {
const meshData = castDataToPlutusData({
type: "Mesh",
Expand Down
4 changes: 2 additions & 2 deletions packages/mesh-common/test/data/mesh/constructors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import {
conStr0,
conStr1,
conStr2,
Data,
mConStr,
mConStr0,
mConStr1,
mConStr2,
} from "../../../src";
} from "@meshsdk/common";

import { serializeData } from "./common";

const testByteString = "abcd";
Expand Down
7 changes: 2 additions & 5 deletions packages/mesh-common/test/data/mesh/credentials.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import {
conStr0,
conStr1,
maybeStakingHash,
mMaybeStakingHash,
mPubKeyAddress,
mScriptAddress,
pubKeyAddress,
pubKeyHash,
scriptAddress,
scriptHash,
} from "../../../src";
} from "@meshsdk/common";

import { serializeData } from "./common";

const testKeyHash1 = "1e4eb194e3335a0dcc4f5c5d009318167c583bb3b0879d9f718cd9e0";
Expand Down
3 changes: 2 additions & 1 deletion packages/mesh-common/test/data/mesh/primitives.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
mBool,
mPlutusBSArrayToString,
mStringToPlutusBSArray,
} from "../../../src";
} from "@meshsdk/common";

import { serializeData } from "./common";

describe("Plutus data type", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-common/test/data/value.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
parsePlutusValueToAssets,
Value,
value,
} from "../../src";
} from "@meshsdk/common";

describe("value", () => {
test("Simple ADA Value", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/mesh-core-csl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"build:mesh": "tsup src/index.ts --format esm,cjs --dts",
"dev": "tsup src/index.ts --format esm,cjs --watch --dts",
"lint": "eslint",
"test": "jest --verbose",
"clean": "rm -rf .turbo && rm -rf dist && rm -rf node_modules",
"format": "prettier --check . --ignore-path ../../.gitignore",
"build:docs": "typedoc src/index.ts --json ../../apps/docs/src/data/mesh-core-csl.json"
"build:docs": "typedoc src/index.ts --json ../../apps/docs/src/data/mesh-core-csl.json",
"test": "jest"
},
"browser": {
"@sidan-lab/sidan-csl-rs-nodejs": "@sidan-lab/sidan-csl-rs-browser"
Expand Down
11 changes: 9 additions & 2 deletions packages/mesh-core-csl/src/core/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@ import { meshTxBuilderBodyToObj } from "./adaptor";
import { builderDataToCbor } from "./adaptor/data";

export class CSLSerializer implements IMeshTxSerializer {
/**
* Set to true to enable verbose logging for the txBodyJson prior going into build
*/
verbose: boolean;
protocolParams: Protocol;

meshTxBuilderBody: MeshTxBuilderBody = emptyTxBuilderBody();

constructor(protocolParams?: Protocol) {
constructor(protocolParams?: Protocol, verbose = false) {
this.protocolParams = protocolParams || DEFAULT_PROTOCOL_PARAMETERS;
this.verbose = verbose;
}

serializeTxBody(
Expand All @@ -59,7 +64,9 @@ export class CSLSerializer implements IMeshTxSerializer {

const params = JSONbig.stringify(protocolParams || this.protocolParams);

console.log("txBodyJson", txBodyJson);
if (this.verbose) {
console.log("txBodyJson", txBodyJson);
}
const txBuildResult = csl.js_serialize_tx_body(txBodyJson, params);
if (txBuildResult.get_status() !== "success") {
throw new Error(txBuildResult.get_data());
Expand Down
3 changes: 1 addition & 2 deletions packages/mesh-core-csl/test/core/builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import {
DEFAULT_PROTOCOL_PARAMETERS,
MeshTxBuilderBody,
} from "@meshsdk/common";

import { CSLSerializer } from "../../src";
import { CSLSerializer } from "@meshsdk/core-csl";

describe("Builder", () => {
test("serializeTxBody - send lovelace", () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/mesh-core-csl/test/utils/address.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { pubKeyAddress, scriptAddress } from "@meshsdk/common";

import {
deserializeBech32Address,
scriptHashToBech32,
serializeAddressObj,
} from "../../src";
} from "@meshsdk/core-csl";

describe("Address", () => {
test("deserializeBech32Address", () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/mesh-core-csl/test/utils/aiken.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { builtinByteString } from "@meshsdk/common";

import { applyParamsToScript, deserializeBech32Address } from "../../src";
import {
applyParamsToScript,
deserializeBech32Address,
} from "@meshsdk/core-csl";

describe("Aiken", () => {
test("applyParamsToScript 1", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-core-csl/test/utils/scripts.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { applyParamsToScript, getV2ScriptHash } from "../../src";
import { applyParamsToScript, getV2ScriptHash } from "@meshsdk/core-csl";

describe("Scripts", () => {
test("getV2ScriptHash", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-core-csl/test/utils/transaction.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { calculateTxHash } from "../../src";
import { calculateTxHash } from "@meshsdk/core-csl";

describe("Transaction", () => {
test("calculateTxHash", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-core-cst/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"build:mesh": "tsup src/index.ts --format esm,cjs --dts --minify",
"dev": "tsup src/index.ts --format esm,cjs --watch --dts",
"lint": "eslint",
"test": "jest --verbose",
"test": "jest",
"clean": "rm -rf .turbo && rm -rf dist && rm -rf node_modules",
"format": "prettier --check . --ignore-path ../../.gitignore"
},
Expand Down
15 changes: 1 addition & 14 deletions packages/mesh-core-cst/src/stricahq/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
import strica from "@stricahq/bip32ed25519"; // This works with broswer, but not node

// import * as strica from "@stricahq/bip32ed25519"; // This works with node, but not browser

// let strica: any;

// if (typeof window !== "undefined") {
// // Browser environment
// strica = await import("@stricahq/bip32ed25519");
// } else {
// // Node.js environment
// strica = require("@stricahq/bip32ed25519");
// }

import strica from "@stricahq/bip32ed25519";
import hash from "hash.js";

class PrivateKey extends strica.PrivateKey {
Expand Down
4 changes: 1 addition & 3 deletions packages/mesh-core-cst/test/resolvers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ import {
PlutusScript,
resolveFingerprint,
} from "@meshsdk/common";

import {
resolveDataHash,
resolveNativeScriptAddress,
resolveNativeScriptHash,
resolvePaymentKeyHash,
resolvePlutusScriptAddress,
resolvePlutusScriptHash,
resolvePrivateKey,
resolveRewardAddress,
resolveStakeKeyHash,
} from "../src";
} from "@meshsdk/core-cst";

describe("resolveDataHash", () => {
it("should return correct data", () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/mesh-core-cst/test/utils/converter.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { PlutusScript } from "@meshsdk/common";

import { fromScriptRef } from "../../src/utils/converter";
import { fromScriptRef } from "@meshsdk/core-cst";

describe("fromScriptRef", () => {
// it("with native script cbor should return correct NativeScript", () => {});
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/mesh-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dev": "tsup src/index.ts --format esm,cjs --watch --dts",
"lint": "eslint",
"clean": "rm -rf .turbo && rm -rf dist && rm -rf node_modules",
"test": "jest --verbose",
"test": "jest",
"format": "prettier --check . --ignore-path ../../.gitignore",
"build:docs": "typedoc src/index.ts --json ../../apps/docs/src/data/mesh-providers.json"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-provider/test/blockfrost/evaluator.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dotenv from "dotenv";

import { BlockfrostProvider } from "../../src";
import { BlockfrostProvider } from "@meshsdk/provider";

dotenv.config();
const apiKey = process.env.BLOCKFROST_API_KEY_PREPROD!;
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-provider/test/maestro/evaluator.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dotenv from "dotenv";

import { MaestroProvider } from "../../src/maestro";
import { MaestroProvider } from "@meshsdk/provider";

dotenv.config();
const apiKey = process.env.MAESTRO_API_KEY!;
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dev": "tsup src/index.ts --format esm,cjs --watch --dts",
"lint": "eslint",
"clean": "rm -rf .turbo && rm -rf dist && rm -rf node_modules",
"test": "jest --verbose",
"test": "jest",
"format": "prettier --check . --ignore-path ../../.gitignore",
"build:docs": "typedoc src/index.ts --json ../../apps/docs/src/data/mesh-wallets.json"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-wallet/test/app.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppWallet } from "../src";
import { AppWallet } from "@meshsdk/wallet";

describe("AppWallet", () => {
const wallet = new AppWallet({
Expand Down
3 changes: 1 addition & 2 deletions packages/mesh-wallet/test/browser.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CardanoSDKUtil, Serialization } from "@meshsdk/core-cst";

import { WalletStaticMethods } from "../src";
import { WalletStaticMethods } from "@meshsdk/wallet";

describe("BroswerWallet", () => {
it("signTx: addWitnessSet", () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/mesh-wallet/test/embedded.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { checkSignature } from "@meshsdk/core-cst";

import { EmbeddedWallet } from "../src";
import { EmbeddedWallet } from "@meshsdk/wallet";

describe("EmbeddedWallet mnemonic", () => {
const wallet = new EmbeddedWallet({
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-wallet/test/mesh.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MeshWallet } from "../src";
import { MeshWallet } from "@meshsdk/wallet";

describe("MeshWallet", () => {
const wallet = new MeshWallet({
Expand Down

0 comments on commit 6e1a4aa

Please sign in to comment.