From b980db76668c4298a10bc4ea83ebbd205eb61246 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 6 May 2025 11:26:27 +0545 Subject: [PATCH 1/4] feat: add wallet generation script for faucet --- .../playwright/generate_faucet_wallet.ts | 30 +++++++++++++++++++ .../govtool-frontend/playwright/package.json | 3 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/govtool-frontend/playwright/generate_faucet_wallet.ts diff --git a/tests/govtool-frontend/playwright/generate_faucet_wallet.ts b/tests/govtool-frontend/playwright/generate_faucet_wallet.ts new file mode 100644 index 000000000..0fd3fbe60 --- /dev/null +++ b/tests/govtool-frontend/playwright/generate_faucet_wallet.ts @@ -0,0 +1,30 @@ +import { ShelleyWallet } from "./lib/helpers/crypto"; + +(async () => { + try { + console.log("\nGenerating your wallet... ๐Ÿ”"); + const wallet = await ShelleyWallet.generate(); + const walletJson = wallet.json(); + + // Display wallet details + console.log("\n๐ŸŽ‰ Wallet generated successfully!"); + console.log("-----------------------------------"); + console.log("๐Ÿ’ผ Wallet:", walletJson); + console.log(`๐Ÿ”‘ Payment Private Key: ${walletJson.payment.private}`); + console.log(`๐Ÿ”— Stake Public Key Hash: ${walletJson.stake.pkh}`); + console.log(`๐Ÿ  Wallet Address: ${walletJson.address}`); + console.log("-----------------------------------"); + + // Instructions for environment variables + console.log( + "\n๐Ÿ“‹ Please copy the following to your environment variables:" + ); + console.log(`1. Set FAUCET_PAYMENT_PRIVATE=${walletJson.payment.private}`); + console.log(`2. Set FAUCET_STAKE_PKH=${walletJson.stake.pkh}`); + console.log(`3. Set FAUCET_ADDRESS=${walletJson.address}`); + + console.log("\n๐ŸŽˆ All done! Have fun with your new wallet!"); + } catch (error) { + console.error("\nโŒ An error occurred:", error.message); + } +})(); diff --git a/tests/govtool-frontend/playwright/package.json b/tests/govtool-frontend/playwright/package.json index ae13b722d..62bdac42d 100644 --- a/tests/govtool-frontend/playwright/package.json +++ b/tests/govtool-frontend/playwright/package.json @@ -44,7 +44,8 @@ "test:headless:usersnap": "npx playwright test userSnap.spec.ts", "test:headless:misc": "npx playwright test miscellaneous", "format": "prettier . --write", - "generate-wallets": "ts-node ./generate_wallets.ts 23" + "generate-wallets": "ts-node ./generate_wallets.ts 23", + "generate-faucet-wallet": "ts-node ./generate_faucet_wallet.ts" }, "dependencies": { "@cardanoapi/cardano-test-wallet": "^3.3.1", From 4896bfb1a38a9888045a828b3a7712f86a529731 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 6 May 2025 11:26:43 +0545 Subject: [PATCH 2/4] feat: add faucet wallet generation instructions to README --- tests/govtool-frontend/playwright/README.md | 65 ++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/tests/govtool-frontend/playwright/README.md b/tests/govtool-frontend/playwright/README.md index d7a7cc123..36d99abee 100644 --- a/tests/govtool-frontend/playwright/README.md +++ b/tests/govtool-frontend/playwright/README.md @@ -77,13 +77,76 @@ npx playwright install 3. Navigate to **API Keys**. 4. Click to **Generate API Key**. +--- + +## ๐Ÿ”ง Faucet wallet Configuration + +This section guides you through generating a Cardano faucet wallet and configuring it for use. Follow the steps below to create and set the config on env + +### Step 1: Generate a Faucet Wallet + +Run the following command to generate a new faucet wallet: + +```bash +npm run generate-faucet-wallet +``` + +The script will: +- Display the wallet details (payment private key, stake public key hash, and wallet address) in the terminal. + +**Example Output:** +``` +๐ŸŽ‰ Wallet generated successfully! +----------------------------------- +๐Ÿ”‘ Payment Private Key: +๐Ÿ”— Stake Public Key Hash: +๐Ÿ  Wallet Address: +----------------------------------- + +๐Ÿ“‹ Please copy the following to your environment variables: +1. Set FAUCET_PAYMENT_PRIVATE= +2. Set FAUCET_STAKE_PKH= +3. Set FAUCET_ADDRESS= + +๐ŸŽˆ All done! Have fun with your new wallet! +``` + +### Step 2: Configure Environment Variables + +Securely store the generated wallet details in your environment variables. Add the following to your `.env` file or environment configuration: + +```env +FAUCET_PAYMENT_PRIVATE= +FAUCET_STAKE_PKH= +FAUCET_ADDRESS= +``` + +โš ๏ธ **Security Note**: Store your wallet details in a secure location for future use. The payment private key is sensitive and must be protected to prevent unauthorized access to your funds. + +### Step 3: Fund the Wallet + +Ensure the wallet address has sufficient funds for your test runs. The required balance depends on the specific tests you plan to execute (refer to the test-specific test run details below). + +To check the wallet balance, visit: + +``` +https://${network}.cardanoscan.io/address/ +``` + +Replace `${network}` with the appropriate Cardano network (e.g.`preprod`, or `preview`) and `` with the generated address. + +**Example**: +- For a preview wallet: `https://preview.cardanoscan.io/address/` +- Monitor the balance to ensure it meets the requirements for individual or all test runs. + + --- ## ๐Ÿงช Running Tests ### ๐Ÿ”‘ Generate Test Wallets -Before each test run, generate fresh test wallets to avoid conflicts: +Before each test run, generate test wallets which is required for wallet dependent test: ```bash npm run generate-wallets From 72417435dd3f40d2974c33ca5f1cc88641d6a511 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 6 May 2025 11:33:53 +0545 Subject: [PATCH 3/4] fix: update README for generation of test wallets and correct singular terms --- tests/govtool-frontend/playwright/README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/govtool-frontend/playwright/README.md b/tests/govtool-frontend/playwright/README.md index 36d99abee..efebb147d 100644 --- a/tests/govtool-frontend/playwright/README.md +++ b/tests/govtool-frontend/playwright/README.md @@ -92,9 +92,11 @@ npm run generate-faucet-wallet ``` The script will: + - Display the wallet details (payment private key, stake public key hash, and wallet address) in the terminal. **Example Output:** + ``` ๐ŸŽ‰ Wallet generated successfully! ----------------------------------- @@ -136,17 +138,17 @@ https://${network}.cardanoscan.io/address/ Replace `${network}` with the appropriate Cardano network (e.g.`preprod`, or `preview`) and `` with the generated address. **Example**: + - For a preview wallet: `https://preview.cardanoscan.io/address/` - Monitor the balance to ensure it meets the requirements for individual or all test runs. - --- ## ๐Ÿงช Running Tests ### ๐Ÿ”‘ Generate Test Wallets -Before each test run, generate test wallets which is required for wallet dependent test: +Before each test run, generate test wallets required for wallet-dependent tests: ```bash npm run generate-wallets @@ -178,7 +180,7 @@ Each test suite can be run in **UI** or **Headless** mode. --- -#### 1. **Delegation Pillars** +#### 1. **Delegation Pillar** - **Pre-requisite**: Ensure the faucet address holds at least **12,000 ADA**. @@ -196,7 +198,7 @@ npm run test:headless:delegation-pillar --- -#### 2. **Voting Pillars** +#### 2. **Voting Pillar** - **Pre-requisite**: Ensure the faucet address holds at least **12,000 ADA**. @@ -230,7 +232,7 @@ npm run test:headless:outcomes --- -#### 4. **Proposal Pillars** +#### 4. **Proposal Pillar** _Includes both Proposal Discussion and Budget Discussion_ From 04918ab6cfe70976512b562b57520696b33872f1 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 6 May 2025 15:49:29 +0545 Subject: [PATCH 4/4] chore: update generate faucet wallet success message --- tests/govtool-frontend/playwright/README.md | 2 +- tests/govtool-frontend/playwright/generate_faucet_wallet.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/govtool-frontend/playwright/README.md b/tests/govtool-frontend/playwright/README.md index efebb147d..567219012 100644 --- a/tests/govtool-frontend/playwright/README.md +++ b/tests/govtool-frontend/playwright/README.md @@ -110,7 +110,7 @@ The script will: 2. Set FAUCET_STAKE_PKH= 3. Set FAUCET_ADDRESS= -๐ŸŽˆ All done! Have fun with your new wallet! +๐ŸŽˆ All set! Please ensure this wallet is funded with a sufficient balance ``` ### Step 2: Configure Environment Variables diff --git a/tests/govtool-frontend/playwright/generate_faucet_wallet.ts b/tests/govtool-frontend/playwright/generate_faucet_wallet.ts index 0fd3fbe60..f29d3bab5 100644 --- a/tests/govtool-frontend/playwright/generate_faucet_wallet.ts +++ b/tests/govtool-frontend/playwright/generate_faucet_wallet.ts @@ -23,7 +23,9 @@ import { ShelleyWallet } from "./lib/helpers/crypto"; console.log(`2. Set FAUCET_STAKE_PKH=${walletJson.stake.pkh}`); console.log(`3. Set FAUCET_ADDRESS=${walletJson.address}`); - console.log("\n๐ŸŽˆ All done! Have fun with your new wallet!"); + console.log( + "\n๐ŸŽˆ All set! Please ensure this wallet is funded with a sufficient balance" + ); } catch (error) { console.error("\nโŒ An error occurred:", error.message); }