Skip to content
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

Fix balance update delay - Closes #1539 #1609

Merged
merged 6 commits into from Jan 8, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/store/middlewares/account.js
Expand Up @@ -94,14 +94,17 @@ const passphraseUsed = (store, action) => {
const checkTransactionsAndUpdateAccount = (store, action) => {
const state = store.getState();
const { account, transactions } = state;

store.dispatch(updateTransactionsIfNeeded(
{
transactions,
account,
},
action.data.windowIsFocused,
));
// Adding timeout explained in
// https://github.com/LiskHQ/lisk-hub/pull/1609
setTimeout(() => {
store.dispatch(updateTransactionsIfNeeded(
{
transactions,
account,
},
action.data.windowIsFocused,
));
}, 500);

const tx = action.data.block.transactions || [];
const accountAddress = state.account.address;
Expand All @@ -116,7 +119,7 @@ const checkTransactionsAndUpdateAccount = (store, action) => {
// after a new block with second passphrase registration transaction was received
setTimeout(() => {
updateAccountData(store, action);
}, 5000);
}, 500);
}
};

Expand Down
11 changes: 5 additions & 6 deletions test/cypress/e2e/delegateReg.spec.js
Expand Up @@ -3,11 +3,11 @@ import networks from '../../constants/networks';
import ss from '../../constants/selectors';
import urls from '../../constants/urls';
import enterSecondPassphrase from '../utils/enterSecondPassphrase';
// import compareBalances from '../utils/compareBalances';
import compareBalances from '../utils/compareBalances';

const txConfirmationTimeout = 12000;

// const txDelegateRegPrice = 25;
const txDelegateRegPrice = 25;

const getRandomDelegateName = () => Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);

Expand Down Expand Up @@ -58,10 +58,9 @@ describe('Delegate Registration', () => {
cy.get('@tx').find(ss.transactionAddress).should('have.text', 'Delegate registration');
cy.get('@tx').find(ss.transactionReference).should('have.text', '-');
cy.get('@tx').find(ss.transactionAmountPlaceholder).should('have.text', '-');
// TODO Unskip when #1539 is fixed
// cy.get(ss.headerBalance).invoke('text').as('balanceAfter').then(() => {
// compareBalances(this.balanceBefore, this.balanceAfter, txDelegateRegPrice);
// });
cy.get(ss.headerBalance).invoke('text').as('balanceAfter').then(function () {
compareBalances(this.balanceBefore, this.balanceAfter, txDelegateRegPrice);
});
});

/**
Expand Down
11 changes: 5 additions & 6 deletions test/cypress/e2e/delegates.spec.js
Expand Up @@ -3,10 +3,10 @@ import networks from '../../constants/networks';
import ss from '../../constants/selectors';
import urls from '../../constants/urls';
import enterSecondPassphrase from '../utils/enterSecondPassphrase';
// import compareBalances from '../utils/compareBalances';
import compareBalances from '../utils/compareBalances';

const txConfirmationTimeout = 20000;
// const txVotePrice = 1;
const txVotePrice = 1;

describe('Delegates', () => {
/**
Expand Down Expand Up @@ -139,10 +139,9 @@ describe('Delegates', () => {
cy.get('@dg').find(ss.voteCheckbox, { timeout: txConfirmationTimeout }).should('have.class', 'unchecked');
cy.get(ss.selectionVotingNumber).should('have.text', '0');
cy.get(ss.totalVotingNumber).should('have.text', '100');
// TODO Unskip when #1539 is fixed
// cy.get(ss.headerBalance).invoke('text').as('balanceAfter').then(() => {
// compareBalances(this.balanceBefore, this.balanceAfter, txVotePrice);
// });
cy.get(ss.headerBalance).invoke('text').as('balanceAfter').then(function () {
compareBalances(this.balanceBefore, this.balanceAfter, txVotePrice);
});
// Vote
cy.get(ss.nextBtn).should('be.disabled');
cy.get(ss.delegateRow).eq(0).as('dg');
Expand Down
11 changes: 5 additions & 6 deletions test/cypress/e2e/send.spec.js
Expand Up @@ -3,7 +3,7 @@ import networks from '../../constants/networks';
import urls from '../../constants/urls';
import ss from '../../constants/selectors';
import enterSecondPassphrase from '../utils/enterSecondPassphrase';
// import compareBalances from '../utils/compareBalances';
import compareBalances from '../utils/compareBalances';

const getFollowedAccountObjFromLS = () => JSON.parse(localStorage.getItem('followedAccounts'));

Expand All @@ -19,7 +19,7 @@ const getRandomAddress = () => `23495548666${Math.floor((Math.random() * 8990000
const getRandomAmount = () => Math.floor((Math.random() * 10) + 1);
const getRandomReference = () => Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);

// const transactionFee = 0.1;
const transactionFee = 0.1;

describe('Send', () => {
let randomAddress;
Expand Down Expand Up @@ -70,10 +70,9 @@ describe('Send', () => {
cy.get('@tx').find(ss.transactionAmount).should('have.text', randomAmount.toString());
cy.wait(txConfirmationTimeout);
cy.get('@tx').find(ss.spinner).should('not.exist');
// TODO Unskip when #1539 is fixed
// cy.get(ss.headerBalance).invoke('text').as('balanceAfter').then(() => {
// compareBalances(this.balanceBefore, this.balanceAfter, randomAmount + transactionFee);
// });
cy.get(ss.headerBalance).invoke('text').as('balanceAfter').then(function () {
compareBalances(this.balanceBefore, this.balanceAfter, randomAmount + transactionFee);
});
});

/**
Expand Down