Skip to content

Commit

Permalink
Merge pull request #401 from bitfinexcom/staging
Browse files Browse the repository at this point in the history
Release version to master
  • Loading branch information
prdn authored Jul 31, 2024
2 parents 50dc1b4 + 833b178 commit 914ed9e
Show file tree
Hide file tree
Showing 120 changed files with 5,268 additions and 1,628 deletions.
2 changes: 1 addition & 1 deletion bfx-report-ui
Submodule bfx-report-ui updated 74 files
+13 −9 package-lock.json
+1 −1 package.json
+28 −6 public/locales/en/translations.json
+1 −1 src/components/AffiliatesEarnings/AffiliatesEarnings.js
+3 −3 src/components/Auth/LoginOtp/LoginOtp.js
+19 −101 src/components/Derivatives/Derivatives.columns.js
+25 −109 src/components/FundingCreditHistory/FundingCreditHistory.columns.js
+22 −99 src/components/FundingLoanHistory/FundingLoanHistory.columns.js
+19 −90 src/components/FundingOfferHistory/FundingOfferHistory.columns.js
+1 −1 src/components/FundingPayment/FundingPayment.js
+0 −18 src/components/Header/Export/Export.container.js
+10 −11 src/components/Header/Export/Export.js
+1 −1 src/components/Header/Export/index.js
+35 −149 src/components/Invoices/Invoices.columns.js
+114 −189 src/components/Ledgers/Ledgers.columns.js
+1 −1 src/components/Ledgers/Ledgers.js
+80 −133 src/components/PublicFunding/PublicFunding.columns.js
+1 −1 src/components/PublicFunding/PublicFunding.js
+78 −137 src/components/PublicTrades/PublicTrades.columns.js
+1 −1 src/components/PublicTrades/PublicTrades.js
+1 −1 src/components/StakingPayments/StakingPayments.js
+0 −73 src/components/TaxReport/Result/Balances.columns.js
+0 −35 src/components/TaxReport/Result/Result.container.js
+0 −286 src/components/TaxReport/Result/Result.js
+0 −1 src/components/TaxReport/Result/index.js
+0 −38 src/components/TaxReport/Snapshot/Snapshot.container.js
+0 −132 src/components/TaxReport/Snapshot/Snapshot.js
+0 −19 src/components/TaxReport/Snapshot/Snapshots.props.js
+0 −1 src/components/TaxReport/Snapshot/index.js
+112 −0 src/components/TaxReport/TaxReport.columns.js
+0 −18 src/components/TaxReport/TaxReport.container.js
+28 −0 src/components/TaxReport/TaxReport.disclaimer.js
+111 −74 src/components/TaxReport/TaxReport.js
+33 −0 src/components/TaxReport/TaxReport.loader.js
+0 −7 src/components/TaxReport/TaxReport.props.js
+0 −7 src/components/TaxReport/TaxReport.sections.js
+61 −11 src/components/TaxReport/_TaxReport.scss
+1 −1 src/components/TaxReport/index.js
+55 −94 src/components/Tickers/Tickers.columns.js
+1 −1 src/components/Tickers/Tickers.js
+4 −13 src/state/query/saga.js
+2 −0 src/state/sync/saga.js
+18 −41 src/state/taxReport/actions.js
+10 −6 src/state/taxReport/constants.js
+45 −147 src/state/taxReport/reducer.js
+31 −52 src/state/taxReport/saga.js
+15 −42 src/state/taxReport/selectors.js
+2 −2 src/styles/themes/_dark.scss
+44 −45 src/ui/CollapsedTable/CollapsedTable.js
+1 −3 src/ui/CollapsedTable/index.js
+3 −0 src/ui/DataTable/_DataTable.scss
+0 −18 src/ui/DateFormatSelector/DateFormatSelector.container.js
+22 −26 src/ui/DateFormatSelector/DateFormatSelector.js
+0 −9 src/ui/DateFormatSelector/DateFormatSelector.props.js
+1 −3 src/ui/DateFormatSelector/index.js
+0 −13 src/ui/ExportButton/ExportButton.container.js
+0 −20 src/ui/ExportButton/ExportButton.js
+0 −3 src/ui/ExportButton/index.js
+1 −1 src/ui/JSONFormat/_JSONFormat.scss
+0 −18 src/ui/LangMenu/LangMenu.container.js
+15 −12 src/ui/LangMenu/LangMenu.js
+0 −8 src/ui/LangMenu/LangMenu.props.js
+1 −3 src/ui/LangMenu/index.js
+25 −10 src/ui/NavSwitcher/NavSwitcher.js
+0 −9 src/ui/NavSwitcher/NavSwitcher.props.js
+1 −3 src/ui/NavSwitcher/index.js
+0 −18 src/ui/ShowMilliseconds/ShowMilliseconds.container.js
+17 −25 src/ui/ShowMilliseconds/ShowMilliseconds.js
+0 −11 src/ui/ShowMilliseconds/ShowMilliseconds.props.js
+1 −3 src/ui/ShowMilliseconds/index.js
+32 −0 src/ui/TaxStrategySelector/TaxStrategySelector.js
+1 −0 src/ui/TaxStrategySelector/index.js
+12 −0 src/ui/utils.js
+50 −0 src/utils/columns.js
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bfx-reports-framework",
"version": "4.17.2",
"version": "4.18.0",
"description": "Bitfinex reports framework",
"main": "worker.js",
"license": "Apache-2.0",
Expand All @@ -10,6 +10,7 @@
"bfx-facs-scheduler": "git+https://github.com:bitfinexcom/bfx-facs-scheduler.git",
"bfx-report": "git+https://github.com/bitfinexcom/bfx-report.git",
"bfx-svc-boot-js": "https://github.com/bitfinexcom/bfx-svc-boot-js.git",
"bignumber.js": "9.1.2",
"csv": "5.5.3",
"grenache-nodejs-ws": "git+https://github.com:bitfinexcom/grenache-nodejs-ws.git",
"html-pdf": "3.0.1",
Expand Down
267 changes: 267 additions & 0 deletions test/7-interrupt-operations.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
'use strict'

const {
setTimeout
} = require('node:timers/promises')
const path = require('node:path')
const request = require('supertest')
const { assert } = require('chai')

const {
stopEnvironment
} = require('bfx-report/test/helpers/helpers.boot')
const {
rmDB,
rmAllFiles
} = require('bfx-report/test/helpers/helpers.core')

const {
startEnvironment
} = require('./helpers/helpers.boot')
const {
getRServiceProxy,
emptyDB,
rmRf
} = require('./helpers/helpers.core')
const {
createMockRESTv2SrvWithDate
} = require('./helpers/helpers.mock-rest-v2')

process.env.NODE_CONFIG_DIR = path.join(__dirname, 'config')
const { app } = require('bfx-report-express')
const agent = request.agent(app)

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

let wrkReportServiceApi = null
let mockRESTv2Srv = null

const basePath = '/api'
const tempDirPath = path.join(__dirname, '..', 'workers/loc.api/queue/temp')
const dbDirPath = path.join(__dirname, '..', 'db')
const reportFolderPath = path.join(__dirname, '..', 'report-files')
const date = new Date()
const end = date.getTime()
const start = (new Date()).setDate(date.getDate() - 90)

const apiKeys = {
apiKey: 'fake',
apiSecret: 'fake'
}
const email = '[email protected]'
const password = '123Qwerty'
const isSubAccount = false

describe('Interrupt operations', () => {
const params = {
processorQueue: null,
aggregatorQueue: null,
basePath,
auth: {
email,
password,
isSubAccount
},
apiKeys,
date,
end,
start
}
const auth = { token: 'user-token' }

before(async function () {
this.timeout(20000)

mockRESTv2Srv = createMockRESTv2SrvWithDate(start, end, 100)

await rmRf(reportFolderPath)
await rmAllFiles(tempDirPath, ['README.md'])
await rmDB(dbDirPath)
const env = await startEnvironment(false, false, 1)

wrkReportServiceApi = env.wrksReportServiceApi[0]
const rService = wrkReportServiceApi.grc_bfx.api
const rServiceProxy = getRServiceProxy(rService, {
async _getPublicTrades (targetMethod, context, argsList) {
await setTimeout(5000)

return Reflect.apply(...arguments)
}
})
rService._transactionTaxReport.rService = rServiceProxy
params.processorQueue = wrkReportServiceApi.lokue_processor.q
params.aggregatorQueue = wrkReportServiceApi.lokue_aggregator.q

await emptyDB()
})

after(async function () {
this.timeout(20000)

await stopEnvironment()
await rmDB(dbDirPath)
await rmAllFiles(tempDirPath, ['README.md'])
await rmRf(reportFolderPath)

try {
await mockRESTv2Srv.close()
} catch (err) { }
})

signUpTestCase(agent, params, (token) => { auth.token = token })

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

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

assert.isObject(res.body)
assert.propertyVal(res.body, 'id', 5)
assert.isOk(
typeof res.body.result === 'number' ||
res.body.result === 'SYNCHRONIZATION_IS_STARTED'
)
})

