Skip to content

Commit

Permalink
fix(wallet): Proper check of tx result after signing (#4328)
Browse files Browse the repository at this point in the history
* fix(wallet): Proper check of rx result after signing

* chore: Update wallet e2e tests

* chore: better tests

* add sleep
  • Loading branch information
marc2332 authored and begonaalvarezd committed Dec 4, 2024
1 parent 1419770 commit 64a147f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/wallet/src/background/Transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Transactions {
if (!txResult) {
throw new Error('Sign message result is empty');
}
if (!('messageBytes' in txResult)) {
if (!('bytes' in txResult)) {
throw new Error('Sign message error, unknown result');
}
return txResult as IotaSignPersonalMessageOutput;
Expand Down
38 changes: 38 additions & 0 deletions apps/wallet/tests/sites-to-cs-api.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) Mysten Labs, Inc.
// Modifications Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { type Page } from '@playwright/test';
import { expect, test } from './fixtures';
import { createWallet } from './utils/auth';
import { demoDappConnect } from './utils/dapp-connect';
import dotenv from 'dotenv';

dotenv.config();

test.beforeEach(async ({ page, extensionUrl }) => {
await createWallet(page, extensionUrl);
await page.close();
});

test.describe('Wallet API', () => {
let demoPage: Page;

test.beforeEach(async ({ context, demoPageUrl }) => {
demoPage = await context.newPage();
await demoPage.goto(demoPageUrl);
await demoDappConnect(demoPage, demoPageUrl, context);
});
test('signing message works', async ({ context }) => {
const newPage = context.waitForEvent('page');
await demoPage.getByRole('button', { name: 'Sign message' }).click();
const walletPage = await newPage;
await walletPage
.getByRole('button', {
name: 'Sign',
})
.click();
await demoPage.waitForTimeout(3000);
await expect(demoPage.getByText('Error')).toHaveCount(0);
});
});
12 changes: 11 additions & 1 deletion apps/wallet/tests/sites-to-cs-messaging.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ test.describe('Wallet interface', () => {
await demoPage.getByRole('button', { name: 'Sign transaction' }).click();
await expect(demoPage.getByText('Error')).toBeVisible();
});
test('signing a message', async () => {
test('signing a message fails', async () => {
await demoPage.getByRole('button', { name: 'Sign message' }).click();
await expect(demoPage.getByText('Error')).toBeVisible();
});
Expand All @@ -150,6 +150,16 @@ test.describe('Wallet interface', () => {
await expect(approve).toBeVisible();
await expect(approve).toBeEnabled();
});
test('signing message works', async ({ context }) => {
const newPage = context.waitForEvent('page');
await demoPage.getByRole('button', { name: 'Sign message' }).click();
const walletPage = await newPage;
const sign = walletPage.getByRole('button', {
name: 'Sign',
});
await expect(sign).toBeVisible();
await expect(sign).toBeEnabled();
});
test.describe('and using wrong account', () => {
test.beforeEach(async () => {
await demoPage.getByLabel('Use wrong account').check();
Expand Down

0 comments on commit 64a147f

Please sign in to comment.