Skip to content

Commit

Permalink
Merge pull request #1166 from IntersectMBO/enhancement/local-development
Browse files Browse the repository at this point in the history
Enhance flexibility for local development
  • Loading branch information
NabinKawan authored Jun 5, 2024
2 parents 97fc12d + c2b3c7e commit bd9ce30
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 56 deletions.
53 changes: 0 additions & 53 deletions tests/govtool-frontend/playwright/global-setup.ts

This file was deleted.

6 changes: 5 additions & 1 deletion tests/govtool-frontend/playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import environments from "lib/constants/environments";
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
globalSetup: environments.ci ? require.resolve("./global-setup.ts") : "",
testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
Expand Down Expand Up @@ -44,13 +43,18 @@ export default defineConfig({
name: "auth setup",
testMatch: "**/auth.setup.ts",
},
{
name: "faucet setup",
testMatch: "**/faucet.setup.ts",
},
{
name: "dRep setup",
testMatch: "**/dRep.setup.ts",
},
{
name: "wallet bootstrap",
testMatch: "**/wallet.bootstrap.ts",
dependencies: !environments.ci ? ["faucet setup"] : [],
},
{
name: "transaction",
Expand Down
47 changes: 46 additions & 1 deletion tests/govtool-frontend/playwright/tests/dRep.setup.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
import environments from "@constants/environments";
import { dRepWallets } from "@constants/staticWallets";
import { setAllureEpic, setAllureStory } from "@helpers/allure";
import { ShelleyWallet } from "@helpers/crypto";
import { pollTransaction } from "@helpers/transaction";
import { expect, test as setup } from "@playwright/test";
import kuberService from "@services/kuberService";
import walletManager from "lib/walletManager";

setup.describe.configure({ timeout: environments.txTimeOut });
const REGISTER_DREP_WALLETS_COUNT = 9;
const DREP_WALLETS_COUNT = 9;

setup.beforeEach(async () => {
await setAllureEpic("Setup");
await setAllureStory("Register DRep");
});

async function generateWallets(num: number) {
return await Promise.all(
Array.from({ length: num }, () =>
ShelleyWallet.generate().then((wallet) => wallet.json())
)
);
}

setup("Register DRep of static wallets", async () => {
setup.setTimeout(environments.txTimeOut);

try {
const res = await kuberService.multipleDRepRegistration(dRepWallets);

Expand All @@ -28,3 +41,35 @@ setup("Register DRep of static wallets", async () => {
}
}
});

setup("Setup temporary DRep wallets", async () => {
setup.setTimeout(3 * environments.txTimeOut);

const dRepWallets = await generateWallets(DREP_WALLETS_COUNT);
const registerDRepWallets = await generateWallets(
REGISTER_DREP_WALLETS_COUNT
);

// initialize wallets
const initializeRes = await kuberService.initializeWallets([
...dRepWallets,
...registerDRepWallets,
]);
await pollTransaction(initializeRes.txId, initializeRes.lockInfo);

// register dRep
const registrationRes =
await kuberService.multipleDRepRegistration(dRepWallets);
await pollTransaction(registrationRes.txId, registrationRes.lockInfo);

// transfer 600 ADA for dRep registration
const amountOutputs = registerDRepWallets.map((wallet) => {
return { address: wallet.address, value: `${600}A` };
});
const transferRes = await kuberService.multipleTransferADA(amountOutputs);
await pollTransaction(transferRes.txId, transferRes.lockInfo);

// save to file
await walletManager.writeWallets(dRepWallets, "registeredDRep");
await walletManager.writeWallets(registerDRepWallets, "registerDRep");
});
22 changes: 22 additions & 0 deletions tests/govtool-frontend/playwright/tests/faucet.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import environments from "@constants/environments";
import { faucetWallet } from "@constants/staticWallets";
import { setAllureEpic, setAllureStory } from "@helpers/allure";
import { pollTransaction } from "@helpers/transaction";
import { test as setup } from "@playwright/test";
import { loadAmountFromFaucet } from "@services/faucetService";
import kuberService from "@services/kuberService";

setup.describe.configure({ timeout: environments.txTimeOut });

setup.beforeEach(async () => {
await setAllureEpic("Setup");
await setAllureStory("Faucet");
});

setup("Faucet setup", async () => {
const balance = await kuberService.getBalance(faucetWallet.address);
if (balance > 10000) return;

const res = await loadAmountFromFaucet(faucetWallet.address);
await pollTransaction(res.txid);
});
3 changes: 2 additions & 1 deletion tests/govtool-frontend/playwright/tests/wallet.bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { adaHolderWallets, dRepWallets } from "@constants/staticWallets";
import { setAllureEpic } from "@helpers/allure";
import { setAllureEpic, setAllureStory } from "@helpers/allure";
import { pollTransaction } from "@helpers/transaction";
import { expect, test as setup } from "@playwright/test";
import kuberService from "@services/kuberService";
Expand All @@ -9,6 +9,7 @@ setup.describe.configure({ mode: "serial", timeout: environments.txTimeOut });

setup.beforeEach(async () => {
await setAllureEpic("Setup");
await setAllureStory("Wallet bootstrap");
});

setup("Initialize static wallets", async () => {
Expand Down

0 comments on commit bd9ce30

Please sign in to comment.