Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions src/action/index-mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,36 @@ sinon.stub(channel, 'connectAndOpen');
sinon.stub(channel, 'closeSelectedChannel');
sinon.stub(autopilot, 'toggle');

// Stub gRPC seed generation during development.
grpc.sendUnlockerCommand.withArgs('GenSeed').resolves({
cipherSeedMnemonic: [
'empower',
'neglect',
'experience',
'elevator',
'entropy',
'future',
'trust',
'swift',
'pluck',
'easy',
'kite',
'measure',
'engage',
'settle',
'dog',
'manager',
'tool',
'fan',
'neglect',
'conduct',
'blouse',
'stone',
'quit',
'cashew',
],
});

// SET SOME DUMMY DATA DURING DEVELOPMENT
setTimeout(
() => (store.walletAddress = 'ra2XT898gWTp9q2DwMgtwMJsUEh3oMeS4K'),
Expand Down Expand Up @@ -216,32 +246,6 @@ store.selectedTransaction = (store.computedTransactions || []).find(
tx => tx.type === 'bitcoin'
);
store.selectedChannel = store.computedChannels && store.computedChannels[0];
store.seedMnemonic = [
'empower',
'neglect',
'experience',
'elevator',
'entropy',
'future',
'trust',
'swift',
'pluck',
'easy',
'kite',
'measure',
'engage',
'settle',
'dog',
'manager',
'tool',
'fan',
'neglect',
'conduct',
'blouse',
'stone',
'quit',
'cashew',
];
store.logs = [
'[14:00:24.995] [info] Using lnd in path lnd',
'Checking for update',
Expand Down
5 changes: 3 additions & 2 deletions src/action/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class WalletAction {
* @param {number} options.index The seed index
*/
setSeedVerify({ word = '', index }) {
this._store.wallet.seedVerify[index] = word.toLowerCase();
this._store.wallet.seedVerify[index] = word.toLowerCase().trim();
}

/**
Expand Down Expand Up @@ -283,8 +283,9 @@ class WalletAction {
* resetting the current seed index.
* @return {undefined}
*/
initSeed() {
async initSeed() {
this._store.wallet.seedIndex = 0;
await this.generateSeed();
this._nav.goSeedIntro ? this._nav.goSeedIntro() : this._nav.goSeed();
}

Expand Down
4 changes: 2 additions & 2 deletions src/view/select-seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ const SelectSeedView = ({ store, wallet, setting }) => (
</View>
</MainContent>
<GlasButton
onPress={() =>
onPress={async () =>
store.settings.restoring
? wallet.initRestoreWallet()
: wallet.initSeed()
: await wallet.initSeed()
}
>
Next
Expand Down
20 changes: 16 additions & 4 deletions test/unit/action/wallet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ describe('Action Wallet Unit Tests', () => {
wallet.setSeedVerify({ word: 'FOO', index: 1 });
expect(store.wallet.seedVerify[1], 'to equal', 'foo');
});

it('should trim whitespace', () => {
wallet.setSeedVerify({ word: ' foo ', index: 1 });
expect(store.wallet.seedVerify[1], 'to equal', 'foo');
});
});

describe('initSetPassword()', () => {
Expand Down Expand Up @@ -316,17 +321,24 @@ describe('Action Wallet Unit Tests', () => {
});

describe('initSeed()', () => {
it('should clear attributes and navigate to view', () => {
beforeEach(() => {
grpc.sendUnlockerCommand.withArgs('GenSeed').resolves({
cipherSeedMnemonic: 'foo bar',
});
});

it('should clear attributes and navigate to view', async () => {
store.wallet.seedIndex = 42;
wallet.initSeed();
await wallet.initSeed();
expect(store.wallet.seedIndex, 'to equal', 0);
expect(store.seedMnemonic, 'to equal', 'foo bar');
expect(nav.goSeed, 'was called once');
});

it('should navigate to seed intro on mobile', () => {
it('should navigate to seed intro on mobile', async () => {
nav = sinon.createStubInstance(NavActionMobile);
wallet = new WalletAction(store, grpc, db, nav, notification);
wallet.initSeed();
await wallet.initSeed();
expect(nav.goSeedIntro, 'was called once');
});
});
Expand Down