Skip to content

Commit

Permalink
✅ Fix timeout coverage on wallet tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cif committed Nov 14, 2022
1 parent 2ebccda commit 8b97c5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/auth/src/wallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import { Observable } from 'rxjs';
jest.mock('@near-wallet-selector/core');
jest.mock('@near-wallet-selector/modal-ui');
jest.mock('./constants', () => ({
WALLET_CONNECTION_TIMEOUT: 10,
WALLET_CONNECTION_TIMEOUT: -1,
WALLET_CONNECTION_POLL_INTERVAL: 100,
}));

jest.useFakeTimers();
// jest.useFakeTimers();

describe('wallet', () => {
const mockModal = {
Expand All @@ -45,7 +45,7 @@ describe('wallet', () => {
},
};
beforeAll(() => {

jest.resetAllMocks();
Object.defineProperty(global, 'localStorage', {
value: {
getItem: jest.fn(),
Expand Down
18 changes: 9 additions & 9 deletions packages/auth/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ let timerReference = null;

export const pollForWalletConnection = async (): Promise<AccountState[]> => {
validateWalletComponentsAreSetup();
// clear any existing timers
// clear any existing timer
clearTimeout(timerReference);

const tryToResolveAccountsFromState = (
Expand Down Expand Up @@ -190,18 +190,18 @@ export const signMessage = async (params: VerifyOwnerParams): Promise<VerifiedOw
// https://www.npmjs.com/package/bs58
// https://github.com/feross/buffer
// https://github.com/near/wallet-selector/issues/434
export const verifyMessage = async (signature: string): Promise<boolean> => {
// export const verifyMessage = async (signature: string): Promise<boolean> => {

// const owner = await getVerifiedOwner(signature);
// // const owner = await getVerifiedOwner(signature);

// const publicKeyString = `ed25519:${BinaryToBase58(Buffer.from(owner.publicKey, 'base64'))}`;
// // const publicKeyString = `ed25519:${BinaryToBase58(Buffer.from(owner.publicKey, 'base64'))}`;

// const createdPublicKey = utils.PublicKey.from(publicKeyString);
// // const createdPublicKey = utils.PublicKey.from(publicKeyString);

// const stringified = JSON.stringify(owner);
// // const stringified = JSON.stringify(owner);

// const verified = createdPublicKey.verify(new Uint8Array(sha256.array(stringified)), Buffer.from(signature, 'base64'));
// // const verified = createdPublicKey.verify(new Uint8Array(sha256.array(stringified)), Buffer.from(signature, 'base64'));

return false;
};
// return false;
// };

0 comments on commit 8b97c5f

Please sign in to comment.