test: lint

This commit is contained in:
AndyWhiteVega 2022-07-06 14:25:36 +01:00
parent abc08664e2
commit 187b373cab
12 changed files with 238 additions and 134 deletions

View File

@ -15,16 +15,19 @@ module.exports = defineConfig({
chromeWebSecurity: false,
},
env: {
ethProviderUrl: 'http://localhost:8545/',
ethWalletPublicKey: '0xEe7D375bcB50C26d52E1A4a472D8822A2A22d94F',
ethStakingBridgeContractAddress: '0x9135f5afd6F055e731bca2348429482eE614CFfA',
vegaWalletName: 'capsule_wallet',
vegaWalletLocation: '~/.vegacapsule/testnet/wallet',
vegaWalletPassphrase: '123',
vegaWalletMnemonic: 'ozone access unlock valid olympic save include omit supply green clown session',
vegaWalletPublicKey: '02eceaba4df2bef76ea10caf728d8a099a2aa846cced25737cccaa9812342f65',
vegaWalletPublicKeyShort: '02ecea…2f65',
vegaTokenContractAddress: '0xF41bD86d462D36b997C0bbb4D97a0a3382f205B7',
vegaTokenAddress: '0x67175Da1D5e966e40D11c4B2519392B2058373de'
}
ethProviderUrl: 'http://localhost:8545/',
ethWalletPublicKey: '0xEe7D375bcB50C26d52E1A4a472D8822A2A22d94F',
ethStakingBridgeContractAddress:
'0x9135f5afd6F055e731bca2348429482eE614CFfA',
vegaWalletName: 'capsule_wallet',
vegaWalletLocation: '~/.vegacapsule/testnet/wallet',
vegaWalletPassphrase: '123',
vegaWalletMnemonic:
'ozone access unlock valid olympic save include omit supply green clown session',
vegaWalletPublicKey:
'02eceaba4df2bef76ea10caf728d8a099a2aa846cced25737cccaa9812342f65',
vegaWalletPublicKeyShort: '02ecea…2f65',
vegaTokenContractAddress: '0xF41bD86d462D36b997C0bbb4D97a0a3382f205B7',
vegaTokenAddress: '0x67175Da1D5e966e40D11c4B2519392B2058373de',
},
});

View File

