Skip to content

Commit

Permalink
update tests to check server time offset
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshu committed Mar 5, 2024
1 parent a7d1ecd commit 7c77945
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/aqua.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe("torus utils aqua", function () {
const { torusNodeEndpoints, torusNodePub } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const result = await torus.getPublicAddress(torusNodeEndpoints, torusNodePub, verifierDetails);
expect(result.finalKeyData.evmAddress).to.equal("0xDfA967285AC699A70DA340F60d00DB19A272639d");
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -58,6 +59,7 @@ describe("torus utils aqua", function () {
const { torusNodeEndpoints, torusNodePub } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const result1 = (await torus.getUserTypeAndAddress(torusNodeEndpoints, torusNodePub, verifierDetails)) as TorusPublicKey;
expect(result1.metadata.typeOfUser).to.equal("v2");
expect(result1.metadata.serverTimeOffset).lessThan(20);
delete result1.metadata.serverTimeOffset;

expect(result1).eql({
Expand Down Expand Up @@ -91,6 +93,7 @@ describe("torus utils aqua", function () {
verifierId: v2TestEmail,
})) as TorusPublicKey;
expect(result2.metadata.typeOfUser).to.equal("v2");
expect(result2.metadata.serverTimeOffset).lessThan(20);
delete result2.metadata.serverTimeOffset;

expect(result2).eql({
Expand Down Expand Up @@ -122,6 +125,7 @@ describe("torus utils aqua", function () {
verifier: v2Verifier,
verifierId: v2nTestEmail,
})) as TorusPublicKey;
expect(result3.metadata.serverTimeOffset).lessThan(20);
delete result3.metadata.serverTimeOffset;

expect(result3.metadata.typeOfUser).to.equal("v2");
Expand Down Expand Up @@ -169,6 +173,7 @@ describe("torus utils aqua", function () {
const { torusNodeEndpoints, torusIndexes } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const result = await torus.retrieveShares(torusNodeEndpoints, torusIndexes, TORUS_TEST_VERIFIER, { verifier_id: TORUS_TEST_EMAIL }, token);
expect(result.finalKeyData.privKey).to.be.equal("f726ce4ac79ae4475d72633c94769a8817aff35eebe2d4790aed7b5d8a84aa1d");
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -206,6 +211,7 @@ describe("torus utils aqua", function () {
},
hashedIdToken.substring(2)
);
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result.oAuthKeyData.evmAddress).to.be.equal("0x5b58d8a16fDA79172cd42Dc3068d5CEf26a5C81D");
Expand Down
6 changes: 6 additions & 0 deletions test/celeste.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe("torus utils celeste", function () {
const { torusNodeEndpoints, torusNodePub } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const result = await torus.getPublicAddress(torusNodeEndpoints, torusNodePub, verifierDetails);
expect(result.finalKeyData.evmAddress).to.equal("0xeC80FB9aB308Be1789Bd3f9317962D5505A4A242");
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -59,6 +60,7 @@ describe("torus utils celeste", function () {
const result1 = await torus.getUserTypeAndAddress(torusNodeEndpoints, torusNodePub, verifierDetails);
expect(result1.finalKeyData.evmAddress).to.equal("0xeC80FB9aB308Be1789Bd3f9317962D5505A4A242");
expect(result1.metadata.typeOfUser).to.equal("v1");
expect(result1.metadata.serverTimeOffset).lessThan(20);
delete result1.metadata.serverTimeOffset;

expect(result1).eql({
Expand Down Expand Up @@ -163,6 +165,8 @@ describe("torus utils celeste", function () {
const { torusNodeEndpoints, torusIndexes } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const result = await torus.retrieveShares(torusNodeEndpoints, torusIndexes, TORUS_TEST_VERIFIER, { verifier_id: TORUS_TEST_EMAIL }, token);
expect(result.finalKeyData.privKey).to.be.equal("0ae056aa938080c9e8bf6641261619e09fd510c91bb5aad14b0de9742085a914");
expect(result.metadata.serverTimeOffset).lessThan(20);

delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -200,6 +204,8 @@ describe("torus utils celeste", function () {
},
hashedIdToken.substring(2)
);
expect(result.metadata.serverTimeOffset).lessThan(20);

delete result.metadata.serverTimeOffset;

expect(result.oAuthKeyData.evmAddress).to.be.equal("0x535Eb1AefFAc6f699A2a1A5846482d7b5b2BD564");
Expand Down
9 changes: 9 additions & 0 deletions test/cyan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ describe("torus utils cyan", function () {
const { torusNodeEndpoints, torusNodePub } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const result = await torus.getPublicAddress(torusNodeEndpoints, torusNodePub, verifierDetails);
expect(result.finalKeyData.evmAddress).to.equal("0xA3767911A84bE6907f26C572bc89426dDdDB2825");
expect(result.metadata.serverTimeOffset).lessThan(20);

delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -59,6 +61,7 @@ describe("torus utils cyan", function () {
const result1 = await torus.getUserTypeAndAddress(torusNodeEndpoints, torusNodePub, verifierDetails);
expect(result1.finalKeyData.evmAddress).to.equal("0x3507F0d192a44E436B8a6C32a37d57D022861b1a");
expect(result1.metadata.typeOfUser).to.equal("v2");
expect(result1.metadata.serverTimeOffset).lessThan(20);
delete result1.metadata.serverTimeOffset;

expect(result1).eql({
Expand Down Expand Up @@ -91,6 +94,8 @@ describe("torus utils cyan", function () {
verifier: v2Verifier,
verifierId: v2TestEmail,
});
expect(result2.metadata.serverTimeOffset).lessThan(20);

delete result2.metadata.serverTimeOffset;

expect(result2.finalKeyData.evmAddress).to.equal("0x8EA83Ace86EB414747F2b23f03C38A34E0217814");
Expand Down Expand Up @@ -171,6 +176,8 @@ describe("torus utils cyan", function () {
const { torusNodeEndpoints, torusIndexes } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const result = await torus.retrieveShares(torusNodeEndpoints, torusIndexes, TORUS_TEST_VERIFIER, { verifier_id: TORUS_TEST_EMAIL }, token);
delete result.sessionData;
expect(result.metadata.serverTimeOffset).lessThan(20);

delete result.metadata.serverTimeOffset;

expect(result.finalKeyData.privKey).to.be.equal("5db51619684b32a2ff2375b4c03459d936179dfba401cb1c176b621e8a2e4ac8");
Expand Down Expand Up @@ -209,6 +216,8 @@ describe("torus utils cyan", function () {
hashedIdToken.substring(2)
);
delete result.sessionData;
expect(result.metadata.serverTimeOffset).lessThan(20);

delete result.metadata.serverTimeOffset;

expect(result.oAuthKeyData.evmAddress).to.be.equal("0x34117FDFEFBf1ad2DFA6d4c43804E6C710a6fB04");
Expand Down
8 changes: 8 additions & 0 deletions test/mainnet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ describe("torus utils mainnet", function () {
const { torusNodeEndpoints, torusNodePub } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const result1 = await torus.getUserTypeAndAddress(torusNodeEndpoints, torusNodePub, verifierDetails);
expect(result1.metadata.typeOfUser).to.equal("v2");
expect(result1.metadata.serverTimeOffset).lessThan(20);

delete result1.metadata.serverTimeOffset;

expect(result1).eql({
Expand Down Expand Up @@ -90,6 +92,8 @@ describe("torus utils mainnet", function () {
verifier: v2Verifier,
verifierId: v2TestEmail,
});
expect(result2.metadata.serverTimeOffset).lessThan(20);

delete result2.metadata.serverTimeOffset;

expect(result2.finalKeyData.evmAddress).to.equal("0xFf669A15bFFcf32D3C5B40bE9E5d409d60D43526");
Expand Down Expand Up @@ -172,6 +176,8 @@ describe("torus utils mainnet", function () {
const { torusNodeEndpoints, torusIndexes } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const result = await torus.retrieveShares(torusNodeEndpoints, torusIndexes, TORUS_TEST_VERIFIER, { verifier_id: TORUS_TEST_EMAIL }, token);
delete result.sessionData;
expect(result.metadata.serverTimeOffset).lessThan(20);

delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -211,6 +217,8 @@ describe("torus utils mainnet", function () {
expect(result.oAuthKeyData.evmAddress).to.be.equal("0x621a4d458cFd345dAE831D9E756F10cC40A50381");
expect(result.finalKeyData.evmAddress).to.be.equal("0x621a4d458cFd345dAE831D9E756F10cC40A50381");
delete result.sessionData;
expect(result.metadata.serverTimeOffset).lessThan(20);

delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down
7 changes: 7 additions & 0 deletions test/onekey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ describe("torus onekey", function () {
const { torusNodeEndpoints, torusNodePub } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const publicAddress = (await torus.getPublicAddress(torusNodeEndpoints, torusNodePub, verifierDetails)) as TorusPublicKey;
expect(publicAddress.finalKeyData.evmAddress).to.be.equal("0x930abEDDCa6F9807EaE77A3aCc5c78f20B168Fd1");
expect(publicAddress.metadata.serverTimeOffset).lessThan(20);

delete publicAddress.metadata.serverTimeOffset;

expect(publicAddress).eql({
Expand Down Expand Up @@ -66,6 +68,8 @@ describe("torus onekey", function () {
{ verifier_id: TORUS_TEST_EMAIL },
token
);
expect(retrieveSharesResponse.metadata.serverTimeOffset).lessThan(20);

delete retrieveSharesResponse.metadata.serverTimeOffset;

expect(retrieveSharesResponse.finalKeyData.privKey).to.be.equal("296045a5599afefda7afbdd1bf236358baff580a0fe2db62ae5c1bbe817fbae4");
Expand Down Expand Up @@ -115,6 +119,8 @@ describe("torus onekey", function () {
},
hashedIdToken.substring(2)
);
expect(retrieveSharesResponse.metadata.serverTimeOffset).lessThan(20);

delete retrieveSharesResponse.metadata.serverTimeOffset;

expect(retrieveSharesResponse.finalKeyData.evmAddress).to.be.equal("0xE1155dB406dAD89DdeE9FB9EfC29C8EedC2A0C8B");
Expand Down Expand Up @@ -188,6 +194,7 @@ describe("torus onekey", function () {
{ verifier_id: "[email protected]" },
token
);
expect(retrieveSharesResponse.metadata.serverTimeOffset).lessThan(20);
delete retrieveSharesResponse.metadata.serverTimeOffset;

expect(retrieveSharesResponse.finalKeyData.privKey).to.be.equal("9ec5b0504e252e35218c7ce1e4660eac190a1505abfbec7102946f92ed750075");
Expand Down
16 changes: 16 additions & 0 deletions test/sapphire_devnet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ describe("torus utils sapphire devnet", function () {
});
expect(result.finalKeyData.evmAddress).to.equal("0xE91200d82029603d73d6E307DbCbd9A7D0129d8D");
expect(result.metadata.typeOfUser).to.equal("v2");
expect(result.metadata.serverTimeOffset).lessThan(20);

delete result.metadata.serverTimeOffset;
expect(result).eql({
oAuthKeyData: {
Expand Down Expand Up @@ -178,6 +180,8 @@ describe("torus utils sapphire devnet", function () {
});
expect(data.metadata.typeOfUser).to.equal("v2");
expect(data.finalKeyData.evmAddress).to.equal("0x1016DA7c47A04C76036637Ea02AcF1d29c64a456");
expect(data.metadata.serverTimeOffset).lessThan(20);

delete data.metadata.serverTimeOffset;
expect(data).eql({
oAuthKeyData: {
Expand Down Expand Up @@ -208,6 +212,7 @@ describe("torus utils sapphire devnet", function () {
const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints;
const result = await torus.getPublicAddress(torusNodeEndpoints, nodeDetails.torusNodePub, verifierDetails);
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -253,8 +258,12 @@ describe("torus utils sapphire devnet", function () {
const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints;

const result1 = await torus.getPublicAddress(torusNodeEndpoints, nodeDetails.torusNodePub, verifierDetails);
expect(result1.metadata.serverTimeOffset).lessThan(20);

delete result1.metadata.serverTimeOffset;
const result2 = await torus.getPublicAddress(torusNodeEndpoints, nodeDetails.torusNodePub, verifierDetails);
expect(result2.metadata.serverTimeOffset).lessThan(20);

delete result2.metadata.serverTimeOffset;

expect(result1.finalKeyData).eql(result2.finalKeyData);
Expand All @@ -267,6 +276,7 @@ describe("torus utils sapphire devnet", function () {
const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints;
const result = await torus.getPublicAddress(torusNodeEndpoints, nodeDetails.torusNodePub, verifierDetails);
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -314,6 +324,7 @@ describe("torus utils sapphire devnet", function () {
{ verifier_id: TORUS_TEST_EMAIL },
token
);
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -449,6 +460,7 @@ describe("torus utils sapphire devnet", function () {
const nodeDetails = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints;
const result = await torus.getPublicAddress(torusNodeEndpoints, nodeDetails.torusNodePub, verifierDetails);
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -515,6 +527,7 @@ describe("torus utils sapphire devnet", function () {
const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints;
const result = await torus.getPublicAddress(torusNodeEndpoints, nodeDetails.torusNodePub, verifierDetails);
expect(result.finalKeyData.evmAddress).to.equal("0xF79b5ffA48463eba839ee9C97D61c6063a96DA03");
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -560,6 +573,8 @@ describe("torus utils sapphire devnet", function () {
const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints;
const result = await torus.getPublicAddress(torusNodeEndpoints, nodeDetails.torusNodePub, verifierDetails);
expect(result.finalKeyData.evmAddress).to.equal("0xF79b5ffA48463eba839ee9C97D61c6063a96DA03");
expect(result.metadata.serverTimeOffset).lessThan(20);

delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -650,6 +665,7 @@ describe("torus utils sapphire devnet", function () {
},
hashedIdToken.substring(2)
);
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result.finalKeyData.evmAddress).to.not.equal(null);
Expand Down
6 changes: 6 additions & 0 deletions test/sapphire_mainnet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe("torus utils sapphire mainnet", function () {
const { torusNodeEndpoints, torusNodePub } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const result = await torus.getPublicAddress(torusNodeEndpoints, torusNodePub, verifierDetails);
expect(result.finalKeyData.evmAddress).to.equal("0x327b2742768B436d09153429E762FADB54413Ded");
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -117,6 +118,7 @@ describe("torus utils sapphire mainnet", function () {
const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints;
const result = await torus.getPublicAddress(torusNodeEndpoints, nodeDetails.torusNodePub, verifierDetails);
expect(result.finalKeyData.evmAddress).to.be.equal("0x98EC5b049c5C0Dc818C69e95CF43534AEB80261A");
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -168,6 +170,7 @@ describe("torus utils sapphire mainnet", function () {
const torusNodeEndpoints = nodeDetails.torusNodeSSSEndpoints;
const result = await torus.getPublicAddress(torusNodeEndpoints, nodeDetails.torusNodePub, verifierDetails);
expect(result.finalKeyData.evmAddress).to.equal("0xCb76F4C8cbAe524997787B57efeeD99f6D3BD5AB");
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -239,6 +242,7 @@ describe("torus utils sapphire mainnet", function () {
token
);
expect(result.finalKeyData.privKey).to.be.equal("13941ecd812b08d8a33a20bc975f0cd1c3f82de25b20c0c863ba5f21580b65f6");
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -277,6 +281,8 @@ describe("torus utils sapphire mainnet", function () {
const { torusNodeEndpoints, torusIndexes } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const result = await torus.retrieveShares(torusNodeEndpoints, torusIndexes, TORUS_TEST_VERIFIER, { verifier_id: TORUS_TEST_EMAIL }, token);
expect(result.finalKeyData.privKey).to.be.equal("dfb39b84e0c64b8c44605151bf8670ae6eda232056265434729b6a8a50fa3419");
expect(result.metadata.serverTimeOffset).lessThan(20);

delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down
7 changes: 7 additions & 0 deletions test/testnet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe("torus utils migrated testnet on sapphire", function () {
const { torusNodeEndpoints, torusNodePub } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const result = await torus.getPublicAddress(torusNodeEndpoints, torusNodePub, verifierDetails);
expect(result.finalKeyData.evmAddress).to.equal("0x9bcBAde70546c0796c00323CD1b97fa0a425A506");
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result).eql({
Expand Down Expand Up @@ -60,6 +61,8 @@ describe("torus utils migrated testnet on sapphire", function () {
const result1 = await torus.getUserTypeAndAddress(torusNodeEndpoints, torusNodePub, verifierDetails);
expect(result1.finalKeyData.evmAddress).to.equal("0xf5804f608C233b9cdA5952E46EB86C9037fd6842");
expect(result1.metadata.typeOfUser).to.equal("v2");
expect(result1.metadata.serverTimeOffset).lessThan(20);

delete result1.metadata.serverTimeOffset;

expect(result1).eql({
Expand Down Expand Up @@ -94,6 +97,8 @@ describe("torus utils migrated testnet on sapphire", function () {
})) as TorusPublicKey;
expect(result2.finalKeyData.evmAddress).to.equal("0xE91200d82029603d73d6E307DbCbd9A7D0129d8D");
expect(result2.metadata.typeOfUser).to.equal("v2");
expect(result2.metadata.serverTimeOffset).lessThan(20);

delete result2.metadata.serverTimeOffset;

expect(result2).eql({
Expand Down Expand Up @@ -172,6 +177,7 @@ describe("torus utils migrated testnet on sapphire", function () {
const verifierDetails = { verifier: TORUS_TEST_VERIFIER, verifierId: TORUS_TEST_EMAIL };
const { torusNodeEndpoints, torusIndexes } = await TORUS_NODE_MANAGER.getNodeDetails(verifierDetails);
const result = await torus.retrieveShares(torusNodeEndpoints, torusIndexes, TORUS_TEST_VERIFIER, { verifier_id: TORUS_TEST_EMAIL }, token);
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result.finalKeyData.privKey).to.be.equal("9b0fb017db14a0a25ed51f78a258713c8ae88b5e58a43acb70b22f9e2ee138e3");
Expand Down Expand Up @@ -213,6 +219,7 @@ describe("torus utils migrated testnet on sapphire", function () {
},
hashedIdToken.substring(2)
);
expect(result.metadata.serverTimeOffset).lessThan(20);
delete result.metadata.serverTimeOffset;

expect(result.metadata.typeOfUser).to.be.equal("v1");
Expand Down

0 comments on commit 7c77945

Please sign in to comment.