test(governance): governance transfer proposal tests (#5011)
Co-authored-by: daro-maj <119658839+daro-maj@users.noreply.github.com>
This commit is contained in:
parent
852c9bb8f4
commit
58cc074538
@ -24,8 +24,10 @@ NX_SUCCESSOR_MARKETS=true
|
||||
NX_PRODUCT_PERPETUALS=true
|
||||
NX_REFERRALS=true
|
||||
NX_UPDATE_MARKET_STATE=true
|
||||
NX_GOVERNANCE_TRANSFERS=true
|
||||
NX_VOLUME_DISCOUNTS=true
|
||||
|
||||
|
||||
NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf
|
||||
NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn
|
||||
NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/pl/firefox/addon/vega-wallet
|
||||
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
"rationale": {
|
||||
"title": "Governance cancel transfer proposal",
|
||||
"description": "Rejected cancel transfer proposal"
|
||||
},
|
||||
"terms": {
|
||||
"cancelTransfer": {
|
||||
"changes": {
|
||||
"transferId": "invalid transfer id"
|
||||
}
|
||||
},
|
||||
"closingTimestamp": 0,
|
||||
"enactmentTimestamp": 0
|
||||
}
|
||||
}
|
@ -27,12 +27,16 @@ import {
|
||||
} from '../../../../governance-e2e/src/support/staking.functions';
|
||||
import { ethereumWalletConnect } from '../../../../governance-e2e/src/support/wallet-eth.functions';
|
||||
import {
|
||||
depositAsset,
|
||||
switchVegaWalletPubKey,
|
||||
vegaWalletSetSpecifiedApprovalAmount,
|
||||
} from '../../support/wallet-functions';
|
||||
import type { testFreeformProposal } from '../../support/common-interfaces';
|
||||
import { formatDateWithLocalTimezone } from '@vegaprotocol/utils';
|
||||
import { createSuccessorMarketProposalTxBody } from '../../support/proposal.functions';
|
||||
import {
|
||||
createGovernanceTransferProposalTxBody,
|
||||
createSuccessorMarketProposalTxBody,
|
||||
} from '../../support/proposal.functions';
|
||||
|
||||
const proposalListItem = '[data-testid="proposals-list-item"]';
|
||||
const participationNotMet = 'token-participation-not-met';
|
||||
@ -51,6 +55,7 @@ const openProposals = 'open-proposals';
|
||||
const viewProposalButton = 'view-proposal-btn';
|
||||
const proposalTermsToggle = 'proposal-json-toggle';
|
||||
const marketDataToggle = 'proposal-market-data-toggle';
|
||||
const governanceTransferToggle = 'proposal-transfer-details';
|
||||
const marketProposalType = 'proposal-type';
|
||||
|
||||
describe(
|
||||
@ -520,5 +525,78 @@ describe(
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('Able to see governance transfer proposal', function () {
|
||||
const vegaAssetAddress = '0x67175Da1D5e966e40D11c4B2519392B2058373de';
|
||||
depositAsset(vegaAssetAddress, '1000', 18);
|
||||
cy.getByTestId('currency-title', Cypress.env('txTimeout')).should(
|
||||
'contain.text',
|
||||
'Collateral'
|
||||
);
|
||||
cy.VegaWalletTopUpNetworkAccount('100');
|
||||
cy.VegaWalletSubmitProposal(createGovernanceTransferProposalTxBody());
|
||||
cy.reload();
|
||||
getProposalFromTitle('Governance transfer proposal').within(() => {
|
||||
cy.getByTestId(marketProposalType).should('have.text', 'NewTransfer');
|
||||
cy.getByTestId(viewProposalButton).click();
|
||||
});
|
||||
cy.getByTestId(marketProposalType).should('have.text', 'NewTransfer');
|
||||
cy.getByTestId(governanceTransferToggle).click();
|
||||
cy.getByTestId('proposal-transfer-details-table').within(() => {
|
||||
getProposalInformationFromTable('Source Type')
|
||||
.invoke('text')
|
||||
.and('eq', 'Network Treasury');
|
||||
getProposalInformationFromTable('Destination')
|
||||
.invoke('text')
|
||||
.and('eq', Cypress.env('vegaWalletPublicKey'));
|
||||
getProposalInformationFromTable('Asset')
|
||||
.invoke('text')
|
||||
.and('eq', 'VEGA');
|
||||
getProposalInformationFromTable('Fraction Of Balance')
|
||||
.invoke('text')
|
||||
.and('eq', '50%');
|
||||
getProposalInformationFromTable('Amount')
|
||||
.invoke('text')
|
||||
.and('eq', '100.00');
|
||||
getProposalInformationFromTable('Transfer Type')
|
||||
.invoke('text')
|
||||
.and('eq', 'All or nothing');
|
||||
getProposalInformationFromTable('Kind')
|
||||
.invoke('text')
|
||||
.and('eq', 'One off');
|
||||
});
|
||||
});
|
||||
|
||||
it(' Able to see cancel transfer proposal - rejected', function () {
|
||||
const proposalPath = 'src/fixtures/proposals/cancel-transfer-raw.json';
|
||||
const enactmentTimestamp =
|
||||
createTenDigitUnixTimeStampForSpecifiedDays(11);
|
||||
const closingTimestamp = createTenDigitUnixTimeStampForSpecifiedDays(10);
|
||||
submitUniqueRawProposal({
|
||||
proposalBody: proposalPath,
|
||||
enactmentTimestamp: enactmentTimestamp,
|
||||
closingTimestamp: closingTimestamp,
|
||||
submit: false,
|
||||
});
|
||||
cy.getByTestId('proposal-submit').should('be.visible').click();
|
||||
cy.getByTestId('dialog-title').should('have.text', 'Proposal rejected');
|
||||
cy.getByTestId('icon-cross').last().click();
|
||||
navigateTo(navigation.proposals);
|
||||
cy.get('[href="/proposals/rejected"]').click();
|
||||
getProposalFromTitle('Governance cancel transfer proposal').within(() => {
|
||||
cy.getByTestId(marketProposalType).should(
|
||||
'have.text',
|
||||
'CancelTransfer'
|
||||
);
|
||||
cy.getByTestId(viewProposalButton).click();
|
||||
});
|
||||
cy.getByTestId(marketProposalType).should('have.text', 'CancelTransfer');
|
||||
getProposalInformationFromTable('Error details')
|
||||
.invoke('text')
|
||||
.and('eq', 'Governance transfer invalid transfer id not found');
|
||||
getProposalInformationFromTable('transferId')
|
||||
.invoke('text')
|
||||
.and('eq', 'invalid transfer id');
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { addSeconds, millisecondsToSeconds } from 'date-fns';
|
||||
import { addDays, addSeconds, millisecondsToSeconds } from 'date-fns';
|
||||
import type { ProposalSubmissionBody } from '@vegaprotocol/wallet';
|
||||
import { aliasGQLQuery } from '@vegaprotocol/cypress';
|
||||
import { upgradeProposalsData } from '../fixtures/mocks/network-upgrade';
|
||||
import { proposalsData } from '../fixtures/mocks/proposals';
|
||||
import { nodeData } from '../fixtures/mocks/nodes';
|
||||
import { AccountType, GovernanceTransferType } from '@vegaprotocol/types';
|
||||
|
||||
export function createUpdateNetworkProposalTxBody(): ProposalSubmissionBody {
|
||||
const MIN_CLOSE_SEC = 5;
|
||||
@ -358,6 +359,46 @@ export function createSuccessorMarketProposalTxBody(
|
||||
};
|
||||
}
|
||||
|
||||
export function createGovernanceTransferProposalTxBody(): ProposalSubmissionBody {
|
||||
const MIN_CLOSE_SEC = 5;
|
||||
const MIN_ENACT_SEC = 7;
|
||||
|
||||
const closingDate = addDays(new Date(), MIN_CLOSE_SEC);
|
||||
const enactmentDate = addDays(closingDate, MIN_ENACT_SEC);
|
||||
const closingTimestamp = millisecondsToSeconds(closingDate.getTime());
|
||||
const enactmentTimestamp = millisecondsToSeconds(enactmentDate.getTime());
|
||||
const destination = Cypress.env('vegaWalletPublicKey');
|
||||
return {
|
||||
proposalSubmission: {
|
||||
rationale: {
|
||||
title: 'Governance transfer proposal',
|
||||
description: 'E2E test for transfer proposal test',
|
||||
},
|
||||
terms: {
|
||||
newTransfer: {
|
||||
changes: {
|
||||
fractionOfBalance: '0.5',
|
||||
amount: '100' + '0'.repeat(18),
|
||||
sourceType: AccountType.ACCOUNT_TYPE_NETWORK_TREASURY,
|
||||
source: '',
|
||||
transferType:
|
||||
GovernanceTransferType.GOVERNANCE_TRANSFER_TYPE_ALL_OR_NOTHING,
|
||||
destinationType: AccountType.ACCOUNT_TYPE_GENERAL,
|
||||
destination,
|
||||
asset:
|
||||
'b4f2726571fbe8e33b442dc92ed2d7f0d810e21835b7371a7915a365f07ccd9b',
|
||||
oneOff: {
|
||||
deliverOn: '0',
|
||||
},
|
||||
},
|
||||
},
|
||||
closingTimestamp,
|
||||
enactmentTimestamp,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function mockNetworkUpgradeProposal() {
|
||||
cy.mockGQL((req) => {
|
||||
aliasGQLQuery(req, 'Nodes', nodeData);
|
||||
|
@ -41,6 +41,9 @@ export async function depositAsset(
|
||||
) {
|
||||
// Approve asset
|
||||
const faucet = new Token(assetEthAddress, signer);
|
||||
// Wait needed to allow Eth chain to catch up
|
||||
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
||||
cy.wait(4000);
|
||||
cy.wrap(
|
||||
faucet.approve(Erc20BridgeAddress, amount + '0'.repeat(decimalPlaces + 1)),
|
||||
transactionTimeout
|
||||
|
@ -25,6 +25,7 @@ import { addImportNodeWallets } from './lib/commands/import-node-wallets';
|
||||
import { addVegaWalletTopUpRewardsPool } from './lib/commands/vega-wallet-top-up-rewards-pool';
|
||||
import { addAssociateTokensToVegaWallet } from './lib/commands/associate-tokens-to-vega-wallet';
|
||||
import { addMockChainId } from './lib/commands/mock-chain-id';
|
||||
import { addVegaWalletTopUpNetworkAccount } from './lib/commands/vega-wallet-fund-network-account';
|
||||
|
||||
addGetTestIdcommand();
|
||||
addMockGQLCommand();
|
||||
@ -52,6 +53,7 @@ addImportNodeWallets();
|
||||
addVegaWalletTopUpRewardsPool();
|
||||
addAssociateTokensToVegaWallet();
|
||||
addMockChainId();
|
||||
addVegaWalletTopUpNetworkAccount();
|
||||
|
||||
export {
|
||||
mockConnectWallet,
|
||||
|
@ -0,0 +1,41 @@
|
||||
import { AccountType } from '@vegaprotocol/types';
|
||||
import type { TransferBody } from '@vegaprotocol/wallet';
|
||||
import { createWalletClient, sendVegaTx } from '../capsule/wallet-client';
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
interface Chainable<Subject> {
|
||||
VegaWalletTopUpNetworkAccount(amount: string): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function addVegaWalletTopUpNetworkAccount() {
|
||||
Cypress.Commands.add('VegaWalletTopUpNetworkAccount', (amount: string) => {
|
||||
const vegaWalletUrl = Cypress.env('VEGA_WALLET_URL');
|
||||
const token = Cypress.env('VEGA_WALLET_API_TOKEN');
|
||||
const vegaPubKey = Cypress.env('VEGA_PUBLIC_KEY');
|
||||
const assetAddress =
|
||||
'b4f2726571fbe8e33b442dc92ed2d7f0d810e21835b7371a7915a365f07ccd9b';
|
||||
createWalletClient(vegaWalletUrl, token);
|
||||
|
||||
const transactionBody: TransferBody = {
|
||||
transfer: {
|
||||
fromAccountType: AccountType.ACCOUNT_TYPE_GENERAL,
|
||||
toAccountType: AccountType.ACCOUNT_TYPE_NETWORK_TREASURY,
|
||||
to: '0000000000000000000000000000000000000000000000000000000000000000',
|
||||
asset: assetAddress,
|
||||
amount: amount + '0'.repeat(18),
|
||||
oneOff: {
|
||||
deliverOn: 0,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
cy.highlight('Topping network account');
|
||||
|
||||
sendVegaTx(vegaPubKey, transactionBody);
|
||||
});
|
||||
}
|
@ -29,11 +29,6 @@ export function addVegaWalletTopUpRewardsPool() {
|
||||
.then((epochText) => {
|
||||
transferStartEpoch = Number(epochText.replace('Epoch', '')) + 5;
|
||||
transferEndEpoch = transferStartEpoch + 100;
|
||||
|
||||
/* eslint-disable no-console */
|
||||
console.log(transferStartEpoch);
|
||||
console.log(transferEndEpoch);
|
||||
/* eslint-enable */
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
|
@ -235,6 +235,39 @@ interface ProposalUpdateAssetTerms {
|
||||
enactmentTimestamp: number;
|
||||
}
|
||||
|
||||
interface ProposalTransferTerms {
|
||||
newTransfer: {
|
||||
changes: {
|
||||
fractionOfBalance: string;
|
||||
amount: string;
|
||||
sourceType: string;
|
||||
source: string;
|
||||
transferType: string;
|
||||
destinationType: string;
|
||||
destination: string;
|
||||
asset: string;
|
||||
recurring?: {
|
||||
startEpoch: number;
|
||||
endEpoch: number;
|
||||
};
|
||||
oneOff?: {
|
||||
deliverOn: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
closingTimestamp: number;
|
||||
enactmentTimestamp: number;
|
||||
validationTimestamp?: number;
|
||||
}
|
||||
|
||||
interface ProposalCancelTransferTerms {
|
||||
cancelTransfer: {
|
||||
changes: {
|
||||
transferId: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
interface DataSourceSpecBinding {
|
||||
settlementDataProperty: string;
|
||||
tradingTerminationProperty: string;
|
||||
@ -342,7 +375,9 @@ export interface ProposalSubmission {
|
||||
| ProposalUpdateMarketTerms
|
||||
| ProposalNetworkParameterTerms
|
||||
| ProposalNewAssetTerms
|
||||
| ProposalUpdateAssetTerms;
|
||||
| ProposalUpdateAssetTerms
|
||||
| ProposalTransferTerms
|
||||
| ProposalCancelTransferTerms;
|
||||
}
|
||||
|
||||
export interface ProposalSubmissionBody {
|
||||
|
Loading…
Reference in New Issue
Block a user