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 Mar 26, 2018
2 parents 69d3700 + 5a3289a commit 8c0290d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
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
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 8c0290d

Please sign in to comment.