From c1e311860689514be2c2e939962436688492f4ac Mon Sep 17 00:00:00 2001 From: Nabin Kawan Date: Thu, 6 Jun 2024 15:51:20 +0545 Subject: [PATCH 1/2] chore: Replace hardcoded dRep registration amount with protocol params --- .../playwright/lib/services/kuberService.ts | 10 ++++++++-- tests/govtool-frontend/playwright/lib/types.ts | 5 +++++ tests/govtool-frontend/playwright/tests/dRep.setup.ts | 9 ++++++++- .../govtool-frontend/playwright/tests/faucet.setup.ts | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/services/kuberService.ts b/tests/govtool-frontend/playwright/lib/services/kuberService.ts index 51b9cf740..ac6ff8942 100644 --- a/tests/govtool-frontend/playwright/lib/services/kuberService.ts +++ b/tests/govtool-frontend/playwright/lib/services/kuberService.ts @@ -1,5 +1,5 @@ import { faucetWallet } from "@constants/staticWallets"; -import { KuberValue, StaticWallet } from "@types"; +import { KuberValue, QueryProtocolParams, StaticWallet } from "@types"; import * as blake from "blakejs"; import environments from "lib/constants/environments"; import { LockInterceptor, LockInterceptorInfo } from "lib/lockInterceptor"; @@ -168,7 +168,9 @@ const kuberService = { return kuber.signAndSubmitTx(req); }, - multipleTransferADA: (outputs: { address: string; value: string }[]) => { + multipleTransferADA: ( + outputs: { address: string; value: string | number }[] + ) => { const kuber = new Kuber(faucetWallet.address, faucetWallet.payment.private); const req = { outputs, @@ -326,6 +328,10 @@ const kuberService = { >; }, + queryProtocolParams() { + return callKuber("/api/v3/protocol-params") as Promise; + }, + voteOnProposal( addr: string, signingKey: string, diff --git a/tests/govtool-frontend/playwright/lib/types.ts b/tests/govtool-frontend/playwright/lib/types.ts index db1b932d0..2b6d24545 100644 --- a/tests/govtool-frontend/playwright/lib/types.ts +++ b/tests/govtool-frontend/playwright/lib/types.ts @@ -92,3 +92,8 @@ export type IDRep = { latestTxHash: string; latestRegistrationDate: string; }; + +export type QueryProtocolParams = { + dRepDeposit: number; + govActionDeposit: number; +}; diff --git a/tests/govtool-frontend/playwright/tests/dRep.setup.ts b/tests/govtool-frontend/playwright/tests/dRep.setup.ts index 0fa9a07c2..773591151 100644 --- a/tests/govtool-frontend/playwright/tests/dRep.setup.ts +++ b/tests/govtool-frontend/playwright/tests/dRep.setup.ts @@ -10,6 +10,13 @@ import walletManager from "lib/walletManager"; const REGISTER_DREP_WALLETS_COUNT = 9; const DREP_WALLETS_COUNT = 9; +let dRepDeposit: number; + +setup.beforeAll(async () => { + const res = await kuberService.queryProtocolParams(); + dRepDeposit = res.dRepDeposit; +}); + setup.beforeEach(async () => { await setAllureEpic("Setup"); await setAllureStory("Register DRep"); @@ -64,7 +71,7 @@ setup("Setup temporary DRep wallets", async () => { // transfer 600 ADA for dRep registration const amountOutputs = registerDRepWallets.map((wallet) => { - return { address: wallet.address, value: `${600}A` }; + return { address: wallet.address, value: dRepDeposit }; }); const transferRes = await kuberService.multipleTransferADA(amountOutputs); await pollTransaction(transferRes.txId, transferRes.lockInfo); diff --git a/tests/govtool-frontend/playwright/tests/faucet.setup.ts b/tests/govtool-frontend/playwright/tests/faucet.setup.ts index bd20cba9a..2b872e8af 100644 --- a/tests/govtool-frontend/playwright/tests/faucet.setup.ts +++ b/tests/govtool-frontend/playwright/tests/faucet.setup.ts @@ -15,7 +15,7 @@ setup.beforeEach(async () => { setup("Faucet setup", async () => { const balance = await kuberService.getBalance(faucetWallet.address); - if (balance > 1_00_000) return; + if (balance > 100_000) return; const res = await loadAmountFromFaucet(faucetWallet.address); await pollTransaction(res.txid); From 0e350eae13ecc23b20c2f2d77d48f22f1b1afeb7 Mon Sep 17 00:00:00 2001 From: Nabin Kawan Date: Wed, 12 Jun 2024 13:25:44 +0545 Subject: [PATCH 2/2] chore: Update protocol params type to 'ProtocolParams' --- .../govtool-frontend/playwright/lib/services/kuberService.ts | 4 ++-- tests/govtool-frontend/playwright/lib/types.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/govtool-frontend/playwright/lib/services/kuberService.ts b/tests/govtool-frontend/playwright/lib/services/kuberService.ts index ac6ff8942..c0d4acf35 100644 --- a/tests/govtool-frontend/playwright/lib/services/kuberService.ts +++ b/tests/govtool-frontend/playwright/lib/services/kuberService.ts @@ -1,5 +1,5 @@ import { faucetWallet } from "@constants/staticWallets"; -import { KuberValue, QueryProtocolParams, StaticWallet } from "@types"; +import { KuberValue, ProtocolParams, StaticWallet } from "@types"; import * as blake from "blakejs"; import environments from "lib/constants/environments"; import { LockInterceptor, LockInterceptorInfo } from "lib/lockInterceptor"; @@ -329,7 +329,7 @@ const kuberService = { }, queryProtocolParams() { - return callKuber("/api/v3/protocol-params") as Promise; + return callKuber("/api/v3/protocol-params") as Promise; }, voteOnProposal( diff --git a/tests/govtool-frontend/playwright/lib/types.ts b/tests/govtool-frontend/playwright/lib/types.ts index 2b6d24545..765c955e7 100644 --- a/tests/govtool-frontend/playwright/lib/types.ts +++ b/tests/govtool-frontend/playwright/lib/types.ts @@ -93,7 +93,7 @@ export type IDRep = { latestRegistrationDate: string; }; -export type QueryProtocolParams = { +export type ProtocolParams = { dRepDeposit: number; govActionDeposit: number; };