Skip to content
Merged
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
4 changes: 3 additions & 1 deletion packages/neuron-wallet/src/services/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ConnectionStatusSubject } from 'models/subjects/node'
import { CurrentNetworkIDSubject } from 'models/subjects/networks'
import NetworksService from 'services/networks'
import RpcService from 'services/rpc-service'
import { startCkbNode } from 'services/ckb-runner'
import { startCkbNode, stopCkbNode } from 'services/ckb-runner'
import HexUtils from 'utils/hex'
import { BUNDLED_CKB_URL, BUNDLED_LIGHT_CKB_URL } from 'utils/const'
import logger from 'utils/logger'
Expand Down Expand Up @@ -157,8 +157,10 @@ class NodeService {
try {
const network = NetworksService.getInstance().getCurrent()
if (network.type === NetworkType.Light) {
await stopCkbNode()
await CKBLightRunner.getInstance().start()
} else {
await CKBLightRunner.getInstance().stop()
await startCkbNode()
}
this.startedBundledNode = true
Expand Down
9 changes: 8 additions & 1 deletion packages/neuron-wallet/tests/services/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { BUNDLED_CKB_URL } from '../../src/utils/const'
describe('NodeService', () => {
let nodeService: any
const stubbedStartCKBNode = jest.fn()
const stubbedStopCkbNode = jest.fn()
const stubbedStartLightNode = jest.fn()
const stubbedStopLightNode = jest.fn()
const stubbedConnectionStatusSubjectNext = jest.fn()
const stubbedCKBSetNode = jest.fn()
const stubbedGetTipBlockNumber = jest.fn()
Expand All @@ -19,6 +21,7 @@ describe('NodeService', () => {

const resetMocks = () => {
stubbedStartCKBNode.mockReset()
stubbedStopCkbNode.mockReset()
stubbedConnectionStatusSubjectNext.mockReset()
stubbedCKBSetNode.mockReset()
stubbedGetTipBlockNumber.mockReset()
Expand All @@ -27,6 +30,7 @@ describe('NodeService', () => {
stubbedLoggerInfo.mockReset()
stubbedLoggerError.mockReset()
stubbedStartLightNode.mockReset()
stubbedStopLightNode.mockReset()
}

beforeEach(() => {
Expand All @@ -35,7 +39,8 @@ describe('NodeService', () => {

jest.doMock('../../src/services/ckb-runner', () => {
return {
startCkbNode: stubbedStartCKBNode
startCkbNode: stubbedStartCKBNode,
stopCkbNode: stubbedStopCkbNode,
}
})
jest.doMock('../../src/services/networks', () => {
Expand Down Expand Up @@ -92,6 +97,7 @@ describe('NodeService', () => {
getInstance() {
return {
start: stubbedStartLightNode,
stop: stubbedStopLightNode,
}
}
}
Expand Down Expand Up @@ -230,6 +236,7 @@ describe('NodeService', () => {
stubbedNetworsServiceGet.mockReturnValueOnce({type: NetworkType.Light})
await nodeService.startNode()
expect(stubbedStartLightNode).toBeCalled()
expect(stubbedStopCkbNode).toBeCalled()
})
})
});
Expand Down
2 changes: 1 addition & 1 deletion scripts/download-ckb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function download_macos() {

function download_macos_light() {
# macOS
CKB_FILENAME="ckb-light-client_${CKB_LIGHT_VERSION}-x86_64-darwin"
CKB_FILENAME="ckb-light-client_${CKB_LIGHT_VERSION}-x86_64-darwin-portable"
cd $ROOT_DIR/packages/neuron-wallet/bin/mac

curl -O -L "https://github.com/nervosnetwork/ckb-light-client/releases/download/${CKB_LIGHT_VERSION}/${CKB_FILENAME}.tar.gz"
Expand Down