Skip to content

Commit

Permalink
'gaia server' -> 'gaia rest-server'
Browse files Browse the repository at this point in the history
  • Loading branch information
mappum committed Nov 26, 2017
1 parent 076c3db commit a0b7704
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
16 changes: 9 additions & 7 deletions app/src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ app.on('ready', () => createWindow())
async function startBaseserver (home) {
log('startBaseserver', home)
let child = startProcess(SERVER_BINARY, [
'server',
'rest-server',
'serve',
'--home', home // ,
// '--trust-node'
Expand Down Expand Up @@ -236,7 +236,7 @@ async function initBaseserver (chainId, home, node) {
// fs.ensureDirSync(home)
// `baseserver init` to generate config, trust seed
let child = startProcess(SERVER_BINARY, [
'server',
'rest-server',
'init',
'--home', home,
'--chain-id', chainId,
Expand Down Expand Up @@ -398,19 +398,21 @@ async function main () {
log('Picked seed:', nodeIP, 'of', seeds)
// replace port with default RPC port
nodeIP = `${nodeIP.split(':')[0]}:46657`
log(`Initializing baseserver with remote node ${nodeIP}`)
log(`Initializing REST server with remote node ${nodeIP}`)

let baseserverHome = join(root, 'baseserver')
if (init) {
await initBaseserver(chainId, baseserverHome, nodeIP)
}

log('starting gaia server')
log('starting gaia rest-server')
baseserverProcess = await startBaseserver(baseserverHome)
log('gaia server ready')
log('gaia rest-server ready')

// start mock API server on port 8999
mockServer(8999)
if (!TEST) {
// start mock API server on port 8999
mockServer(8999)
}
}
module.exports = Object.assign(
main()
Expand Down
34 changes: 17 additions & 17 deletions test/unit/specs/main.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ describe('Startup Process', () => {
expect(fs.existsSync(testRoot)).toBe(true)
})

it('should init gaia server with correct testnet', async function () {
it('should init gaia rest-server with correct testnet', async function () {
expect(childProcess.spawn.mock.calls
.find(([path, args]) =>
path.includes('gaia') &&
args.includes('server') &&
args.includes('rest-server') &&
args.includes('init') &&
args.splice(1).join('=').includes('--chain-id=gaia-1')
)
).toBeDefined()
})

it('should start gaia server', async function () {
it('should start gaia rest-server', async function () {
expect(childProcess.spawn.mock.calls
.find(([path, args]) =>
path.includes('gaia') &&
args.includes('server') &&
args.includes('rest-server') &&
args.includes('serve')
)
).toBeDefined()
Expand All @@ -92,7 +92,7 @@ describe('Startup Process', () => {
})

// TODO the stdout.on('data') trick doesn't work
xit('should init gaia server accepting the new app hash', async function () {
xit('should init gaia rest-server accepting the new app hash', async function () {
await resetConfigs()
let mockWrite = jest.fn()
childProcessMock((path, args) => ({
Expand All @@ -101,7 +101,7 @@ describe('Startup Process', () => {
},
stdout: {
on: (type, cb) => {
if (type === 'data' && path.includes('gaia') && args[0] === 'server' && args[1] === 'init') {
if (type === 'data' && path.includes('gaia') && args[0] === 'rest-server' && args[1] === 'init') {
cb('Will you accept the hash?')
}
}
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('Startup Process', () => {
},
stdout: {
on: (type, cb) => {
if (type === 'data' && path.includes('gaia') && args[0] === 'server' && args[1] === 'init') {
if (type === 'data' && path.includes('gaia') && args[0] === 'rest-server' && args[1] === 'init') {
cb('Will you accept the hash?')
}
}
Expand Down Expand Up @@ -177,22 +177,22 @@ describe('Startup Process', () => {
expect(fs.existsSync(testRoot)).toBe(true)
})

it('should init gaia server with correct testnet', async function () {
it('should init gaia rest-server with correct testnet', async function () {
expect(childProcess.spawn.mock.calls
.find(([path, args]) =>
path.includes('gaia') &&
args.includes('server') &&
args.includes('rest-server') &&
args.includes('init') &&
args.splice(1).join('=').includes('--chain-id=gaia-1')
)
).toBeDefined()
})

it('should start gaia server', async function () {
it('should start gaia rest-server', async function () {
expect(childProcess.spawn.mock.calls
.find(([path, args]) =>
path.includes('gaia') &&
args.includes('server') &&
args.includes('rest-server') &&
args.includes('serve')
)
).toBeDefined()
Expand Down Expand Up @@ -225,21 +225,21 @@ describe('Startup Process', () => {
describe('Start initialized', function () {
mainSetup()

it('should not init gaia server again', async function () {
it('should not init gaia rest-server again', async function () {
expect(childProcess.spawn.mock.calls
.find(([path, args]) =>
path.includes('gaia') &&
args.includes('server') &&
args.includes('rest-server') &&
args.includes('init')
)
).toBeUndefined()
})

it('should start gaia server', async function () {
it('should start gaia rest-server', async function () {
expect(childProcess.spawn.mock.calls
.find(([path, args]) =>
path.includes('gaia') &&
args.includes('server') &&
args.includes('rest-server') &&
args.includes('serve')
)
).toBeDefined()
Expand Down Expand Up @@ -277,7 +277,7 @@ describe('Startup Process', () => {
afterEach(function () {
main.shutdown()
})
it('should rerun gaia server if gaia server fails', async function () {
it('should rerun gaia rest-server if gaia rest-server fails', async function () {
failingChildProcess('gaia', 'serve')
await initMain()

Expand All @@ -286,7 +286,7 @@ describe('Startup Process', () => {
expect(childProcess.spawn.mock.calls
.find(([path, args]) =>
path.includes('gaia') &&
args.includes('server') &&
args.includes('rest-server') &&
args.includes('serve')
).length
).toBeGreaterThan(1)
Expand Down

0 comments on commit a0b7704

Please sign in to comment.