test(taproot): verify address generated is correct

This commit is contained in:
kyranjamie
2023-05-19 10:48:36 +02:00
committed by kyranjamie
parent 11f9461a68
commit 79b2ce8534
8 changed files with 45 additions and 17 deletions

View File

@@ -25,6 +25,7 @@ export const test = base.extend<TestFixtures>({
const pathToExtension = path.join(__dirname, '../../dist');
const context = await chromium.launchPersistentContext('', {
headless: false,
permissions: ['clipboard-read'],
args: [
`--disable-extensions-except=${pathToExtension}`,
`--load-extension=${pathToExtension}`,

View File

@@ -1,4 +1,8 @@
export const TEST_ACCOUNT_1_BTC_ADDRESS = 'bc1qhdykvr9eafepm9cf6aryk0stmmwpv4wws9raj5';
export const TEST_ACCOUNT_1_NATIVE_SEGWIT_ADDRESS = 'bc1qhdykvr9eafepm9cf6aryk0stmmwpv4wws9raj5';
export const TEST_ACCOUNT_1_TAPROOT_ADDRESS =
'bc1plpvrq9f8mdh0ug4984kmdx4gv5nztypxktyemlc89uyqnlu3gwkq35e5pv';
// export const TEST_TESTNET_ACCOUNT_1_BTC_ADDRESS = 'tb1q3c7zyg58dd9hy07m77dv8es9vnpk8xad0yaw8y'
export const TEST_ACCOUNT_1_STX_ADDRESS = 'SP297VG59W96DPGBT13SGD542QE1XS954X78Z75G0';
// export const TEST_ACCOUNT_1_PUBKEY =

View File

@@ -32,15 +32,23 @@ export class HomePage {
// Also, an open issue to consistently determine `isMac` in the workaround:
// https://github.com/microsoft/playwright/issues/12168
// Using the `Receive` route to get the account address for now.
async getReceiveBtcAddress() {
async getReceiveNativeSegwitAddress() {
await this.goToReceiveModal();
await this.page.getByTestId(HomePageSelectors.ReceiveBtcQrCodeBtn).click();
await this.page.getByTestId(HomePageSelectors.ReceiveBtcNativeSegwitQrCodeBtn).click();
const displayerAddress = await this.page
.getByTestId(SharedComponentsSelectors.AddressDisplayer)
.innerText();
return displayerAddress.replaceAll('\n', '');
}
// Currently under Ordinals receive flow
async getReceiveTaprootAddress() {
await this.goToReceiveModal();
await this.page.getByTestId(HomePageSelectors.ReceiveBtcTaprootQrCodeBtn).click();
await this.page.getByRole('button', { name: 'Copy address' }).click();
return this.page.evaluate('navigator.clipboard.readText()');
}
async getReceiveStxAddress() {
await this.goToReceiveModal();
await this.page.getByTestId(HomePageSelectors.ReceiveStxQrCodeBtn).click();

View File

@@ -2,7 +2,8 @@ export enum HomePageSelectors {
DrawerHeaderActionBtn = 'drawer-header-action-btn',
HomePageContainer = 'home-page-container',
ReceiveCryptoAssetBtn = 'receive-crypto-asset-btn',
ReceiveBtcQrCodeBtn = 'receive-btc-qr-code-btn',
ReceiveBtcNativeSegwitQrCodeBtn = 'receive-native-segwit-qr-code-btn',
ReceiveBtcTaprootQrCodeBtn = 'receive-taproot-qr-code-btn',
ReceiveStxQrCodeBtn = 'receive-stx-qr-code-btn',
SendCryptoAssetBtn = 'send-crypto-asset-btn',
}

View File

@@ -1,4 +1,8 @@
import { TEST_ACCOUNT_1_BTC_ADDRESS, TEST_ACCOUNT_1_STX_ADDRESS } from '@tests/mocks/constants';
import {
TEST_ACCOUNT_1_NATIVE_SEGWIT_ADDRESS,
TEST_ACCOUNT_1_STX_ADDRESS,
TEST_ACCOUNT_1_TAPROOT_ADDRESS,
} from '@tests/mocks/constants';
import { test } from '../../fixtures/fixtures';
@@ -8,15 +12,22 @@ test.describe('onboarding existing user', () => {
await onboardingPage.signInExistingUser();
});
test('that restoring a wallet generates the correct bitcoin segwit address', async ({
homePage,
}) => {
const testAddress = await homePage.getReceiveBtcAddress();
test.expect(testAddress).toEqual(TEST_ACCOUNT_1_BTC_ADDRESS);
test.describe('Bitcoin', () => {
test('that the wallet generates the correct Native Segwit address', async ({ homePage }) => {
const nativeSegwitAddress = await homePage.getReceiveNativeSegwitAddress();
test.expect(nativeSegwitAddress).toEqual(TEST_ACCOUNT_1_NATIVE_SEGWIT_ADDRESS);
});
test('that the wallet generates the correct Taproot address', async ({ homePage }) => {
const taprootAddress = await homePage.getReceiveTaprootAddress();
test.expect(taprootAddress).toEqual(TEST_ACCOUNT_1_TAPROOT_ADDRESS);
});
});
test('that restoring a wallet generates the correct stacks address', async ({ homePage }) => {
const testAddress = await homePage.getReceiveStxAddress();
test.expect(testAddress).toEqual(TEST_ACCOUNT_1_STX_ADDRESS);
test.describe('Stacks', () => {
test('that restoring a wallet generates the correct stacks address', async ({ homePage }) => {
const stacksAddress = await homePage.getReceiveStxAddress();
test.expect(stacksAddress).toEqual(TEST_ACCOUNT_1_STX_ADDRESS);
});
});
});