test(governance): refactor proposal enactment tests (#2897)
This commit is contained in:
parent
55d6dd4dce
commit
42cd32f376
@ -0,0 +1,143 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
import {
|
||||||
|
createUpdateNetworkProposalTxBody,
|
||||||
|
createFreeFormProposalTxBody,
|
||||||
|
} from '../../support/proposal.functions';
|
||||||
|
|
||||||
|
const closedProposals = '[data-testid="closed-proposals"]';
|
||||||
|
const proposalStatus = '[data-testid="proposal-status"]';
|
||||||
|
const viewProposalButton = '[data-testid="view-proposal-btn"]';
|
||||||
|
const votesTable = '[data-testid="votes-table"]';
|
||||||
|
const openProposals = '[data-testid="open-proposals"]';
|
||||||
|
const proposalVoteProgressForPercentage =
|
||||||
|
'[data-testid="vote-progress-indicator-percentage-for"]';
|
||||||
|
const proposalTimeout = { timeout: 8000 };
|
||||||
|
|
||||||
|
context(
|
||||||
|
'Proposal flow - with proposals enacted or failed',
|
||||||
|
{ tags: '@slow' },
|
||||||
|
function () {
|
||||||
|
before('Connect wallets and set approval', function () {
|
||||||
|
cy.visit('/');
|
||||||
|
cy.vega_wallet_set_specified_approval_amount('1000');
|
||||||
|
cy.connectVegaWallet();
|
||||||
|
cy.ethereum_wallet_connect();
|
||||||
|
cy.ensure_specified_unstaked_tokens_are_associated(1);
|
||||||
|
cy.clearLocalStorage();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach('visit proposals', function () {
|
||||||
|
cy.reload();
|
||||||
|
cy.wait_for_spinner();
|
||||||
|
cy.connectVegaWallet();
|
||||||
|
cy.ethereum_wallet_connect();
|
||||||
|
cy.navigate_to('proposals');
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3001-VOTE-006
|
||||||
|
it('Able to view enacted proposal', function () {
|
||||||
|
const proposalTitle = 'Add Lorem Ipsum market';
|
||||||
|
|
||||||
|
cy.createMarket();
|
||||||
|
cy.reload();
|
||||||
|
cy.wait_for_spinner();
|
||||||
|
cy.get(closedProposals).within(() => {
|
||||||
|
cy.contains(proposalTitle)
|
||||||
|
.parentsUntil('[data-testid="proposals-list-item"]')
|
||||||
|
.within(() => {
|
||||||
|
cy.get(proposalStatus).should('have.text', 'Enacted ');
|
||||||
|
cy.get(viewProposalButton).click();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
cy.getByTestId('proposal-type').should('have.text', 'New market');
|
||||||
|
cy.get_proposal_information_from_table('State')
|
||||||
|
.contains('Enacted')
|
||||||
|
.and('be.visible');
|
||||||
|
cy.get(votesTable).within(() => {
|
||||||
|
cy.contains('Vote passed.').should('be.visible');
|
||||||
|
cy.contains('Voting has ended.').should('be.visible');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3001-VOTE-046 3001-VOTE-044 3001-VOTE-074 3001-VOTE-074
|
||||||
|
it('Able to enact proposal by voting', function () {
|
||||||
|
const proposalTitle = 'Add New proposal with short enactment';
|
||||||
|
const proposalTx = createUpdateNetworkProposalTxBody();
|
||||||
|
|
||||||
|
cy.VegaWalletSubmitProposal(proposalTx);
|
||||||
|
cy.navigate_to('proposals');
|
||||||
|
cy.reload();
|
||||||
|
cy.wait_for_spinner();
|
||||||
|
cy.get(openProposals).within(() => {
|
||||||
|
cy.contains(proposalTitle)
|
||||||
|
.parentsUntil('[data-testid="proposals-list-item"]')
|
||||||
|
.within(() => cy.get(viewProposalButton).click());
|
||||||
|
});
|
||||||
|
cy.get_proposal_information_from_table('State')
|
||||||
|
.contains('Open')
|
||||||
|
.and('be.visible');
|
||||||
|
cy.vote_for_proposal('for');
|
||||||
|
cy.get_proposal_information_from_table('State') // 3001-VOTE-047
|
||||||
|
.contains('Passed', proposalTimeout)
|
||||||
|
.and('be.visible');
|
||||||
|
cy.get_proposal_information_from_table('State')
|
||||||
|
.contains('Enacted', proposalTimeout)
|
||||||
|
.and('be.visible');
|
||||||
|
cy.get(votesTable).within(() => {
|
||||||
|
cy.contains('Vote passed.').should('be.visible');
|
||||||
|
cy.contains('Voting has ended.').should('be.visible');
|
||||||
|
});
|
||||||
|
cy.get(proposalVoteProgressForPercentage)
|
||||||
|
.contains('100.00%')
|
||||||
|
.and('be.visible');
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3001-VOTE-047
|
||||||
|
it('Able to enact freeform proposal', function () {
|
||||||
|
const proposalTitle = 'Add New free form proposal with short enactment';
|
||||||
|
const proposalTx = createFreeFormProposalTxBody();
|
||||||
|
|
||||||
|
cy.VegaWalletSubmitProposal(proposalTx);
|
||||||
|
cy.navigate_to('proposals');
|
||||||
|
cy.reload();
|
||||||
|
cy.wait_for_spinner();
|
||||||
|
cy.get(openProposals).within(() => {
|
||||||
|
cy.contains(proposalTitle)
|
||||||
|
.parentsUntil('[data-testid="proposals-list-item"]')
|
||||||
|
.within(() => cy.get(viewProposalButton).click());
|
||||||
|
});
|
||||||
|
cy.get_proposal_information_from_table('State')
|
||||||
|
.contains('Open')
|
||||||
|
.and('be.visible');
|
||||||
|
cy.vote_for_proposal('for');
|
||||||
|
cy.get_proposal_information_from_table('State')
|
||||||
|
.contains('Enacted', proposalTimeout)
|
||||||
|
.and('be.visible');
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3001-VOTE-048 3001-VOTE-049
|
||||||
|
it('Able to fail proposal due to lack of participation', function () {
|
||||||
|
const proposalTitle = 'Add New free form proposal with short enactment';
|
||||||
|
const proposalTx = createFreeFormProposalTxBody();
|
||||||
|
cy.VegaWalletSubmitProposal(proposalTx);
|
||||||
|
cy.navigate_to('proposals');
|
||||||
|
cy.reload();
|
||||||
|
cy.wait_for_spinner();
|
||||||
|
cy.get(openProposals).within(() => {
|
||||||
|
cy.contains(proposalTitle)
|
||||||
|
.parentsUntil('[data-testid="proposals-list-item"]')
|
||||||
|
.within(() => cy.get(viewProposalButton).click());
|
||||||
|
});
|
||||||
|
cy.get_proposal_information_from_table('State')
|
||||||
|
.contains('Open')
|
||||||
|
.and('be.visible');
|
||||||
|
cy.get_proposal_information_from_table('State') // 3001-VOTE-047
|
||||||
|
.contains('Declined', proposalTimeout)
|
||||||
|
.and('be.visible');
|
||||||
|
cy.get_proposal_information_from_table('Rejection reason')
|
||||||
|
.contains('PROPOSAL_ERROR_PARTICIPATION_THRESHOLD_NOT_REACHED')
|
||||||
|
.and('be.visible');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
@ -1,4 +1,5 @@
|
|||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
const vegaWalletUnstakedBalance =
|
const vegaWalletUnstakedBalance =
|
||||||
'[data-testid="vega-wallet-balance-unstaked"]';
|
'[data-testid="vega-wallet-balance-unstaked"]';
|
||||||
const vegaWalletStakedBalances =
|
const vegaWalletStakedBalances =
|
||||||
@ -11,7 +12,6 @@ const newProposalSubmitButton = '[data-testid="proposal-submit"]';
|
|||||||
const dialogCloseButton = '[data-testid="dialog-close"]';
|
const dialogCloseButton = '[data-testid="dialog-close"]';
|
||||||
const viewProposalButton = '[data-testid="view-proposal-btn"]';
|
const viewProposalButton = '[data-testid="view-proposal-btn"]';
|
||||||
const openProposals = '[data-testid="open-proposals"]';
|
const openProposals = '[data-testid="open-proposals"]';
|
||||||
const closedProposals = '[data-testid="closed-proposals"]';
|
|
||||||
const proposalVoteProgressForPercentage =
|
const proposalVoteProgressForPercentage =
|
||||||
'[data-testid="vote-progress-indicator-percentage-for"]';
|
'[data-testid="vote-progress-indicator-percentage-for"]';
|
||||||
const proposalVoteProgressAgainstPercentage =
|
const proposalVoteProgressAgainstPercentage =
|
||||||
@ -23,9 +23,7 @@ const proposalVoteProgressAgainstTokens =
|
|||||||
const changeVoteButton = '[data-testid="change-vote-button"]';
|
const changeVoteButton = '[data-testid="change-vote-button"]';
|
||||||
const proposalDetailsTitle = '[data-testid="proposal-title"]';
|
const proposalDetailsTitle = '[data-testid="proposal-title"]';
|
||||||
const proposalDetailsDescription = '[data-testid="proposal-description"]';
|
const proposalDetailsDescription = '[data-testid="proposal-description"]';
|
||||||
const proposalStatus = '[data-testid="proposal-status"]';
|
|
||||||
const rawProposalData = '[data-testid="proposal-data"]';
|
const rawProposalData = '[data-testid="proposal-data"]';
|
||||||
const votesTable = '[data-testid="votes-table"]';
|
|
||||||
const minVoteButton = '[data-testid="min-vote"]';
|
const minVoteButton = '[data-testid="min-vote"]';
|
||||||
const maxVoteButton = '[data-testid="max-vote"]';
|
const maxVoteButton = '[data-testid="max-vote"]';
|
||||||
const voteButtons = '[data-testid="vote-buttons"]';
|
const voteButtons = '[data-testid="vote-buttons"]';
|
||||||
@ -787,107 +785,6 @@ context(
|
|||||||
cy.contains('You voted: Against').should('be.visible');
|
cy.contains('You voted: Against').should('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3001-VOTE-006
|
|
||||||
it('Able to view enacted proposal', function () {
|
|
||||||
cy.createMarket();
|
|
||||||
cy.reload();
|
|
||||||
cy.wait_for_spinner();
|
|
||||||
cy.get(closedProposals).within(() => {
|
|
||||||
cy.get(proposalDetailsTitle).should(
|
|
||||||
'have.text',
|
|
||||||
'Add Lorem Ipsum market'
|
|
||||||
);
|
|
||||||
cy.get(proposalStatus).should('have.text', 'Enacted ');
|
|
||||||
cy.get(viewProposalButton).click();
|
|
||||||
});
|
|
||||||
cy.getByTestId('proposal-type').should('have.text', 'New market');
|
|
||||||
cy.get_proposal_information_from_table('State')
|
|
||||||
.contains('Enacted')
|
|
||||||
.and('be.visible');
|
|
||||||
cy.get(votesTable).within(() => {
|
|
||||||
cy.contains('Vote passed.').should('be.visible');
|
|
||||||
cy.contains('Voting has ended.').should('be.visible');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// 3001-VOTE-047
|
|
||||||
it('Able to enact freeform proposal', function () {
|
|
||||||
const proposalTitle = 'Add New free form proposal with short enactment';
|
|
||||||
cy.ensure_specified_unstaked_tokens_are_associated(
|
|
||||||
this.minProposerBalance
|
|
||||||
);
|
|
||||||
cy.sendWalletTxFreeFormProposal();
|
|
||||||
cy.navigate_to('proposals');
|
|
||||||
cy.reload();
|
|
||||||
cy.wait_for_spinner();
|
|
||||||
cy.contains(proposalTitle)
|
|
||||||
.parentsUntil('[data-testid="proposals-list-item"]')
|
|
||||||
.within(() => cy.get(viewProposalButton).click());
|
|
||||||
cy.get_proposal_information_from_table('State')
|
|
||||||
.contains('Open')
|
|
||||||
.and('be.visible');
|
|
||||||
cy.vote_for_proposal('for');
|
|
||||||
cy.get_proposal_information_from_table('State')
|
|
||||||
.contains('Enacted', epochTimeout)
|
|
||||||
.and('be.visible');
|
|
||||||
});
|
|
||||||
|
|
||||||
// 3001-VOTE-046 3001-VOTE-044 3001-VOTE-074 3001-VOTE-074
|
|
||||||
it('Able to enact proposal by voting', function () {
|
|
||||||
const proposalTitle = 'Add New proposal with short enactment';
|
|
||||||
cy.ensure_specified_unstaked_tokens_are_associated(
|
|
||||||
this.minProposerBalance
|
|
||||||
);
|
|
||||||
cy.sendWalletTxUpdateNetworkProposal();
|
|
||||||
cy.navigate_to('proposals');
|
|
||||||
cy.reload();
|
|
||||||
cy.wait_for_spinner();
|
|
||||||
cy.contains(proposalTitle)
|
|
||||||
.parentsUntil('[data-testid="proposals-list-item"]')
|
|
||||||
.within(() => cy.get(viewProposalButton).click());
|
|
||||||
cy.get_proposal_information_from_table('State')
|
|
||||||
.contains('Open')
|
|
||||||
.and('be.visible');
|
|
||||||
cy.vote_for_proposal('for');
|
|
||||||
cy.get_proposal_information_from_table('State') // 3001-VOTE-047
|
|
||||||
.contains('Passed', txTimeout)
|
|
||||||
.and('be.visible');
|
|
||||||
cy.get_proposal_information_from_table('State')
|
|
||||||
.contains('Enacted', epochTimeout)
|
|
||||||
.and('be.visible');
|
|
||||||
cy.get(votesTable).within(() => {
|
|
||||||
cy.contains('Vote passed.').should('be.visible');
|
|
||||||
cy.contains('Voting has ended.').should('be.visible');
|
|
||||||
});
|
|
||||||
cy.get(proposalVoteProgressForPercentage)
|
|
||||||
.contains('100.00%')
|
|
||||||
.and('be.visible');
|
|
||||||
});
|
|
||||||
|
|
||||||
// 3001-VOTE-048 3001-VOTE-049
|
|
||||||
it('Able to fail proposal due to lack of participation', function () {
|
|
||||||
const proposalTitle = 'Add New free form proposal with short enactment';
|
|
||||||
cy.ensure_specified_unstaked_tokens_are_associated(
|
|
||||||
this.minProposerBalance
|
|
||||||
);
|
|
||||||
cy.sendWalletTxFreeFormProposal();
|
|
||||||
cy.navigate_to('proposals');
|
|
||||||
cy.reload();
|
|
||||||
cy.wait_for_spinner();
|
|
||||||
cy.contains(proposalTitle)
|
|
||||||
.parentsUntil('[data-testid="proposals-list-item"]')
|
|
||||||
.within(() => cy.get(viewProposalButton).click());
|
|
||||||
cy.get_proposal_information_from_table('State')
|
|
||||||
.contains('Open')
|
|
||||||
.and('be.visible');
|
|
||||||
cy.get_proposal_information_from_table('State') // 3001-VOTE-047
|
|
||||||
.contains('Declined', txTimeout)
|
|
||||||
.and('be.visible');
|
|
||||||
cy.get_proposal_information_from_table('Rejection reason')
|
|
||||||
.contains('PROPOSAL_ERROR_PARTICIPATION_THRESHOLD_NOT_REACHED')
|
|
||||||
.and('be.visible');
|
|
||||||
});
|
|
||||||
|
|
||||||
function createRawProposal(proposerBalance) {
|
function createRawProposal(proposerBalance) {
|
||||||
if (proposerBalance)
|
if (proposerBalance)
|
||||||
cy.ensure_specified_unstaked_tokens_are_associated(proposerBalance);
|
cy.ensure_specified_unstaked_tokens_are_associated(proposerBalance);
|
||||||
|
@ -7,7 +7,7 @@ import './governance.functions.js';
|
|||||||
import './wallet-eth.functions.js';
|
import './wallet-eth.functions.js';
|
||||||
import './wallet-teardown.functions.js';
|
import './wallet-teardown.functions.js';
|
||||||
import './wallet-vega.functions.js';
|
import './wallet-vega.functions.js';
|
||||||
import './proposal.functions.js';
|
import './proposal.functions.ts';
|
||||||
import registerCypressGrep from '@cypress/grep';
|
import registerCypressGrep from '@cypress/grep';
|
||||||
import { aliasGQLQuery } from '@vegaprotocol/cypress';
|
import { aliasGQLQuery } from '@vegaprotocol/cypress';
|
||||||
import { chainIdQuery, statisticsQuery } from '@vegaprotocol/mock';
|
import { chainIdQuery, statisticsQuery } from '@vegaprotocol/mock';
|
||||||
|
@ -1,103 +0,0 @@
|
|||||||
import { addSeconds, millisecondsToSeconds } from 'date-fns';
|
|
||||||
|
|
||||||
const walletName = Cypress.env('vegaWalletName');
|
|
||||||
const walletPubKey = Cypress.env('vegaWalletPublicKey');
|
|
||||||
const walletLocation = Cypress.env('vegaWalletLocation');
|
|
||||||
const walletPassphraseFile = './src/fixtures/wallet/passphrase';
|
|
||||||
|
|
||||||
Cypress.Commands.add('sendWalletTxUpdateNetworkProposal', () => {
|
|
||||||
const MIN_CLOSE_SEC = 8;
|
|
||||||
const MIN_ENACT_SEC = 5;
|
|
||||||
|
|
||||||
const closingDate = addSeconds(new Date(), MIN_CLOSE_SEC);
|
|
||||||
const enactmentDate = addSeconds(closingDate, MIN_ENACT_SEC);
|
|
||||||
const closingTimestamp = millisecondsToSeconds(closingDate.getTime());
|
|
||||||
const enactmentTimestamp = millisecondsToSeconds(enactmentDate.getTime());
|
|
||||||
|
|
||||||
cy.exec(
|
|
||||||
`vegawallet transaction send --wallet ${walletName} --pubkey ${walletPubKey} -p ${walletPassphraseFile} --network DV '{
|
|
||||||
"proposalSubmission": {
|
|
||||||
"rationale": {
|
|
||||||
"title": "Add New proposal with short enactment",
|
|
||||||
"description": "E2E enactment test"
|
|
||||||
},
|
|
||||||
"terms": {
|
|
||||||
"updateNetworkParameter": {
|
|
||||||
"changes": {
|
|
||||||
"key": "governance.proposal.updateNetParam.minProposerBalance",
|
|
||||||
"value": "2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"closingTimestamp": ${closingTimestamp},
|
|
||||||
"enactmentTimestamp": ${enactmentTimestamp}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}' --home ${walletLocation}`,
|
|
||||||
{ failOnNonZeroExit: false }
|
|
||||||
)
|
|
||||||
.its('stderr')
|
|
||||||
.should('contain', '');
|
|
||||||
});
|
|
||||||
|
|
||||||
Cypress.Commands.add('sendWalletTxUpdateAssetProposal', () => {
|
|
||||||
const MIN_CLOSE_SEC = 8;
|
|
||||||
const MIN_ENACT_SEC = 5;
|
|
||||||
|
|
||||||
const closingDate = addSeconds(new Date(), MIN_CLOSE_SEC);
|
|
||||||
const enactmentDate = addSeconds(closingDate, MIN_ENACT_SEC);
|
|
||||||
const closingTimestamp = millisecondsToSeconds(closingDate.getTime());
|
|
||||||
const enactmentTimestamp = millisecondsToSeconds(enactmentDate.getTime());
|
|
||||||
|
|
||||||
cy.exec(
|
|
||||||
`vegawallet transaction send --wallet ${walletName} --pubkey ${walletPubKey} -p ${walletPassphraseFile} --network DV '{
|
|
||||||
"proposalSubmission": {
|
|
||||||
"rationale": {
|
|
||||||
"title": "Update Asset set to fail",
|
|
||||||
"description": "E2E fail test"
|
|
||||||
},
|
|
||||||
"terms": {
|
|
||||||
"updateAsset": {
|
|
||||||
"assetId": "ebcd94151ae1f0d39a4bde3b21a9c7ae81a80ea4352fb075a92e07608d9c953d",
|
|
||||||
"changes": {
|
|
||||||
"quantum": "1",
|
|
||||||
"erc20": {
|
|
||||||
"withdrawThreshold": "10",
|
|
||||||
"lifetimeLimit": "10"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"closingTimestamp": ${closingTimestamp},
|
|
||||||
"enactmentTimestamp": ${enactmentTimestamp}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}' --home ${walletLocation}`,
|
|
||||||
{ failOnNonZeroExit: false }
|
|
||||||
)
|
|
||||||
.its('stderr')
|
|
||||||
.should('contain', '');
|
|
||||||
});
|
|
||||||
|
|
||||||
Cypress.Commands.add('sendWalletTxFreeFormProposal', () => {
|
|
||||||
const MIN_CLOSE_SEC = 5;
|
|
||||||
|
|
||||||
const closingDate = addSeconds(new Date(), MIN_CLOSE_SEC);
|
|
||||||
const closingTimestamp = millisecondsToSeconds(closingDate.getTime());
|
|
||||||
|
|
||||||
cy.exec(
|
|
||||||
`vegawallet transaction send --wallet ${walletName} --pubkey ${walletPubKey} -p ${walletPassphraseFile} --network DV '{
|
|
||||||
"proposalSubmission": {
|
|
||||||
"rationale": {
|
|
||||||
"title": "Add New free form proposal with short enactment",
|
|
||||||
"description": "E2E enactment test"
|
|
||||||
},
|
|
||||||
"terms": {
|
|
||||||
"newFreeform": {},
|
|
||||||
"closingTimestamp": ${closingTimestamp}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}' --home ${walletLocation}`,
|
|
||||||
{ failOnNonZeroExit: false }
|
|
||||||
)
|
|
||||||
.its('stderr')
|
|
||||||
.should('contain', '');
|
|
||||||
});
|
|
82
apps/token-e2e/src/support/proposal.functions.ts
Normal file
82
apps/token-e2e/src/support/proposal.functions.ts
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
import { addSeconds, millisecondsToSeconds } from 'date-fns';
|
||||||
|
import type { ProposalSubmissionBody } from '@vegaprotocol/wallet';
|
||||||
|
|
||||||
|
export function createUpdateNetworkProposalTxBody(): ProposalSubmissionBody {
|
||||||
|
const MIN_CLOSE_SEC = 5;
|
||||||
|
const MIN_ENACT_SEC = 7;
|
||||||
|
|
||||||
|
const closingDate = addSeconds(new Date(), MIN_CLOSE_SEC);
|
||||||
|
const enactmentDate = addSeconds(closingDate, MIN_ENACT_SEC);
|
||||||
|
const closingTimestamp = millisecondsToSeconds(closingDate.getTime());
|
||||||
|
const enactmentTimestamp = millisecondsToSeconds(enactmentDate.getTime());
|
||||||
|
return {
|
||||||
|
proposalSubmission: {
|
||||||
|
rationale: {
|
||||||
|
title: 'Add New proposal with short enactment',
|
||||||
|
description: 'E2E enactment test',
|
||||||
|
},
|
||||||
|
terms: {
|
||||||
|
updateNetworkParameter: {
|
||||||
|
changes: {
|
||||||
|
key: 'governance.proposal.updateNetParam.minProposerBalance',
|
||||||
|
value: '2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
closingTimestamp,
|
||||||
|
enactmentTimestamp,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createUpdateAssetProposalTxBody(): ProposalSubmissionBody {
|
||||||
|
const MIN_CLOSE_SEC = 5;
|
||||||
|
const MIN_ENACT_SEC = 7;
|
||||||
|
|
||||||
|
const closingDate = addSeconds(new Date(), MIN_CLOSE_SEC);
|
||||||
|
const enactmentDate = addSeconds(closingDate, MIN_ENACT_SEC);
|
||||||
|
const closingTimestamp = millisecondsToSeconds(closingDate.getTime());
|
||||||
|
const enactmentTimestamp = millisecondsToSeconds(enactmentDate.getTime());
|
||||||
|
return {
|
||||||
|
proposalSubmission: {
|
||||||
|
rationale: {
|
||||||
|
title: 'Update Asset set to fail',
|
||||||
|
description: 'E2E fail test',
|
||||||
|
},
|
||||||
|
terms: {
|
||||||
|
updateAsset: {
|
||||||
|
assetId:
|
||||||
|
'ebcd94151ae1f0d39a4bde3b21a9c7ae81a80ea4352fb075a92e07608d9c953d',
|
||||||
|
changes: {
|
||||||
|
quantum: '1',
|
||||||
|
erc20: {
|
||||||
|
withdrawThreshold: '10',
|
||||||
|
lifetimeLimit: '10',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
closingTimestamp,
|
||||||
|
enactmentTimestamp,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createFreeFormProposalTxBody(): ProposalSubmissionBody {
|
||||||
|
const MIN_CLOSE_SEC = 7;
|
||||||
|
|
||||||
|
const closingDate = addSeconds(new Date(), MIN_CLOSE_SEC);
|
||||||
|
const closingTimestamp = millisecondsToSeconds(closingDate.getTime());
|
||||||
|
return {
|
||||||
|
proposalSubmission: {
|
||||||
|
rationale: {
|
||||||
|
title: 'Add New free form proposal with short enactment',
|
||||||
|
description: 'E2E enactment test',
|
||||||
|
},
|
||||||
|
terms: {
|
||||||
|
newFreeform: {},
|
||||||
|
closingTimestamp,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
@ -17,6 +17,7 @@ import {
|
|||||||
import { addMockTransactionResponse } from './lib/commands/mock-transaction-response';
|
import { addMockTransactionResponse } from './lib/commands/mock-transaction-response';
|
||||||
import { addCreateMarket } from './lib/commands/create-market';
|
import { addCreateMarket } from './lib/commands/create-market';
|
||||||
import { addConnectPublicKey } from './lib/commands/add-connect-public-key';
|
import { addConnectPublicKey } from './lib/commands/add-connect-public-key';
|
||||||
|
import { addVegaWalletSubmitProposal } from './lib/commands/vega-wallet-submit-proposal';
|
||||||
|
|
||||||
addGetTestIdcommand();
|
addGetTestIdcommand();
|
||||||
addSlackCommand();
|
addSlackCommand();
|
||||||
@ -35,6 +36,7 @@ addSetVegaWallet();
|
|||||||
addMockTransactionResponse();
|
addMockTransactionResponse();
|
||||||
addCreateMarket();
|
addCreateMarket();
|
||||||
addConnectPublicKey();
|
addConnectPublicKey();
|
||||||
|
addVegaWalletSubmitProposal();
|
||||||
|
|
||||||
export { mockConnectWallet } from './lib/commands/vega-wallet-connect';
|
export { mockConnectWallet } from './lib/commands/vega-wallet-connect';
|
||||||
export type { onMessage } from './lib/mock-ws';
|
export type { onMessage } from './lib/mock-ws';
|
||||||
|
25
libs/cypress/src/lib/commands/vega-wallet-submit-proposal.ts
Normal file
25
libs/cypress/src/lib/commands/vega-wallet-submit-proposal.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { createWalletClient, sendVegaTx } from '../capsule/wallet-client';
|
||||||
|
import type { ProposalSubmissionBody } from '@vegaprotocol/wallet';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||||
|
namespace Cypress {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
interface Chainable<Subject> {
|
||||||
|
VegaWalletSubmitProposal(proposalTx: ProposalSubmissionBody): void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const addVegaWalletSubmitProposal = () => {
|
||||||
|
Cypress.Commands.add('VegaWalletSubmitProposal', (proposalTx) => {
|
||||||
|
const vegaWalletUrl = Cypress.env('VEGA_WALLET_URL');
|
||||||
|
const token = Cypress.env('VEGA_WALLET_API_TOKEN');
|
||||||
|
const vegaPubKey = Cypress.env('VEGA_PUBLIC_KEY');
|
||||||
|
|
||||||
|
createWalletClient(vegaWalletUrl, token);
|
||||||
|
|
||||||
|
cy.highlight('Submitting proposal');
|
||||||
|
sendVegaTx(vegaPubKey, proposalTx);
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user