Unverified Commit 9946311f authored by valentinewallace's avatar valentinewallace Committed by GitHub

Merge pull request #1081 from lightninglabs/dev/remove-redundant-getinfo

Remove getInfo call from autopilot action
parents 0ada925f 95ea3fc2
...@@ -8,10 +8,9 @@ import { poll, checkHttpStatus } from '../helper'; ...@@ -8,10 +8,9 @@ import { poll, checkHttpStatus } from '../helper';
import * as log from './log'; import * as log from './log';
class AtplAction { class AtplAction {
constructor(store, grpc, info, db, notification) { constructor(store, grpc, db, notification) {
this._store = store; this._store = store;
this._grpc = grpc; this._grpc = grpc;
this._info = info;
this._db = db; this._db = db;
this._notification = notification; this._notification = notification;
} }
...@@ -64,7 +63,7 @@ class AtplAction { ...@@ -64,7 +63,7 @@ class AtplAction {
*/ */
async updateNodeScores() { async updateNodeScores() {
try { try {
await this._setNetwork(); await this._checkNetwork();
const scores = await this._readNodeScores(); const scores = await this._readNodeScores();
await this._setNodeScores(scores); await this._setNodeScores(scores);
} catch (err) { } catch (err) {
...@@ -72,8 +71,7 @@ class AtplAction { ...@@ -72,8 +71,7 @@ class AtplAction {
} }
} }
async _setNetwork() { async _checkNetwork() {
await this._info.getInfo();
if (!this._store.network) { if (!this._store.network) {
throw new Error('Could not read network'); throw new Error('Could not read network');
} }
......
...@@ -63,7 +63,7 @@ export const auth = new AuthAction( ...@@ -63,7 +63,7 @@ export const auth = new AuthAction(
LocalAuthentication, LocalAuthentication,
Alert Alert
); );
export const autopilot = new AtplAction(store, grpc, info, db, notify); export const autopilot = new AtplAction(store, grpc, db, notify);
payment.listenForUrlMobile(Linking); // enable incoming url handler payment.listenForUrlMobile(Linking); // enable incoming url handler
......
...@@ -42,7 +42,7 @@ export const channel = new ChannelAction(store, grpc, nav, notify); ...@@ -42,7 +42,7 @@ export const channel = new ChannelAction(store, grpc, nav, notify);
export const invoice = new InvoiceAction(store, grpc, nav, notify, Clipboard); export const invoice = new InvoiceAction(store, grpc, nav, notify, Clipboard);
export const payment = new PaymentAction(store, grpc, nav, notify, Clipboard); export const payment = new PaymentAction(store, grpc, nav, notify, Clipboard);
export const setting = new SettingAction(store, wallet, db, ipc); export const setting = new SettingAction(store, wallet, db, ipc);
export const autopilot = new AtplAction(store, grpc, info, db, notify); export const autopilot = new AtplAction(store, grpc, db, notify);
payment.listenForUrl(ipc); // enable incoming url handler payment.listenForUrl(ipc); // enable incoming url handler
......
...@@ -167,7 +167,7 @@ describe('Action Integration Tests', function() { ...@@ -167,7 +167,7 @@ describe('Action Integration Tests', function() {
channels1 = new ChannelAction(store1, grpc1, nav1, notify1); channels1 = new ChannelAction(store1, grpc1, nav1, notify1);
invoice1 = new InvoiceAction(store1, grpc1, nav1, notify1); invoice1 = new InvoiceAction(store1, grpc1, nav1, notify1);
payments1 = new PaymentAction(store1, grpc1, nav1, notify1); payments1 = new PaymentAction(store1, grpc1, nav1, notify1);
autopilot1 = new AtplAction(store1, grpc1, info1, db1, notify1); autopilot1 = new AtplAction(store1, grpc1, db1, notify1);
db2 = sinon.createStubInstance(AppStorage); db2 = sinon.createStubInstance(AppStorage);
nav2 = sinon.createStubInstance(NavAction); nav2 = sinon.createStubInstance(NavAction);
...@@ -180,7 +180,7 @@ describe('Action Integration Tests', function() { ...@@ -180,7 +180,7 @@ describe('Action Integration Tests', function() {
channels2 = new ChannelAction(store2, grpc2, nav2, notify2); channels2 = new ChannelAction(store2, grpc2, nav2, notify2);
invoice2 = new InvoiceAction(store2, grpc2, nav2, notify2); invoice2 = new InvoiceAction(store2, grpc2, nav2, notify2);
payments2 = new PaymentAction(store2, grpc2, nav2, notify2); payments2 = new PaymentAction(store2, grpc2, nav2, notify2);
autopilot2 = new AtplAction(store2, grpc2, info2, db2, notify2); autopilot2 = new AtplAction(store2, grpc2, db2, notify2);
sandbox.stub(autopilot1, 'updateNodeScores').resolves(true); sandbox.stub(autopilot1, 'updateNodeScores').resolves(true);
sandbox.stub(autopilot2, 'updateNodeScores').resolves(true); sandbox.stub(autopilot2, 'updateNodeScores').resolves(true);
......
...@@ -2,7 +2,6 @@ import { Store } from '../../../src/store'; ...@@ -2,7 +2,6 @@ import { Store } from '../../../src/store';
import GrpcAction from '../../../src/action/grpc'; import GrpcAction from '../../../src/action/grpc';
import NotificationAction from '../../../src/action/notification'; import NotificationAction from '../../../src/action/notification';
import AppStorage from '../../../src/action/app-storage'; import AppStorage from '../../../src/action/app-storage';
import InfoAction from '../../../src/action/info';
import AtplAction from '../../../src/action/autopilot'; import AtplAction from '../../../src/action/autopilot';
import * as logger from '../../../src/action/log'; import * as logger from '../../../src/action/log';
import nock from 'nock'; import nock from 'nock';
...@@ -13,7 +12,6 @@ describe('Action Autopilot Unit Test', () => { ...@@ -13,7 +12,6 @@ describe('Action Autopilot Unit Test', () => {
let db; let db;
let grpc; let grpc;
let notify; let notify;
let info;
let autopilot; let autopilot;
let sandbox; let sandbox;
...@@ -25,8 +23,7 @@ describe('Action Autopilot Unit Test', () => { ...@@ -25,8 +23,7 @@ describe('Action Autopilot Unit Test', () => {
grpc = sinon.createStubInstance(GrpcAction); grpc = sinon.createStubInstance(GrpcAction);
db = sinon.createStubInstance(AppStorage); db = sinon.createStubInstance(AppStorage);
notify = sinon.createStubInstance(NotificationAction); notify = sinon.createStubInstance(NotificationAction);
info = sinon.createStubInstance(InfoAction); autopilot = new AtplAction(store, grpc, db, notify);
autopilot = new AtplAction(store, grpc, info, db, notify);
}); });
afterEach(() => { afterEach(() => {
...@@ -87,7 +84,6 @@ describe('Action Autopilot Unit Test', () => { ...@@ -87,7 +84,6 @@ describe('Action Autopilot Unit Test', () => {
}, },
], ],
}; };
info.getInfo.resolves();
store.network = 'testnet'; store.network = 'testnet';
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment