Skip to content

Commit

Permalink
Merge pull request #596 from LiskHQ/552-account-not-found-error
Browse files Browse the repository at this point in the history
Fix "Account not found" error in Delegates - Closes #552
  • Loading branch information
michaeltomasik authored and faival committed Mar 26, 2018
2 parents 69d3700 + 5a3289a commit fc4f658
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 7 deletions.
2 changes: 0 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ module.exports = function (config) {
excludes: [
'src/components/delegateSidebar/index.js',
'src/components/setting/index.js',
'src/components/setting/setting.js',
'src/components/menuBar/menuBar.js',
'src/components/accountVisual/demo.js',
'src/components/delegateList/votingHeader.js',
'src/components/dialog/index.js',
'src/components/app/index.js',
'src/components/transactions/transactionList.js',
'src/components/relativeLink/index.js',
Expand Down
5 changes: 4 additions & 1 deletion src/components/delegateList/delegateList.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class DelegateList extends React.Component {
}

componentDidMount() {
this.loadVotedDelegates(true);
if (this.props.serverPublicKey) {
this.loadVotedDelegates(true);
}

if (navigator.userAgent) {
const agent = navigator.userAgent;
if (agent.indexOf('Safari') > 0 && agent.indexOf('Chrome') === -1) {
Expand Down
1 change: 1 addition & 0 deletions src/components/delegateList/delegateList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('DelegateList', () => {
delegates,
totalDelegates: 10,
votes,
serverPublicKey: null,
activePeer: {},
address: '16313739661670634666L',
setActiveDialog: sinon.spy(),
Expand Down
1 change: 1 addition & 0 deletions src/components/delegateList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DelegateList from './delegateList';

const mapStateToProps = state => ({
address: state.account.address,
serverPublicKey: state.account.serverPublicKey,
activePeer: state.peers.data,
votes: state.voting.votes,
delegates: state.voting.delegates,
Expand Down
17 changes: 14 additions & 3 deletions src/components/setting/setting.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { MemoryRouter } from 'react-router-dom';
import Setting from './setting';
import i18n from '../../i18n';


describe('Setting', () => {
/* eslint-disable mocha/no-exclusive-tests */
describe.only('Setting', () => {
const history = {
location: {
pathname: '/main/voting',
Expand Down Expand Up @@ -74,6 +74,17 @@ describe('Setting', () => {
expect(wrapper.find('#carouselNav li').at(1).props().className).to.be.include('activeSlide');
});

it('should change advanceMode setting when clicking on checkbox', () => {
wrapper.find('.advancedMode').at(0).simulate('change');
wrapper.update();
clock.tick(500);
wrapper.update();
const expectedCallToSettingsUpdated = {
advancedMode: !settings.advancedMode,
};
expect(settingsUpdated).to.have.been.calledWith(expectedCallToSettingsUpdated);
});

it.skip('should click on .autoLog update the setting', () => {
wrapper.find('.autoLog input').simulate('click');
clock.tick(100);
Expand Down Expand Up @@ -103,4 +114,4 @@ describe('Setting', () => {
expect(i18n.language).to.be.equal('en');
});
});

/* eslint-enable mocha/no-exclusive-tests */
2 changes: 2 additions & 0 deletions src/components/voting/voting.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ describe('Voting', () => {
address: 'address 1',
username: 'username1',
publicKey: 'sample_key',
serverPublicKey: 'sample_key',
rank: 12,
},
{
address: 'address 2',
username: 'username2',
publicKey: 'sample_key',
serverPublicKey: 'sample_key',
rank: 23,
},
];
Expand Down
7 changes: 7 additions & 0 deletions test/constants/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,48 @@ const accounts = {
genesis: {
passphrase: 'wagon stock borrow episode laundry kitten salute link globe zero feed marble',
publicKey: 'c094ebee7ec0c50ebee32918655e089f6e1a604b83bcaa760293c61e0f18ab6f',
serverPublicKey: 'c094ebee7ec0c50ebee32918655e089f6e1a604b83bcaa760293c61e0f18ab6f',
address: '16313739661670634666L',
balance: '9967542080836600',
},
delegate: {
passphrase: 'recipe bomb asset salon coil symbol tiger engine assist pact pumpkin visit',
publicKey: '86499879448d1b0215d59cbf078836e3d7d9d2782d56a2274a568761bff36f19',
serverPublicKey: '86499879448d1b0215d59cbf078836e3d7d9d2782d56a2274a568761bff36f19',
address: '537318935439898807L',
username: 'genesis_17',
balance: 1000e8,
},
'empty account': {
passphrase: 'stay undo beyond powder sand laptop grow gloom apology hamster primary arrive',
publicKey: '197cf311f678406bc72a8edfdc3dffe6f59f49c4550a860e4b68fb20382211d0',
serverPublicKey: '197cf311f678406bc72a8edfdc3dffe6f59f49c4550a860e4b68fb20382211d0',
address: '5932438298200837883L',
balance: 0,
},
'delegate candidate': {
passphrase: 'right cat soul renew under climb middle maid powder churn cram coconut',
publicKey: '35c6b25520fc868b56c83fed6e1c89bb350fb7994a5da0bcea7a4f621f948c7f',
serverPublicKey: '35c6b25520fc868b56c83fed6e1c89bb350fb7994a5da0bcea7a4f621f948c7f',
address: '544792633152563672L',
username: 'test',
},
'second passphrase candidate': {
passphrase: 'dolphin inhale planet talk insect release maze engine guilt loan attend lawn',
publicKey: 'ecf6a5cc0b7168c7948ccfaa652cce8a41256bdac1be62eb52f68cde2fb69f2d',
serverPublicKey: 'ecf6a5cc0b7168c7948ccfaa652cce8a41256bdac1be62eb52f68cde2fb69f2d',
address: '4264113712245538326L',
},
'send all account': {
passphrase: 'oyster flush inquiry bright leopard gas replace ball hold pudding teach swear',
publicKey: 'c5e64031407c3ca8d526bf7404f7c78ab60ea0792e90393a73b3b06a8c8841d4',
serverPublicKey: 'c5e64031407c3ca8d526bf7404f7c78ab60ea0792e90393a73b3b06a8c8841d4',
address: '16422276087748907680L',
},
'second passphrase account': {
passphrase: 'awkward service glimpse punch genre calm grow life bullet boil match like',
publicKey: 'fab9d261ea050b9e326d7e11587eccc343a20e64e29d8781b50fd06683cacc88',
serverPublicKey: 'fab9d261ea050b9e326d7e11587eccc343a20e64e29d8781b50fd06683cacc88',
secondPassphrase: 'forest around decrease farm vanish permit hotel clay senior matter endorse domain',
address: '1155682438012955434L',
balance: 1000e8,
Expand Down
5 changes: 4 additions & 1 deletion test/integration/wallet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,15 @@ describe('@integration: Wallet', () => {
passphrase,
};

if (!options.withPublicKey) {
delete account.serverPublicKey;
}

accountAPIStub.withArgs(match.any).returnsPromise().resolves({ ...account });
store.dispatch(activePeerSet({ network: getNetwork(networks.mainnet.code) }));
accountAPIStub.withArgs(match.any).returnsPromise()
.resolves({
...account,
serverPublicKey: options.withPublicKey ? account.publicKey : undefined,
});
store.dispatch(accountLoggedIn(account));
wrapper = mount(renderWithRouter(Wallet, store, { history: { location: { search: '' } } }));
Expand Down

0 comments on commit fc4f658

Please sign in to comment.