Skip to content

LW-9422 Conway era cherry pick #1180

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

Merged
merged 3 commits into from
Apr 3, 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
10 changes: 3 additions & 7 deletions packages/cardano-services/test/jest-setup/rebuild-test-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@ yarn workspace @cardano-sdk/e2e local-network:down
yarn workspace @cardano-sdk/e2e local-network:up -d --build
yarn workspace @cardano-sdk/e2e wait-for-network

TEST1="yarn workspace @cardano-sdk/e2e test:wallet"
TEST2="yarn workspace @cardano-sdk/e2e test:long-running delegation-rewards.test.ts"
TEST3="yarn workspace @cardano-sdk/e2e test:local-network register-pool.test.ts"

for test in "$TEST1" "$TEST2" "$TEST3"; do
while ! $test; do echo repeating...; done
done
yarn workspace @cardano-sdk/e2e test:wallet
yarn workspace @cardano-sdk/e2e test:long-running simple-delegation-rewards.test.ts
yarn workspace @cardano-sdk/e2e test:local-network register-pool.test.ts

TL_LEVEL="${TL_LEVEL:=info}" node "$SCRIPT_DIR/mint-handles.js"

Expand Down
16 changes: 12 additions & 4 deletions packages/e2e/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,8 @@ export const txConfirmed = (
SYNC_TIMEOUT_DEFAULT / 5
);

const submit = (wallet: ObservableWallet, tx: Cardano.Tx) => wallet.submitTx(tx);
const confirm = (wallet: ObservableWallet, tx: Cardano.Tx) => txConfirmed(wallet, tx);
export const submitAndConfirm = (wallet: ObservableWallet, tx: Cardano.Tx) =>
Promise.all([submit(wallet, tx), confirm(wallet, tx)]);
export const submitAndConfirm = (wallet: ObservableWallet, tx: Cardano.Tx, numConfirmations?: number) =>
Promise.all([wallet.submitTx(tx), txConfirmed(wallet, tx, numConfirmations)]);

export type RequestCoinsProps = {
wallet: ObservableWallet;
Expand Down Expand Up @@ -293,3 +291,13 @@ export const burnTokens = async ({
await submitAndConfirm(wallet, signedTx);
await txConfirmed(wallet, signedTx);
};

export const unDelegateWallet = async (wallet: BaseWallet) => {
const rewardAccounts = await firstValueFrom(wallet.delegation.rewardAccounts$);

if (!rewardAccounts.some((acct) => acct.credentialStatus === Cardano.StakeCredentialStatus.Unregistered)) {
const { tx } = await wallet.createTxBuilder().delegatePortfolio(null).build().sign();

await submitAndConfirm(wallet, tx, 1);
}
};
3 changes: 3 additions & 0 deletions packages/e2e/test/local-network/register-pool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getEnv,
getWallet,
submitCertificate,
unDelegateWallet,
waitForWalletStateSettle,
walletReady,
walletVariables
Expand Down Expand Up @@ -74,6 +75,8 @@ describe('local-network/register-pool', () => {
wallet2.wallet.shutdown();
});

beforeEach(() => unDelegateWallet(wallet1.wallet));

test('does not meet pledge', async () => {
const wallet = wallet1.wallet;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const getPoolIds = async (stakePoolProvider: StakePoolProvider, count: number) =
return poolIds;
};

describe('delegation rewards', () => {
describe('shared wallet delegation rewards', () => {
let fundingTx: Cardano.Tx<Cardano.TxBody>;
let faucetWallet: BaseWallet;
let faucetAddress: Cardano.PaymentAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const getPoolIds = async (stakePoolProvider: StakePoolProvider, count: number) =
return poolIds;
};

describe('delegation rewards', () => {
describe('simple delegation rewards', () => {
let providers: TestWallet['providers'];
let wallet1: BaseWallet;
let wallet2: BaseWallet;
Expand Down