Skip to content

Commit d81f816

Browse files
committed
updated test to include validation failure case
1 parent 17628c1 commit d81f816

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

packages/fetch-node-details/test/nodeDetail.test.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { METADATA_MAP, TORUS_LEGACY_NETWORK, TORUS_NETWORK_TYPE, TORUS_SAPPHIRE_NETWORK } from "@toruslabs/constants";
1+
import { METADATA_MAP, SIG_TYPE, TORUS_LEGACY_NETWORK, TORUS_NETWORK_TYPE, TORUS_SAPPHIRE_NETWORK } from "@toruslabs/constants";
22
import { getSapphireNodeDetails } from "@toruslabs/fnd-base";
3-
import { deepStrictEqual, strictEqual, throws } from "assert";
3+
import { deepStrictEqual, rejects, strictEqual, throws } from "assert";
44

55
import NodeDetailManager from "../src/nodeDetailManager";
66

@@ -115,6 +115,27 @@ describe("Fetch Node Details", function () {
115115
);
116116
});
117117

118+
it("#should throw error for invalid key type and sig type", async function () {
119+
const nodeDetailManager = new NodeDetailManager({
120+
network: TORUS_SAPPHIRE_NETWORK.SAPPHIRE_MAINNET,
121+
fndServerEndpoint,
122+
enableLogging: true,
123+
});
124+
125+
const sigType = SIG_TYPE.ED25519;
126+
127+
await rejects(
128+
async () => {
129+
await nodeDetailManager.getNodeDetails({ verifier: "google", verifierId: "hello@tor.us", keyType: "secp256k1", sigType });
130+
},
131+
(err) => {
132+
const error = err as Error;
133+
strictEqual(error.message, `Invalid key type for ${sigType}`);
134+
return true;
135+
}
136+
);
137+
});
138+
118139
it("#should use default network if not provided", async function () {
119140
const nodeDetailManager = new NodeDetailManager({
120141
fndServerEndpoint,

0 commit comments

Comments
 (0)