Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wsdt/circle ci #19

Merged
merged 25 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
machine:
image: ubuntu-2204:current
resource_class: large
parallelism: 10
parallelism: 1
steps:
- checkout
- docker/install-docker
Expand Down Expand Up @@ -63,14 +63,13 @@ jobs:
- run:
name: Install pnpm
command: |
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
npm i -g yarn pnpm
echo "NPM version: $(npm --version)"
echo "Yarn version: $(yarn --version)"
echo "PNPM version: $(pnpm --version)"
pnpm config set store-dir .pnpm-store

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
npm i -g yarn pnpm
echo "NPM version: $(npm --version)"
echo "Yarn version: $(yarn --version)"
echo "PNPM version: $(pnpm --version)"
pnpm config set store-dir .pnpm-store
- save_cache:
name: Save pnpm Package Cache
key: pnpm-packages-{{ checksum "pnpm-lock.yaml" }}
Expand All @@ -87,19 +86,24 @@ jobs:
command: |
cd ./contracts
pnpm install
- run:
name: Install Playwright Browser Binaries
command: |
cd ./contracts
npx playwright install
- run:
name: Start local environment
command: |
pnpm start:local:ci 2>&1 | tee local_env.log
no_output_timeout: 60m
environment:
PRIVATE_KEY: ${PRIVATE_KEY}
CONRANKING_API_KEY: ${CONRANKING_API_KEY}
COINRANKING_API_KEY: ${COINRANKING_API_KEY}
- run:
name: Run Hardhat tests
name: Run E2E tests
command: |
cd ./contracts
npx hardhat test
npx playwright test ./test/e2e/send-user-op.e2e.test.ts --timeout=600000
environment:
TOKEN_PRICE_CONTRACT: ${TOKEN_PRICE_CONTRACT}
RPC_URL: ${RPC_URL}
Expand Down
3 changes: 2 additions & 1 deletion contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"ts-jest": "^29.2.3",
"ts-node": "^10.9.2",
"typechain": "^8.3.2",
"typescript": "^5.5.3"
"typescript": "^5.5.3",
"@playwright/test": "^1.42.0"
},
"dependencies": {
"@openzeppelin/contracts": "^4.0.2",
Expand Down
1 change: 0 additions & 1 deletion contracts/script/deploy-local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const backendEnvPath = path.resolve(__dirname, "../../backend/.env");
const contractsEnvPath = path.resolve(__dirname, "../.env");
let aaConfigFile = fs.readFileSync('../snap-account-abstraction-keyring/packages/snap/src/constants/aa-config.ts', 'utf8');


// TODO: fix .env file loading. Currently .env needs to be in /script directory
async function main() {
try {
Expand Down
39 changes: 31 additions & 8 deletions contracts/test/e2e/send-user-op.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test } from './wallet-creation';
import {test} from './wallet-creation';
import {sleep} from "@nomicfoundation/hardhat-verify/internal/utilities";
import {ethers} from "ethers";
import {chromium, expect} from "@playwright/test";
import {expect} from "@playwright/test";
import * as http from "http";

const RECOVERY_PHRASE = "test test test test test test test test test test test junk";
Expand Down Expand Up @@ -59,7 +59,9 @@ test('Scramble : Recover existing wallet!', async ({ context, extensionId }) =>
await clickTestIdAndWait(extensionPopup, 'confirmation-submit-button');
await clickTestIdAndWait(extensionPopup, 'confirmation-submit-button');
await clickTestIdAndWait(extensionPopup, 'snap-privacy-warning-scroll');
await clickButtonWithText(extensionPopup, "Akzeptieren");
await sleep(500);
await clickButtonWithClass(extensionPopup, "mm-button-primary");
await sleep(500);
await clickTestIdAndWait(extensionPopup, 'page-container-footer-next');
await clickTestIdAndWait(extensionPopup, 'page-container-footer-next');
await clickTestIdAndWait(extensionPopup, 'page-container-footer-next');
Expand All @@ -85,16 +87,15 @@ test('Scramble : Recover existing wallet!', async ({ context, extensionId }) =>
await clickTestIdAndWait(extensionPopup, 'page-container-footer-next');
await createNewSmartWallet(nP2);

console.log('checkign for addr....')
console.log('checking for addr....')
await sleep(3000);
// confirmation
extensionPopup = context.pages().find(page => page.url().startsWith(`chrome-extension://${extensionId}`));
await clickTestIdAndWait(extensionPopup, 'confirmation-submit-button')
await clickTestIdAndWait(extensionPopup, 'confirmation-submit-button')


const addr = await extractAddress(nP2);
console.log('addr i: ', addr);
console.log('new address created: ', addr);

// Fund the new Smart Account
/** @DEV FUND THE ACCOUNT */
Expand All @@ -121,7 +122,10 @@ test('Scramble : Recover existing wallet!', async ({ context, extensionId }) =>
await clickTestIdAndWait(nP3, 'send-request');

await sleep(5000);
console.log('all pages: ', context.pages().map(b => b.url()));
extensionPopup = context.pages().find(page => page.url().startsWith(`chrome-extension://${extensionId}`));
console.log(await nP3.innerText('#root'));
await sleep(2500);
await clickTestIdAndWait(extensionPopup, 'confirmation-submit-button')
await sleep(5000);
extensionPopup = context.pages().find(page => page.url().startsWith(`chrome-extension://${extensionId}`));
Expand All @@ -139,6 +143,21 @@ export const clickTestIdAndWait = async (page: any, id: string) => {
await sleep(500);
}

export const clickButtonWithClass = async (page: any, buttonClass: string) => {
console.log(`Finding and clicking <button> with class ${buttonClass}`);
const buttonSelector = `button.${buttonClass}`;
const button = await page.$(buttonSelector);
if (button) {
await button.click();
console.log(`Clicked <button> with class ${buttonClass}`);
} else {
console.log(`No <button> found with class ${buttonClass}`);
}
};




export const getPageBy = (pages: any, byName: string) => {
return pages.find((page: any) => page.url().startsWith(`${byName}`));
}
Expand Down Expand Up @@ -173,14 +192,18 @@ export const clickButtonWithText = async (page: any, selector: any) => {
export const createNewSmartWallet = async (page: any) => {
// Locate and click the parent div with the specific class and text
const parentDiv = await page.locator('div.Accordion__AccordionHeader-gECkYS.ddFrHO', { hasText: 'Create account (Deterministic)' });
console.log('clicking create account')
await parentDiv.click();
console.log('clicked')

// After clicking the parent div, locate the content div that appears
const contentDiv = await parentDiv.locator('..').locator('div.Accordion__AccordionContent-czDJDU');

// Locate the button within the content div and click it
const button = await contentDiv.locator('button.Buttons__ActionButton-ixlOMU.hgzfsi', { hasText: 'Create Account' });
console.log('creating account')
await button.click();
console.log('acc created')
}


Expand Down Expand Up @@ -210,10 +233,11 @@ export const fundAddr = async (toAddr: string) => {
}

export const extractAddress = async (page: any) => {
const address = await page.evaluate(() => {
return await page.evaluate(() => {
const div = document.querySelector('.styledComponents__CopyableItemValue-ctKSJz');
if (div) {
try {
console.log('text content: ', div.textContent);
const json = JSON.parse(div.textContent!);
return json.address;
} catch (e) {
Expand All @@ -223,7 +247,6 @@ export const extractAddress = async (page: any) => {
}
return null;
});
return address;
}

async function extractETHPrice(page:any) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/.env-local
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VITE_SMART_CONTRACT=0x5f3f1dbd7b74c6b46e8c44f98792a1daf8d69154
VITE_SMART_CONTRACT=0x1f10f3ba7acb61b2f50b9d6ddcf91a6f787c0e82
VITE_RPC_PROVIDER=http://localhost:9545
VITE_SNAP_ORIGIN=local:http://localhost:8080
VITE_SNAP_VERSION=1.1.3
2 changes: 1 addition & 1 deletion snap-account-abstraction-keyring
Loading