@ -7,7 +7,7 @@ import '../../support/vega-wallet.functions';
import '../../support/eth-wallet.functions';
import '../../support/wallet-teardown.functions';
const vegaWalletPublicKeyShort = Cypress.env("vegaWalletPublicKeyShort");
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
context('Staking Tab - with eth and vega wallets connected', function () {
before('visit staking tab and connect vega wallet', function () {
@ -22,7 +22,10 @@ context('Staking Tab - with eth and vega wallets connected', function () {
cy.get(navigation.staking).first().click();
cy.get(navigation.spinner, { timeout: 20000 }).should('not.exist');
cy.get(staking.validatorNames).first().invoke('text').as('validatorName');
cy.get(staking.validatorNames).last().invoke('text').as('otherValidatorName');
cy.get(staking.validatorNames)
.last()
.invoke('text')
.as('otherValidatorName');
});
describe('Eth wallet - contains VEGA tokens', function () {
@ -37,8 +40,11 @@ context('Staking Tab - with eth and vega wallets connected', function () {
it('Able to stake against a validator', function () {
cy.staking_page_associate_tokens('3');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.ethereum_wallet_check_associated_value_is('3.0')
cy.ethereum_wallet_check_associated_vega_key_value_is(vegaWalletPublicKeyShort,'3.000000000000000000');
cy.ethereum_wallet_check_associated_value_is('3.0');
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort,
'3.000000000000000000'
);
cy.get('button').contains('Select a validator to nominate').click();
cy.get(staking.validatorNames).contains(this.validatorName).click();
@ -64,13 +70,15 @@ context('Staking Tab - with eth and vega wallets connected', function () {
cy.get(staking.validatorNames).contains(this.validatorName).click();
cy.staking_validator_page_add_stake('2');
cy.vega_wallet_check_validator_staked_value_is(this.validatorName,
cy.vega_wallet_check_validator_staked_value_is(
this.validatorName,
'2.000000000000000000'
);
cy.get(navigation.staking).first().click();
cy.get(staking.validatorNames).contains(this.otherValidatorName).click();
cy.staking_validator_page_add_stake('1');
cy.vega_wallet_check_validator_staked_value_is(this.otherValidatorName,
cy.vega_wallet_check_validator_staked_value_is(
this.otherValidatorName,
'1.000000000000000000'
);
cy.vega_wallet_check_unstaked_value_is('2.000000000000000000');
@ -202,7 +210,7 @@ context('Staking Tab - with eth and vega wallets connected', function () {
});
it('Disassociating all tokens - removes all staked tokens', function () {
cy.staking_page_associate_tokens('3')
cy.staking_page_associate_tokens('3');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.get('button').contains('Select a validator to nominate').click();
@ -210,17 +218,22 @@ context('Staking Tab - with eth and vega wallets connected', function () {
cy.staking_validator_page_add_stake('2');
cy.vega_wallet_check_unstaked_value_is('1.000000000000000000');
cy.vega_wallet_check_validator_staked_value_is(this.validatorName, '2.000000000000000000');
cy.vega_wallet_check_validator_staked_value_is(
this.validatorName,
'2.000000000000000000'
);
cy.get(navigation.staking).first().click();
cy.staking_page_disassociate_all_tokens();
cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing(vegaWalletPublicKeyShort);
cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing(
vegaWalletPublicKeyShort
);
cy.ethereum_wallet_check_associated_value_is('0.0');
cy.vega_wallet_check_associated_value_is('0.000000000000000000');
cy.vega_wallet_check_associated_value_is('0.000000000000000000');
cy.vega_wallet_check_validator_no_longer_showing(this.validatorName);
});
it('Disassociating some tokens - prioritizes unstaked tokens', function () {
cy.staking_page_associate_tokens('3')
cy.staking_page_associate_tokens('3');
cy.vega_wallet_check_unstaked_value_is('3.000000000000000000');
cy.get('button').contains('Select a validator to nominate').click();
@ -228,33 +241,46 @@ context('Staking Tab - with eth and vega wallets connected', function () {
cy.staking_validator_page_add_stake('2');
cy.vega_wallet_check_unstaked_value_is('1.000000000000000000');
cy.vega_wallet_check_validator_staked_value_is(this.validatorName, '2.000000000000000000');
cy.vega_wallet_check_validator_staked_value_is(
this.validatorName,
'2.000000000000000000'
);
cy.get(navigation.staking).first().click();
cy.staking_page_disassociate_tokens('1');
cy.ethereum_wallet_check_associated_value_is('2.0');
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
cy.vega_wallet_check_validator_staked_value_is(this.validatorName,
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
cy.vega_wallet_check_validator_staked_value_is(
this.validatorName,
'2.000000000000000000'
);
});
});
cy.staking_validator_page_check_stake_next_epoch_value = (expectedVal) => {
cy.highlight(`Checking Staking Page - Validator Stake Next Epoch Value is ${expectedVal}`);
cy.highlight(
`Checking Staking Page - Validator Stake Next Epoch Value is ${expectedVal}`
);
cy.get(staking.stakeNextEpochValue, { timeout: 10000 })
.contains(expectedVal, { timeout: 10000 })
.should('be.visible');
};
cy.staking_validator_page_check_stake_this_epoch_value = (expectedVal) => {
cy.highlight(`Checking Staking Page - Validator Stake This Epoch Value is ${expectedVal}`);
cy.highlight(
`Checking Staking Page - Validator Stake This Epoch Value is ${expectedVal}`
);
cy.get(staking.stakeThisEpochValue, { timeout: 10000 })
.contains(expectedVal, { timeout: 10000 })
.should('be.visible');
};
cy.vega_wallet_check_validator_stake_next_epoch_value_is = (validatorName, expectedVal) => {
cy.highlight(`Checking vega wallet - Stake Next Epoch Value for ${validatorName} is ${expectedVal}`);
cy.vega_wallet_check_validator_stake_next_epoch_value_is = (
validatorName,
expectedVal
) => {
cy.highlight(
`Checking vega wallet - Stake Next Epoch Value for ${validatorName} is ${expectedVal}`
);
cy.get(wallet.vegawallet).within(() => {
cy.contains(`${validatorName} (Next epoch)`, { timeout: 40000 })
.siblings()
@ -262,9 +288,14 @@ context('Staking Tab - with eth and vega wallets connected', function () {
.should('be.visible');
});
};
cy.vega_wallet_check_validator_stake_this_epoch_value_is = (validatorName, expectedVal) => {
cy.highlight(`Checking vega wallet - Stake This Epoch Value for ${validatorName} is ${expectedVal}`);
cy.vega_wallet_check_validator_stake_this_epoch_value_is = (
validatorName,
expectedVal
) => {
cy.highlight(
`Checking vega wallet - Stake This Epoch Value for ${validatorName} is ${expectedVal}`
);
cy.get(wallet.vegawallet).within(() => {
cy.contains(`${validatorName} (This Epoch)`, { timeout: 40000 })
.siblings()
@ -274,15 +305,23 @@ context('Staking Tab - with eth and vega wallets connected', function () {
};
cy.vega_wallet_check_validator_no_longer_showing = (validatorName) => {
cy.highlight(`Checking Validator and therefore stake removed for ${validatorName}`);
cy.highlight(
`Checking Validator and therefore stake removed for ${validatorName}`
);
cy.get(wallet.vegawallet).within(() => {
cy.contains(`${validatorName}`, { timeout: 40000 })
.should('not.exist', { timeout: 40000 });
cy.contains(`${validatorName}`, { timeout: 40000 }).should('not.exist', {
timeout: 40000,
});
});
};
cy.vega_wallet_check_validator_staked_value_is = (validatorName, expectedVal) => {
cy.highlight(`Checking Validator Stake Value for ${validatorName} is ${expectedVal}`);
cy.vega_wallet_check_validator_staked_value_is = (
validatorName,
expectedVal
) => {
cy.highlight(
`Checking Validator Stake Value for ${validatorName} is ${expectedVal}`
);
cy.get(wallet.vegawallet).within(() => {
cy.contains(`${validatorName}`, { timeout: 40000 })
.siblings()

View File

@ -7,7 +7,7 @@ import '../../support/vega-wallet.functions';
import '../../support/eth-wallet.functions';
import '../../support/wallet-teardown.functions';
const vegaWalletPublicKeyShort = Cypress.env("vegaWalletPublicKeyShort");
const vegaWalletPublicKeyShort = Cypress.env('vegaWalletPublicKeyShort');
context('Staking Tab - with eth and vega wallets connected', function () {
before('visit staking tab and connect vega wallet', function () {
@ -36,7 +36,10 @@ context('Staking Tab - with eth and vega wallets connected', function () {
it('Able to associate tokens - from staking page', function () {
cy.staking_page_associate_tokens('2');
cy.ethereum_wallet_check_associated_vega_key_value_is(vegaWalletPublicKeyShort,'2.000000000000000000');
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort,
'2.000000000000000000'
);
cy.ethereum_wallet_check_associated_value_is('2.0');
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
cy.vega_wallet_check_unstaked_value_is('2.000000000000000000');
@ -44,28 +47,45 @@ context('Staking Tab - with eth and vega wallets connected', function () {
it('Able to disassociate tokens - from staking page', function () {
cy.staking_page_associate_tokens('2');
cy.ethereum_wallet_check_associated_vega_key_value_is(vegaWalletPublicKeyShort,'2.000000000000000000');
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort,
'2.000000000000000000'
);
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
cy.get('button').contains('Select a validator to nominate').click();
cy.staking_page_disassociate_tokens('1');
cy.ethereum_wallet_check_associated_vega_key_value_is(vegaWalletPublicKeyShort,'1.000000000000000000');
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort,
'1.000000000000000000'
);
cy.ethereum_wallet_check_associated_value_is('1.0');
cy.vega_wallet_check_associated_value_is('1.000000000000000000');
});
it('Able to access associate token form - from eth wallet', function () {
cy.get(wallet.ethWallet).within(() => cy.get(wallet.ethWalletAssociate).click());
cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).should('be.enabled')
cy.get(wallet.ethWallet).within(() =>
cy.get(wallet.ethWalletAssociate).click()
);
cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).should(
'be.enabled'
);
});
it('Able to access disassociate token form - from eth wallet', function () {
cy.get(wallet.ethWallet).within(() => cy.get(wallet.ethWalletDisassociate).click());
cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).should('be.enabled')
cy.get(wallet.ethWallet).within(() =>
cy.get(wallet.ethWalletDisassociate).click()
);
cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).should(
'be.enabled'
);
});
it('Able to associate more tokens than the approved amount of 1000 - requires re-approval', function () {
cy.staking_page_associate_tokens('1001', true);
cy.ethereum_wallet_check_associated_vega_key_value_is(vegaWalletPublicKeyShort,'1,001.000000000000000000');
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort,
'1,001.000000000000000000'
);
cy.ethereum_wallet_check_associated_value_is('1,001.00');
cy.vega_wallet_check_associated_value_is('1,001.000000000000000000');
});
@ -75,7 +95,10 @@ context('Staking Tab - with eth and vega wallets connected', function () {
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
cy.get('button').contains('Select a validator to nominate').click();
cy.staking_page_disassociate_tokens('1');
cy.ethereum_wallet_check_associated_vega_key_value_is(vegaWalletPublicKeyShort,'1.000000000000000000');
cy.ethereum_wallet_check_associated_vega_key_value_is(
vegaWalletPublicKeyShort,
'1.000000000000000000'
);
cy.ethereum_wallet_check_associated_value_is('1.0');
cy.vega_wallet_check_associated_value_is('1.000000000000000000');
});
@ -85,7 +108,9 @@ context('Staking Tab - with eth and vega wallets connected', function () {
cy.vega_wallet_check_associated_value_is('2.000000000000000000');
cy.get('button').contains('Select a validator to nominate').click();
cy.staking_page_disassociate_all_tokens();
cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing(vegaWalletPublicKeyShort);
cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing(
vegaWalletPublicKeyShort
);
cy.ethereum_wallet_check_associated_value_is('0.0');
cy.vega_wallet_check_associated_value_is('0.000000000000000000');
});

View File

@ -1,8 +1,8 @@
import navigation from '../locators/navigation.locators';
import home from '../locators/home.locators';
const vegaTokenAddress = Cypress.env("vegaTokenAddress");;
const vegaTokenContractAddress = Cypress.env("vegaTokenContractAddress");
const vegaTokenAddress = Cypress.env('vegaTokenAddress');
const vegaTokenContractAddress = Cypress.env('vegaTokenContractAddress');
context('Home Page - verify elements on page', function () {
before('visit token home page', function () {

View File

@ -22,5 +22,5 @@ export default {
stakeAssociateWalletRadio: '[data-testid="associate-radio-wallet"]',
disassociateButton: '[data-testid="disassociate-tokens-btn"]',
associateMoreTokensButton: '[data-testid="associate-more-tokens-btn"]',
associateButton: '[data-testid="associate-tokens-btn"]'
associateButton: '[data-testid="associate-tokens-btn"]',
};

View File

@ -11,4 +11,4 @@ export default {
ethWalletConnect: '[data-testid="web3-connector-Unknown"]',
ethWalletAssociate: '[href="/staking/associate"]',
ethWalletDisassociate: '[href="/staking/disassociate"]',
};
};

View File

@ -14,19 +14,25 @@ cy.ethereum_wallet_connect = () => {
cy.contains('Locked', { timeout: 15000 }).should('be.visible');
});
};
cy.ethereum_wallet_check_associated_value_is = (expectedVal) => {
cy.highlight(`Checking Eth Wallet - Associated Value is ${expectedVal}`);
cy.get(wallet.ethWallet).within(() => {
cy.contains('Associated', { timeout: 20000 })
.parent().siblings()
.parent()
.siblings()
.contains(expectedVal, { timeout: 40000 })
.should('be.visible');
});
};
cy.ethereum_wallet_check_associated_vega_key_value_is = (vegaShortPublicKey, expectedVal) => {
cy.highlight(`Checking Eth Wallet - Vega Key Associated Value is ${expectedVal} for key ${vegaShortPublicKey}`);
cy.ethereum_wallet_check_associated_vega_key_value_is = (
vegaShortPublicKey,
expectedVal
) => {
cy.highlight(
`Checking Eth Wallet - Vega Key Associated Value is ${expectedVal} for key ${vegaShortPublicKey}`
);
cy.get(wallet.ethWallet).within(() => {
cy.contains(vegaShortPublicKey, { timeout: 20000 })
.parent()
@ -35,9 +41,11 @@ cy.ethereum_wallet_check_associated_vega_key_value_is = (vegaShortPublicKey, exp
});
};
cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing = (vegaShortPublicKey) => {
cy.ethereum_wallet_check_associated_vega_key_is_no_longer_showing = (
vegaShortPublicKey
) => {
cy.highlight('Checking Eth Wallet - Vega Key Associated is not showing');
cy.get(wallet.ethWallet).within(() => {
cy.contains(vegaShortPublicKey, { timeout: 20000 }).should('not.exist');
});
};
};

View File

@ -31,11 +31,11 @@ cy.staking_validator_page_removeStake = (stake) => {
);
};
cy.staking_page_associate_tokens = (amount, approve=false) => {
cy.staking_page_associate_tokens = (amount, approve = false) => {
cy.highlight(`Associating ${amount} tokens`);
cy.get(staking.associateButton).click();
cy.get(staking.stakeAssociateWalletRadio, { timeout: 30000 }).click();
cy.get(staking.tokenAmountInput, { timeout: 10000 }).type(amount);
cy.get(staking.tokenAmountInput, { timeout: 10000 }).type(amount);
if (approve) {
cy.get(staking.tokenInputApprove, { timeout: 40000 })
.should('be.enabled')
@ -46,13 +46,14 @@ cy.staking_page_associate_tokens = (amount, approve=false) => {
cy.contains('Approve $VEGA Tokens for staking on Vega', {
timeout: 40000,
}).should('not.exist');
}
}
cy.get(staking.tokenInputSubmit, { timeout: 40000 })
.should('be.enabled').click();
.should('be.enabled')
.click();
cy.contains('can now participate in governance and nominate a validator', {
timeout: 60000,
}).should('be.visible');
}
}).should('be.visible');
};
cy.staking_page_disassociate_tokens = (amount) => {
cy.highlight(`Disassociating ${amount} tokens via Staking Page`);
@ -77,4 +78,4 @@ cy.staking_page_disassociate_all_tokens = () => {
cy.contains('$VEGA tokens have been returned to Ethereum wallet', {
timeout: 60000,
}).should('be.visible');
};
};

View File

@ -1,8 +1,8 @@
import wallet from '../locators/wallet.locators';
const vegaWalletName = Cypress.env("vegaWalletName");
const vegaWalletLocation = Cypress.env("vegaWalletLocation");
const vegaWalletPassphrase = Cypress.env("vegaWalletPassphrase");
const vegaWalletName = Cypress.env('vegaWalletName');
const vegaWalletLocation = Cypress.env('vegaWalletLocation');
const vegaWalletPassphrase = Cypress.env('vegaWalletPassphrase');
cy.vega_wallet_import = () => {
cy.highlight(`Importing Vega Wallet ${vegaWalletName}`);
@ -53,4 +53,4 @@ cy.vega_wallet_check_associated_value_is = (expectedVal) => {
.contains(expectedVal, { timeout: 40000 })
.should('be.visible');
});
};
};

View File

@ -1,33 +1,42 @@
import { StakingBridge, Token, TokenVesting } from '@vegaprotocol/smart-contracts';
import {
StakingBridge,
Token,
TokenVesting,
} from '@vegaprotocol/smart-contracts';
import { ethers, Wallet } from 'ethers';
const vegaWalletMnemonic = Cypress.env("vegaWalletMnemonic");
const vegaWalletPubKey = Cypress.env("vegaWalletPublicKey");
const vegaTokenContractAddress = Cypress.env("vegaTokenContractAddress");
const vegaTokenAddress = Cypress.env("vegaTokenAddress");
const ethWalletPubKey = Cypress.env("ethWalletPublicKey");
const ethStakingBridgeContractAddress = Cypress.env("ethStakingBridgeContractAddress");
const ethProviderUrl = Cypress.env("ethProviderUrl");
const vegaWalletMnemonic = Cypress.env('vegaWalletMnemonic');
const vegaWalletPubKey = Cypress.env('vegaWalletPublicKey');
const vegaTokenContractAddress = Cypress.env('vegaTokenContractAddress');
const vegaTokenAddress = Cypress.env('vegaTokenAddress');
const ethWalletPubKey = Cypress.env('ethWalletPublicKey');
const ethStakingBridgeContractAddress = Cypress.env(
'ethStakingBridgeContractAddress'
);
const ethProviderUrl = Cypress.env('ethProviderUrl');
const getAccount = (number = 0) => `m/44'/60'/0'/0/${number}`;
const transactionTimeout = '50000';
before('Vega wallet teardown prep', function () {
cy.wrap(new ethers.providers.JsonRpcProvider({ url: ethProviderUrl }), {
log: false}).as('provider');
log: false,
}).as('provider');
cy.wrap(Wallet.fromMnemonic(vegaWalletMnemonic, getAccount(0)).privateKey, {
log: false}).then((privateKey) => {
cy.wrap(new Wallet(privateKey, this.provider), { log: false }).as('signer');
})
log: false,
}).then((privateKey) => {
cy.wrap(new Wallet(privateKey, this.provider), { log: false }).as('signer');
});
cy.get("@signer", {log: false}).then((signer => {
cy.get('@signer', { log: false }).then((signer) => {
cy.wrap(new StakingBridge(ethStakingBridgeContractAddress, signer), {
log: false}).as('stakingBridgeContract')
log: false,
}).as('stakingBridgeContract');
cy.wrap(new TokenVesting(vegaTokenContractAddress, signer), {
log: false}).as('vestingContract')
}))
})
log: false,
}).as('vestingContract');
});
});
Cypress.Commands.add('vega_wallet_teardown', function () {
cy.vega_wallet_teardown_staking(this.stakingBridgeContract);
@ -35,45 +44,64 @@ Cypress.Commands.add('vega_wallet_teardown', function () {
cy.vega_wallet_check_associated_value_is('0.000000000000000000');
});
Cypress.Commands.add('vega_wallet_set_specified_approval_amount', function (resetAmount) {
cy.highlight(`Setting token approval amount to ${resetAmount}`);
cy.wrap(new Token(vegaTokenAddress, this.signer), { log: false })
.then((token) => {
cy.wrap(token.approve(ethStakingBridgeContractAddress,
resetAmount.concat('000000000000000000')
),
{ timeout: transactionTimeout, log: false })
.then((tx) => { cy.wait_for_transaction(tx) });
});
// ensure to cy.reload() after running this in order to take affect
});
Cypress.Commands.add(
'vega_wallet_set_specified_approval_amount',
function (resetAmount) {
cy.highlight(`Setting token approval amount to ${resetAmount}`);
cy.wrap(new Token(vegaTokenAddress, this.signer), { log: false }).then(
(token) => {
cy.wrap(
token.approve(
ethStakingBridgeContractAddress,
resetAmount.concat('000000000000000000')
),
{ timeout: transactionTimeout, log: false }
).then((tx) => {
cy.wait_for_transaction(tx);
});
}
);
// ensure to cy.reload() after running this in order to take affect
}
);
cy.vega_wallet_teardown_staking = (stakingBridgeContract) => {
cy.highlight('Tearing down staking tokens from vega wallet if present');
cy.wrap(stakingBridgeContract.stakeBalance(ethWalletPubKey, vegaWalletPubKey), {
timeout: transactionTimeout, log: false})
.then((stake_amount) => {
if (String(stake_amount) != '0') {
cy.wrap(stakingBridgeContract.removeStake(stake_amount, vegaWalletPubKey),
{ timeout: transactionTimeout, log: false })
.then((tx) => { cy.wait_for_transaction(tx) });
}
})
cy.wrap(
stakingBridgeContract.stakeBalance(ethWalletPubKey, vegaWalletPubKey),
{
timeout: transactionTimeout,
log: false,
}
).then((stake_amount) => {
if (String(stake_amount) != '0') {
cy.wrap(
stakingBridgeContract.removeStake(stake_amount, vegaWalletPubKey),
{ timeout: transactionTimeout, log: false }
).then((tx) => {
cy.wait_for_transaction(tx);
});
}
});
};
cy.vega_wallet_teardown_vesting = (vestingContract) => {
cy.highlight('Tearing down vesting tokens from vega wallet if present');
cy.wrap(vestingContract.stakeBalance(ethWalletPubKey, vegaWalletPubKey), {
timeout: transactionTimeout, log: false})
.then((vesting_amount) => {
if (String(vesting_amount) != '0') {
cy.wrap(vestingContract.removeStake(vesting_amount, vegaWalletPubKey),
{ timeout: transactionTimeout, log: false })
.then((tx) => { cy.wait_for_transaction(tx) });
}
timeout: transactionTimeout,
log: false,
}).then((vesting_amount) => {
if (String(vesting_amount) != '0') {
cy.wrap(vestingContract.removeStake(vesting_amount, vegaWalletPubKey), {
timeout: transactionTimeout,
log: false,
}).then((tx) => {
cy.wait_for_transaction(tx);
});
}
});
};
cy.wait_for_transaction = (tx) => {
cy.wrap(tx.wait(1).catch(cy.log), {timeout: transactionTimeout})
};
cy.wrap(tx.wait(1).catch(cy.log), { timeout: transactionTimeout });
};

View File

@ -12,4 +12,4 @@ addMockVegaWalletCommands();
addMockWeb3ProviderCommand();
addHighlightLog();
export * from './lib/graphql-test-utils';
export * from './lib/graphql-test-utils';

View File

@ -1,16 +1,16 @@
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
highlight(message: string): void;
}
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
highlight(message: string): void;
}
}
export function addHighlightLog() {
// @ts-ignore - ignoring Cypress type error which gets resolved when Cypress uses the command
Cypress.Commands.add('highlight', (message) => {
cy.log(`👉 **_${message}_**`);
});
}
}
export function addHighlightLog() {
// @ts-ignore - ignoring Cypress type error which gets resolved when Cypress uses the command
Cypress.Commands.add('highlight', (message) => {
cy.log(`👉 **_${message}_**`);
});
}