Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
lightning-bits
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bitsoko services
lightning-bits
Commits
fdf8cfd1
Unverified
Commit
fdf8cfd1
authored
May 03, 2019
by
Tankred Hase
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate autopilot subserver in grpc-mobile.js
parent
d57edd62
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
0 deletions
+78
-0
grpc-mobile.js
src/action/grpc-mobile.js
+24
-0
grpc-mobile.spec.js
test/unit/action/grpc-mobile.spec.js
+54
-0
No files found.
src/action/grpc-mobile.js
View file @
fdf8cfd1
...
...
@@ -56,6 +56,30 @@ class GrpcAction {
return
this
.
_lnrpcRequest
(
method
,
body
);
}
//
// Autopilot grpc client
//
/**
* This is called to initialize the GRPC client to autopilot. Once `autopilotReady`
* is set to true on the store GRPC calls can be made to the client.
* @return {Promise<undefined>}
*/
async
initAutopilot
()
{
this
.
_store
.
autopilotReady
=
true
;
log
.
info
(
'GRPC autopilotReady'
);
}
/**
* Wrapper function to execute calls to the autopilot grpc client.
* @param {string} method The autopilot GRPC api to call
* @param {Object} body The payload passed to the api
* @return {Promise<Object>}
*/
async
sendAutopilotCommand
(
method
,
body
)
{
return
this
.
_lnrpcRequest
(
method
,
body
);
}
//
// Lightning (lnd) grpc client
//
...
...
test/unit/action/grpc-mobile.spec.js
View file @
fdf8cfd1
...
...
@@ -86,6 +86,60 @@ describe('Action GRPC Mobile Unit Tests', () => {
});
});
describe
(
'initAutopilot()'
,
()
=>
{
it
(
'should set autopilotReady'
,
async
()
=>
{
await
grpc
.
initAutopilot
();
expect
(
store
.
autopilotReady
,
'to be'
,
true
);
});
});
describe
(
'sendAutopilotCommand()'
,
()
=>
{
it
(
'should work for Status'
,
async
()
=>
{
LndReactModuleStub
.
sendCommand
.
resolves
({
data
:
grpc
.
_serializeResponse
(
'Status'
),
});
await
grpc
.
sendAutopilotCommand
(
'Status'
);
expect
(
LndReactModuleStub
.
sendCommand
,
'was called with'
,
'Status'
,
''
);
});
it
(
'should work for SetScores'
,
async
()
=>
{
LndReactModuleStub
.
sendCommand
.
resolves
({
data
:
grpc
.
_serializeResponse
(
'SetScores'
),
});
await
grpc
.
sendAutopilotCommand
(
'SetScores'
,
{
heuristic
:
'externalscore'
,
scores
:
{
'some-pubkey'
:
0.14035087
},
});
expect
(
LndReactModuleStub
.
sendCommand
,
'was called with'
,
'SetScores'
,
'Cg1leHRlcm5hbHNjb3JlEhYKC3NvbWUtcHVia2V5ESe9Tm4E98E/'
);
});
it
(
'should work for QueryScores'
,
async
()
=>
{
LndReactModuleStub
.
sendCommand
.
resolves
({
data
:
grpc
.
_serializeResponse
(
'QueryScores'
),
});
await
grpc
.
sendAutopilotCommand
(
'QueryScores'
);
expect
(
LndReactModuleStub
.
sendCommand
,
'was called once'
);
});
it
(
'should work for ModifyStatus'
,
async
()
=>
{
LndReactModuleStub
.
sendCommand
.
resolves
({
data
:
grpc
.
_serializeResponse
(
'ModifyStatus'
),
});
await
grpc
.
sendAutopilotCommand
(
'ModifyStatus'
,
{
enable
:
true
});
expect
(
LndReactModuleStub
.
sendCommand
,
'was called with'
,
'ModifyStatus'
,
'CAE='
);
});
});
describe
(
'initLnd()'
,
()
=>
{
it
(
'should set lndReady'
,
async
()
=>
{
LndReactModuleStub
.
start
.
resolves
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment