Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add estimated sync time to progress state #245

Merged
98 changes: 8 additions & 90 deletions test/3-api-filter-sync-mode-sqlite.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const {
startEnvironment
} = require('./helpers/helpers.boot')
const {
emptyDB,
delay
emptyDB
} = require('./helpers/helpers.core')
const {
createMockRESTv2SrvWithDate
Expand All @@ -31,7 +30,10 @@ process.env.NODE_CONFIG_DIR = path.join(__dirname, 'config')
const { app } = require('bfx-report-express')
const agent = request.agent(app)

const { signUpTestCase } = require('./test-cases')
const {
signUpTestCase,
getSyncProgressTestCase
} = require('./test-cases')

let wrkReportServiceApi = null
let processorQueue = null
Expand Down Expand Up @@ -120,35 +122,7 @@ describe('API filter', () => {
)
})

it('it should be successfully performed by the getSyncProgress method', async function () {
this.timeout(60000)

while (true) {
const res = await agent
.post(`${basePath}/json-rpc`)
.type('json')
.send({
auth,
method: 'getSyncProgress',
id: 5
})
.expect('Content-Type', /json/)
.expect(200)

assert.isObject(res.body)
assert.propertyVal(res.body, 'id', 5)
assert.isNumber(res.body.result)

if (
typeof res.body.result !== 'number' ||
res.body.result === 100
) {
break
}

await delay()
}
})
getSyncProgressTestCase(agent, { basePath, auth })

it('it should be successfully performed by the editPublicTradesConf method', async function () {
this.timeout(5000)
Expand All @@ -175,35 +149,7 @@ describe('API filter', () => {
assert.isOk(res.body.result)
})

it('it should be successfully performed by the getSyncProgress method', async function () {
this.timeout(60000)

while (true) {
const res = await agent
.post(`${basePath}/json-rpc`)
.type('json')
.send({
auth,
method: 'getSyncProgress',
id: 5
})
.expect('Content-Type', /json/)
.expect(200)

assert.isObject(res.body)
assert.propertyVal(res.body, 'id', 5)
assert.isNumber(res.body.result)

if (
typeof res.body.result !== 'number' ||
res.body.result === 100
) {
break
}

await delay()
}
})
getSyncProgressTestCase(agent, { basePath, auth })

it('it should be successfully performed by the editTickersHistoryConf method', async function () {
this.timeout(5000)
Expand All @@ -230,35 +176,7 @@ describe('API filter', () => {
assert.isOk(res.body.result)
})

it('it should be successfully performed by the getSyncProgress method', async function () {
this.timeout(60000)

while (true) {
const res = await agent
.post(`${basePath}/json-rpc`)
.type('json')
.send({
auth,
method: 'getSyncProgress',
id: 5
})
.expect('Content-Type', /json/)
.expect(200)

assert.isObject(res.body)
assert.propertyVal(res.body, 'id', 5)
assert.isNumber(res.body.result)

if (
typeof res.body.result !== 'number' ||
res.body.result === 100
) {
break
}

await delay()
}
})
getSyncProgressTestCase(agent, { basePath, auth })

it('it should be successfully performed by the api methods', async function () {
this.timeout(10000)
Expand Down
96 changes: 6 additions & 90 deletions test/6-update-sub-account.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ const {
} = require('./helpers/helpers.boot')
const {
emptyDB,
getRServiceProxy,
delay
getRServiceProxy
} = require('./helpers/helpers.core')
const {
createMockRESTv2SrvWithDate,
Expand All @@ -31,7 +30,8 @@ const { app } = require('bfx-report-express')
const agent = request.agent(app)

const {
signUpTestCase
signUpTestCase,
getSyncProgressTestCase
} = require('./test-cases')

let wrkReportServiceApi = null
Expand Down Expand Up @@ -289,35 +289,7 @@ describe('Update sub-account', () => {
assert.isOk(res.body.result)
})

it('it should be successfully performed by the getSyncProgress method', async function () {
this.timeout(60000)

while (true) {
const res = await agent
.post(`${basePath}/json-rpc`)
.type('json')
.send({
auth: subAccountAuth,
method: 'getSyncProgress',
id: 5
})
.expect('Content-Type', /json/)
.expect(200)

assert.isObject(res.body)
assert.propertyVal(res.body, 'id', 5)
assert.isNumber(res.body.result)

if (
typeof res.body.result !== 'number' ||
res.body.result === 100
) {
break
}

await delay()
}
})
getSyncProgressTestCase(agent, { basePath, auth: subAccountAuth })

it('it should be successfully performed by the getLedgers method, without params', async function () {
this.timeout(5000)
Expand Down Expand Up @@ -517,35 +489,7 @@ describe('Update sub-account', () => {
assert.isString(res.body.result.token)
})

it('it should be successfully performed by the getSyncProgress method', async function () {
this.timeout(60000)

while (true) {
const res = await agent
.post(`${basePath}/json-rpc`)
.type('json')
.send({
auth: subAccountAuth,
method: 'getSyncProgress',
id: 5
})
.expect('Content-Type', /json/)
.expect(200)

assert.isObject(res.body)
assert.propertyVal(res.body, 'id', 5)
assert.isNumber(res.body.result)

if (
typeof res.body.result !== 'number' ||
res.body.result === 100
) {
break
}

await delay()
}
})
getSyncProgressTestCase(agent, { basePath, auth: subAccountAuth })

it('it should be successfully performed by the getUsers method', async function () {
this.timeout(5000)
Expand Down Expand Up @@ -587,35 +531,7 @@ describe('Update sub-account', () => {
})
})

it('it should be successfully performed by the getSyncProgress method', async function () {
this.timeout(60000)

while (true) {
const res = await agent
.post(`${basePath}/json-rpc`)
.type('json')
.send({
auth: subAccountAuth,
method: 'getSyncProgress',
id: 5
})
.expect('Content-Type', /json/)
.expect(200)

assert.isObject(res.body)
assert.propertyVal(res.body, 'id', 5)
assert.isNumber(res.body.result)

if (
typeof res.body.result !== 'number' ||
res.body.result === 100
) {
break
}

await delay()
}
})
getSyncProgressTestCase(agent, { basePath, auth: subAccountAuth })

it('it should be successfully performed by the getLedgers method, without params', async function () {
this.timeout(5000)
Expand Down
33 changes: 3 additions & 30 deletions test/test-cases/additional-api-sync-mode-sqlite-test-cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ const {
} = require('bfx-report/test/helpers/helpers.tests')

const {
delay,
getParamsArrToTestTimeframeGrouping
} = require('../helpers/helpers.core')
const {
testCsvPathHasCommonFolder
} = require('../helpers/helpers.tests')

const getSyncProgressTestCase = require('./get-sync-progress-test-case')

module.exports = (
agent,
params = {}
Expand Down Expand Up @@ -123,35 +124,7 @@ module.exports = (
)
})

it('it should be successfully performed by the getSyncProgress method', async function () {
this.timeout(60000)

while (true) {
const res = await agent
.post(`${basePath}/json-rpc`)
.type('json')
.send({
auth,
method: 'getSyncProgress',
id: 5
})
.expect('Content-Type', /json/)
.expect(200)

assert.isObject(res.body)
assert.propertyVal(res.body, 'id', 5)
assert.isNumber(res.body.result)

if (
typeof res.body.result !== 'number' ||
res.body.result === 100
) {
break
}

await delay()
}
})
getSyncProgressTestCase(agent, { basePath, auth })

it('it should be successfully performed by the getBalanceHistory method', async function () {
this.timeout(5000)
Expand Down
Loading