Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Replace all uses of account.secondSecret with account.secondPublicKey
Browse files Browse the repository at this point in the history
... because the former was removed in Lisk Core 1.0.0
  • Loading branch information
slaweet committed Jan 23, 2018
1 parent 5ad1431 commit 27f59fc
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/components/account/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TooltipWrapper } from '../timestamp';
import styles from './account.css';

const getStatusTooltip = (props) => {
if (props.secondSignature) {
if (props.secondPublicKey) {
return props.t('This account is protected by a second passphrase');
} else if (props.passphrase) {
return props.t('Passphrase of the account is saved till the end of the session.');
Expand Down Expand Up @@ -39,7 +39,7 @@ const Address = (props) => {
{content}
<span className="status">
<TooltipWrapper tooltip={getStatusTooltip(props)}>
<i className="material-icons">{props.passphrase && !props.secondSignature ? 'lock_open' : 'lock'}</i>
<i className="material-icons">{props.passphrase && !props.secondPublicKey ? 'lock_open' : 'lock'}</i>
</TooltipWrapper>
</span>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/components/authInputs/authInputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { extractPublicKey } from '../../utils/api/account';

class AuthInputs extends React.Component {
componentDidMount() {
if (this.props.account.secondSignature) {
if (this.props.account.secondPublicKey) {
this.props.onChange('secondPassphrase', '');
}
}
Expand Down Expand Up @@ -32,12 +32,12 @@ class AuthInputs extends React.Component {
error={this.props.passphrase.error}
value={this.props.passphrase.value}
onChange={this.onChange.bind(this, 'passphrase')} />)}
{(this.props.account.secondSignature &&
{(this.props.account.secondPublicKey ?
<PassphraseInput label={this.props.t('Second Passphrase')}
className='second-passphrase'
error={this.props.secondPassphrase.error}
value={this.props.secondPassphrase.value}
onChange={this.onChange.bind(this, 'secondPassphrase')} />)}
onChange={this.onChange.bind(this, 'secondPassphrase')} /> : null)}
</span>;
}
}
Expand Down
18 changes: 7 additions & 11 deletions src/components/authInputs/authInputs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ describe('AuthInputs', () => {
let wrapper;
let props;
const passphrase = 'recipe bomb asset salon coil symbol tiger engine assist pact pumpkin visit';
const secondPublicKey = 'fab9d261ea050b9e326d7e11587eccc343a20e64e29d8781b50fd06683cacc88';

beforeEach(() => {
props = {
onChange: sinon.spy(),
secondPassphrase: { },
account: {
passphrase,
secondPublicKey,
},
passphrase: {
value: passphrase,
Expand All @@ -26,48 +28,42 @@ describe('AuthInputs', () => {
};
});

it('should render Input if props.account.secondSignature', () => {
props.account.secondSignature = true;
it('should render Input if props.account.secondPublicKey', () => {
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>);
expect(wrapper.find('Input')).to.have.lengthOf(1);
});

it('should render null if !props.account.secondSignature', () => {
props.account.secondSignature = false;
it('should render null if !props.account.secondPublicKey', () => {
props.account.secondPublicKey = undefined;
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>);
expect(wrapper.html()).to.equal('<span></span>');
});

it('should render null if !props.account.secondSignature', () => {
props.account.secondSignature = false;
it('should render null if !props.account.secondPublicKey', () => {
props.account.secondPublicKey = undefined;
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>);
expect(wrapper.html()).to.equal('<span></span>');
});

it('should call props.onChange when input value changes', () => {
props.account.secondSignature = true;
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>);
wrapper.find('.second-passphrase input').simulate('change', { target: { value: passphrase } });
expect(props.onChange).to.have.been.calledWith('secondPassphrase', passphrase);
});

it('should call props.onChange with an error if entered secondPassphrase does not belong to secondPublicKey', () => {
const error = 'Entered passphrase does not belong to the active account';
props.account.secondSignature = true;
props.account.secondPublicKey = 'fab9d261ea050b9e326d7e11587eccc343a20e64e29d8781b50fd06683cacc88';
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>);
wrapper.find('.second-passphrase input').simulate('change', { target: { value: passphrase } });
expect(props.onChange).to.have.been.calledWith('secondPassphrase', passphrase, error);
});

it('should call props.onChange(\'secondPassphrase\', \'Required\') when input value changes to \'\'', () => {
props.account.secondSignature = true;
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>); wrapper.find('.second-passphrase input').simulate('change', { target: { value: '' } });
expect(props.onChange).to.have.been.calledWith('secondPassphrase', '', 'Required');
});

it('should call props.onChange(\'secondPassphrase\', \'Invalid passphrase\') when input value changes to \'test\'', () => {
props.account.secondSignature = true;
wrapper = mount(<I18nextProvider i18n={ i18n }><AuthInputs {...props} /></I18nextProvider>);
wrapper.find('.second-passphrase input').simulate('change', { target: { value: 'test' } });
expect(props.onChange).to.have.been.calledWith('secondPassphrase', 'test', 'Passphrase should have 12 words, entered passphrase has 1');
Expand Down
2 changes: 1 addition & 1 deletion src/components/authInputs/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('AuthInputsHOC', () => {
secondPassphrase: {},
};
const account = {
secondSignature: 1,
secondPublicKey: 'fab9d261ea050b9e326d7e11587eccc343a20e64e29d8781b50fd06683cacc88',
passphrase,
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Header = props => (
</MenuItem>
}
{
!props.account.secondSignature &&
!props.account.secondPublicKey &&
<MenuItem theme={styles}>
<RelativeLink className={`register-second-passphrase ${styles.menuLink}`}
to='register-second-passphrase'>{props.t('Register second passphrase')}</RelativeLink>
Expand Down
2 changes: 1 addition & 1 deletion src/components/registerDelegate/registerDelegate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const withSecondSecretAccount = {
delegate: {
username: 'lisk-nano',
},
secondSignature: 1,
secondPublicKey: 'fab9d261ea050b9e326d7e11587eccc343a20e64e29d8781b50fd06683cacc88',
};

const props = {
Expand Down
4 changes: 3 additions & 1 deletion src/components/secondPassphrase/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import SecondPassphraseHOC from './index';
describe('SecondPassphraseHOC', () => {
let wrapper;
const peers = {};
const account = { secondSignature: 1 };
const account = {
secondPublicKey: 'fab9d261ea050b9e326d7e11587eccc343a20e64e29d8781b50fd06683cacc88',
};
const store = configureMockStore([])({
peers,
account,
Expand Down
2 changes: 1 addition & 1 deletion src/components/voteDialog/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ chai.use(chaiEnzyme());
const ordinaryAccount = {
passphrase: 'pass',
publicKey: 'key',
secondSignature: 0,
secondPublicKey: undefined,
balance: 10e8,
};
const delegates = [
Expand Down
3 changes: 1 addition & 2 deletions src/components/voteDialog/voteDialog.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ const mountWithRouter = (node, context) => mount(<Router>{node}</Router>, contex
const ordinaryAccount = {
passphrase: 'pass',
publicKey: 'key',
secondSignature: 0,
balance: 10e8,
};
const accountWithSecondPassphrase = {
passphrase: 'awkward service glimpse punch genre calm grow life bullet boil match like',
secondPassphrase: 'forest around decrease farm vanish permit hotel clay senior matter endorse domain',
publicKey: 'key',
secondSignature: 1,
secondPublicKey: 'ec057d8816b18b83a2baac387eebf8af707f8fb565c963476a0e4533e8481eaf',
balance: 10e8,
};
const votes = {
Expand Down

0 comments on commit 27f59fc

Please sign in to comment.