Skip to content

Commit

Permalink
Update dev-deps and fix typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
notVitaliy committed Nov 27, 2020
1 parent bc71a59 commit c997b12
Show file tree
Hide file tree
Showing 10 changed files with 2,883 additions and 2,371 deletions.
3 changes: 0 additions & 3 deletions config/jest/globalSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ const mongod = new MongodbMemoryServer({
instance: {
dbName: 'jest',
},
binary: {
version: '3.2.18',
},
})

module.exports = async () => {
Expand Down
2 changes: 1 addition & 1 deletion config/jest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
globalSetup: '<rootDir>/config/jest/globalSetup.js',
globalTeardown: '<rootDir>/config/jest/globalTeardown.js',
testEnvironment: '<rootDir>/config/jest/testEnvironment.js',
setupTestFrameworkScriptFile: '<rootDir>/config/jest/setupTests.js',
setupFilesAfterEnv: ['<rootDir>/config/jest/setupTests.js'],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
Expand Down
23 changes: 8 additions & 15 deletions config/jest/testEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,21 @@ const fs = require('fs')

const globalConfigPath = path.join(__dirname, 'globalConfig.json')

module.exports = class MongoEnvironment extends NodeEnvironment {
module.exports = class MongoEnvironment extends (
NodeEnvironment
) {
constructor(config) {
super(config)
}

setup() {
async setup() {
const globalConfig = JSON.parse(fs.readFileSync(globalConfigPath, 'utf-8'))
const { MongoClient } = require('mongodb')

return MongoClient.connect(
globalConfig.mongoUri,
{ useNewUrlParser: true }
)
.then((connection) => {
return connection.db(globalConfig.mongoDBName)
})
.then((db) => {
this.global.db = db
})
.then(() => {
super.setup()
})
const connection = await MongoClient.connect(globalConfig.mongoUri, { useNewUrlParser: true })
const db = connection.db(globalConfig.mongoDBName)
this.global.db = db
super.setup()
}

async teardown() {
Expand Down
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,29 @@
"ws": "^5.2.2"
},
"devDependencies": {
"@types/body-parser": "^1.17.0",
"@types/compression": "^0.0.36",
"@types/cors": "^2.8.4",
"@types/dotenv": "^4.0.3",
"@types/errorhandler": "^0.0.32",
"@types/express": "^4.16.0",
"@types/jest": "^23.3.0",
"@types/mongodb": "^3.1.0",
"@types/mongodb-memory-server": "^1.8.0",
"@types/semver": "^5.5.0",
"@types/ws": "^5.1.2",
"jest": "^23.4.1",
"jest-environment-node": "^23.4.0",
"mongodb-memory-server": "^1.9.0",
"nodemon": "^1.18.4",
"@types/body-parser": "^1.19.0",
"@types/compression": "^1.7.0",
"@types/cors": "^2.8.8",
"@types/dotenv": "^8.2.0",
"@types/errorhandler": "^1.5.0",
"@types/express": "^4.17.9",
"@types/jest": "^26.0.15",
"@types/mongodb": "^3.5.34",
"@types/mongodb-memory-server": "^2.3.0",
"@types/semver": "^7.3.4",
"@types/ws": "^7.4.0",
"jest": "^26.6.3",
"jest-environment-node": "^26.6.2",
"mongodb-memory-server": "^6.9.2",
"nodemon": "^2.0.6",
"pre-commit": "^1.2.2",
"pre-push": "^0.1.1",
"rimraf": "^2.6.2",
"ts-jest": "^23.0.1",
"ts-node": "^7.0.0",
"tsconfig-paths": "^3.4.2",
"tslint": "^5.11.0",
"typescript": "^3.0.1"
"rimraf": "^3.0.2",
"ts-jest": "^26.4.4",
"ts-node": "^9.0.0",
"tsconfig-paths": "^3.9.0",
"tslint": "^6.1.3",
"typescript": "^4.1.2"
},
"pre-commit": [
"lint"
Expand Down
2 changes: 1 addition & 1 deletion src/engine/trade.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { TradeEngine } from './trade'

describe('TradeEngine', () => {
let tradeEngine: TradeEngine
let getNow: jest.Mock<any>
let getNow: jest.SpyInstance<any, any>

beforeEach(() => {
tradeEngine = new TradeEngine(mockExchangeProvider, mockId, 0)
Expand Down
1 change: 0 additions & 1 deletion src/engine/trade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export class TradeEngine {
}

private async tick(symbol: string) {
console.log({ symbol })
if (this.symbols.get(symbol) === SYNC_STATE.STOPPED) return

const storeOpts = { exchange: this.exchange, symbol }
Expand Down
8 changes: 4 additions & 4 deletions src/lib/db/db.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ interface Fee {
rate: number
}

export type TradeWithFee = Trade & { fee: Fee }
export type TradeWithFee = Trade & { fee: number }

export type OrderWithTrades = Filter<Order, 'fee'> & {
trades?: TradeWithFee[]
fee: Fee
fee: number
}

export type OrderCollection = OrderWithTrades & {
Expand Down Expand Up @@ -116,8 +116,8 @@ export type AdjustmentCollection = Adjustment & {
sessionId: string
exchange: string
symbol: string
strategy: string
time: number
strategy?: string
timestamp: number
}

export interface ExchangeAuthentication {
Expand Down
2 changes: 1 addition & 1 deletion src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Server {
}

public init(port = 8080) {
return new Promise((resolve) => {
return new Promise<void>((resolve) => {
this.app.listen(port, () => {
console.log(`Listening on port: ${port}`)
resolve()
Expand Down
6 changes: 1 addition & 5 deletions src/store/order.store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ const order: OrderWithTrades = {
cost: 25,
filled: 0,
remaining: 5,
fee: {
cost: 0,
currency: 'btc',
rate: 0,
},
fee: 0,
}

describe('OrderStore', () => {
Expand Down
Loading

0 comments on commit c997b12

Please sign in to comment.