getSyncProgressTestCase(agent, { basePath, auth })

it('it should interrupt transaction tax report', async function () {
this.timeout(60000)

const trxTaxReportPromise = agent
.post(`${basePath}/json-rpc`)
.type('json')
.send({
auth,
method: 'getTransactionTaxReport',
params: {
end,
start: start + (45 * 24 * 60 * 60 * 1000),
strategy: 'LIFO'
},
id: 5
})
.expect('Content-Type', /json/)
.expect(200)
const interruptOperationsPromise = setTimeout(1000).then(() => {
return agent
.post(`${basePath}/json-rpc`)
.type('json')
.send({
auth,
method: 'interruptOperations',
params: {
names: ['TRX_TAX_REPORT_INTERRUPTER']
},
id: 5
})
.expect('Content-Type', /json/)
.expect(200)
})

const [
trxTaxReport,
interruptOperations
] = await Promise.all([
trxTaxReportPromise,
interruptOperationsPromise
])

assert.isObject(interruptOperations.body)
assert.propertyVal(interruptOperations.body, 'id', 5)
assert.isBoolean(interruptOperations.body.result)
assert.isOk(interruptOperations.body.result)

assert.isObject(trxTaxReport.body)
assert.propertyVal(trxTaxReport.body, 'id', 5)
assert.isArray(trxTaxReport.body.result)
assert.lengthOf(trxTaxReport.body.result, 0)
})

it('it should not be successfully performed by the interruptOperations method', async function () {
const res = await agent
.post(`${basePath}/json-rpc`)
.type('json')
.send({
auth,
method: 'interruptOperations',
params: {
names: [
'FAKE_INTERRUPTER',
'TRX_TAX_REPORT_INTERRUPTER'
]
},
id: 5
})
.expect('Content-Type', /json/)
.expect(400)

assert.isObject(res.body)
assert.isObject(res.body.error)
assert.propertyVal(res.body.error, 'code', 400)
assert.propertyVal(res.body.error, 'message', 'Args params is not valid')
assert.propertyVal(res.body, 'id', 5)
})

it('it should interrupt transaction tax report after sign-out', async function () {
this.timeout(60000)

const trxTaxReportPromise = agent
.post(`${basePath}/json-rpc`)
.type('json')
.send({
auth,
method: 'getTransactionTaxReport',
params: {
end,
start: start + (45 * 24 * 60 * 60 * 1000),
strategy: 'LIFO'
},
id: 5
})
.expect('Content-Type', /json/)
.expect(200)
const signOutPromise = setTimeout(1000).then(() => {
return agent
.post(`${basePath}/json-rpc`)
.type('json')
.send({
auth,
method: 'signOut',
id: 5
})
.expect('Content-Type', /json/)
.expect(200)
})

const [
trxTaxReport,
signOut
] = await Promise.all([
trxTaxReportPromise,
signOutPromise
])

assert.isObject(signOut.body)
assert.propertyVal(signOut.body, 'id', 5)
assert.isBoolean(signOut.body.result)
assert.isOk(signOut.body.result)

assert.isObject(trxTaxReport.body)
assert.propertyVal(trxTaxReport.body, 'id', 5)
assert.isArray(trxTaxReport.body.result)
assert.lengthOf(trxTaxReport.body.result, 0)
})
})
4 changes: 3 additions & 1 deletion test/config/default.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"app": {
"port": 31339,
"host": "127.0.0.1"
"host": "127.0.0.1",
"httpRpcTimeout": 600000,
"wsRpcTimeout": 3600000
},
"grenacheClient": {
"query": "rest:report:api",
Expand Down
Loading

0 comments on commit 914ed9e

Please sign in to comment.