Skip to content

Commit 6f80494

Browse files
authored
Merge pull request #2964 from IntersectMBO/feat/merge-utxos-on-faucet-refund
Feat: merge utxos on faucet refund
2 parents 93ca8ff + aa84b57 commit 6f80494

File tree

3 files changed

+51
-11
lines changed

3 files changed

+51
-11
lines changed

tests/govtool-frontend/playwright/lib/constants/staticWallets.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const staticWallets: StaticWallet[] = require("../_mock/wallets.json");
22
import { StaticWallet } from "@types";
3+
import { proposalFaucetWallet } from "./proposalFaucetWallet";
34
export const faucetWallet = staticWallets[0];
45

56
export const dRep01Wallet = staticWallets[1];
@@ -37,4 +38,21 @@ export const userWallets = [user01Wallet];
3738

3839
export const dRepWallets = [dRep01Wallet, dRep02Wallet];
3940

40-
export const proposalWallets = [proposal01Wallet];
41+
export const proposalWallets = [
42+
proposal01Wallet,
43+
proposal02Wallet,
44+
proposal03Wallet,
45+
proposal04Wallet,
46+
proposal05Wallet,
47+
proposal06Wallet,
48+
proposal07Wallet,
49+
];
50+
51+
export const allStaticWallets = [
52+
...dRepWallets,
53+
...adaHolderWallets,
54+
user01Wallet,
55+
...proposalWallets,
56+
faucetWallet,
57+
proposalFaucetWallet,
58+
];

tests/govtool-frontend/playwright/lib/services/kuberService.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import fetch, { BodyInit, RequestInit } from "node-fetch";
1212
import { cborxEncoder } from "@helpers/encodeDecode";
1313
import { Logger } from "@helpers/logger";
1414
import { blockfrostSubmitTransaction } from "@services/blockfrostService";
15+
import { proposalFaucetWallet } from "@constants/proposalFaucetWallet";
1516

1617
type CertificateType = "registerstake" | "registerdrep" | "deregisterdrep";
1718

@@ -161,6 +162,25 @@ const kuberService = {
161162
certificates,
162163
});
163164
},
165+
mergeUtXos: (wallets: StaticWallet[]) => {
166+
const kuber = new Kuber(
167+
proposalFaucetWallet.address,
168+
proposalFaucetWallet.payment.private
169+
);
170+
const selections = wallets.map((wallet) => ({
171+
type: "PaymentSigningKeyShelley_ed25519",
172+
description: "Payment Signing Key",
173+
cborHex: "5820" + wallet.payment.private,
174+
}));
175+
176+
const inputs = wallets.map((wallet) => wallet.address);
177+
return kuber.signAndSubmitTx({
178+
inputs,
179+
selections,
180+
changeAddress: proposalFaucetWallet.address,
181+
});
182+
},
183+
164184
transferADA: (receiverAddressList: string[], ADA = 20) => {
165185
const kuber = new Kuber(faucetWallet.address, faucetWallet.payment.private);
166186
const req = {

tests/govtool-frontend/playwright/tests/faucet.teardown.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import environments from "@constants/environments";
2-
import { faucetWallet } from "@constants/staticWallets";
2+
import { allStaticWallets } from "@constants/staticWallets";
33
import { setAllureEpic, setAllureStory } from "@helpers/allure";
44
import { skipIfMainnet } from "@helpers/cardano";
55
import { pollTransaction } from "@helpers/transaction";
66
import { test as cleanup, expect } from "@playwright/test";
77
import kuberService from "@services/kuberService";
8+
import { StaticWallet } from "@types";
9+
import walletManager from "lib/walletManager";
810

911
cleanup.describe.configure({ timeout: environments.txTimeOut });
1012
cleanup.beforeEach(async () => {
@@ -14,16 +16,16 @@ cleanup.beforeEach(async () => {
1416
});
1517

1618
cleanup("Refund faucet", async () => {
19+
const registerDRepWallets: StaticWallet[] =
20+
await walletManager.readWallets("registerDRepCopy");
21+
const registeredDRepWallets: StaticWallet[] =
22+
await walletManager.readWallets("registeredDRepCopy");
1723
try {
18-
const faucetRemainingBalance = await kuberService.getBalance(
19-
faucetWallet.address
20-
);
21-
22-
const transferBalance = Math.floor(faucetRemainingBalance) - 3;
23-
const { txId, lockInfo } = await kuberService.transferADA(
24-
[environments.faucet.address],
25-
transferBalance
26-
);
24+
const { txId, lockInfo } = await kuberService.mergeUtXos([
25+
...allStaticWallets,
26+
...registerDRepWallets,
27+
...registeredDRepWallets,
28+
]);
2729
await pollTransaction(txId, lockInfo);
2830
} catch (err) {
2931
console.log(err);

0 commit comments

Comments
 (0)