Skip to content

Commit

Permalink
Update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
dguenther committed Nov 12, 2023
1 parent 16c70f2 commit c7df900
Show file tree
Hide file tree
Showing 7 changed files with 424 additions and 667 deletions.
4 changes: 2 additions & 2 deletions ironfish-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"cross-env": "7.0.3",
"eslint-config-ironfish": "*",
"eslint-plugin-deprecation": "2.0.0",
"jest": "29.3.1",
"jest-jasmine2": "29.3.1",
"jest": "29.7.0",
"jest-jasmine2": "29.7.0",
"oclif": "2.6.0",
"rimraf": "^3.0.2",
"tsc-watch": "4.2.9",
Expand Down
8 changes: 4 additions & 4 deletions ironfish-rust-nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
},
"devDependencies": {
"@napi-rs/cli": "2.16.1",
"@types/jest": "29.2.4",
"jest": "29.3.1",
"jest-jasmine2": "29.3.1",
"@types/jest": "29.5.8",
"jest": "29.7.0",
"jest-jasmine2": "29.7.0",
"rimraf": "3.0.2",
"ts-jest": "29.0.3",
"ts-jest": "29.1.1",
"typescript": "4.7.4"
}
}
8 changes: 4 additions & 4 deletions ironfish/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"lint": "tsc -b && tsc -b tsconfig.test.json && eslint --ext .ts,.tsx,.js,.jsx src/",
"lint:fix": "tsc -b && tsc -b tsconfig.test.json && eslint --ext .ts,.tsx,.js,.jsx src/ --fix",
"start": "tsc -b -w",
"test": "tsc -b && tsc -b tsconfig.test.json && cross-env NODE_OPTIONS=--experimental-vm-modules jest --testTimeout=${JEST_TIMEOUT:-5000}",
"test": "tsc -b && tsc -b tsconfig.test.json && node --experimental-vm-modules ../node_modules/jest/bin/jest.js --testTimeout=${JEST_TIMEOUT:-5000}",
"test:slow": "tsc -b && tsc -b tsconfig.test.json && cross-env TEST_INIT_RUST=true jest --testMatch \"**/*.test.slow.ts\" --testPathIgnorePatterns --testTimeout=${JEST_TIMEOUT:-60000}",
"test:perf": "tsc -b && tsc -b tsconfig.test.json && cross-env TEST_INIT_RUST=true jest --testMatch \"**/*.test.perf.ts\" --testPathIgnorePatterns --testTimeout=${JEST_TIMEOUT:-600000} --runInBand",
"test:perf:report": "tsc -b && tsc -b tsconfig.test.json && cross-env TEST_INIT_RUST=true GENERATE_TEST_REPORT=true jest --config jest.config.js --testMatch \"**/*.test.perf.ts\" --testPathIgnorePatterns --testTimeout=${JEST_TIMEOUT:-600000} --ci",
Expand All @@ -68,7 +68,7 @@
},
"devDependencies": {
"@jest/reporters": "29.3.1",
"@jest/types": "29.5.0",
"@jest/types": "29.6.3",
"@types/buffer-json": "2.0.0",
"@types/colors": "1.2.1",
"@types/imurmurhash": "0.1.1",
Expand All @@ -90,11 +90,11 @@
"eslint-plugin-jest": "27.1.6",
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-react-hooks": "4.2.0",
"jest": "29.5.0",
"jest": "29.7.0",
"jest-jasmine2": "29.3.1",
"mitm": "1.7.2",
"prettier": "2.3.2",
"ts-jest": "29.0.3",
"ts-jest": "29.1.1",
"ts-node": "10.9.1",
"typescript": "4.7.4"
},
Expand Down
6 changes: 4 additions & 2 deletions ironfish/src/network/peers/connections/webRtcConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,10 @@ export class WebRtcConnection extends Connection {
try {
sent = this.datachannel.sendMessageBinary(data)
} catch (e) {
this.logger.debug(`Datachannel error occurred while sending message: ${JSON.stringify(e)}`)
this.close()
this.logger.debug(
`Datachannel error occurred while sending message: ${JSON.stringify(e)}`,
)
this.close(e)
sent = false
}

Expand Down
40 changes: 26 additions & 14 deletions ironfish/src/network/peers/peer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,32 +113,48 @@ it('Times out WebRTC handshake', async () => {
expect(peer.state.type).toEqual('CONNECTED')
})

describe('Handles WebRTC message send failure', () => {
it('Handles failure if WebRTC is only connection', async () => {
describe('Handles message send failure', () => {
it('Disconnects peer on error in _send', async () => {
const nodeDataChannel = await import('node-datachannel')

const connection = new WebRtcConnection(nodeDataChannel, true, createRootLogger())
expect(connection.state.type).toEqual('CONNECTING')

const peer = new Peer(null)

// Time out requesting signaling
connection.setState({ type: 'CONNECTED', identity: mockIdentity('peer') })
peer.setWebRtcConnection(connection)
if (!connection['datachannel']) {
throw new Error('Should have datachannel')
}
jest.spyOn(connection['datachannel'], 'sendMessageBinary').mockImplementation(() => {
throw new Error('Error')
const sendSpy = jest.spyOn(connection, '_send').mockImplementation(() => {
throw new Error()
})
jest.spyOn(connection['datachannel'], 'isOpen').mockImplementation(() => true)

expect(peer.state.type).toEqual('CONNECTED')
const result = peer.send(new PeerListRequestMessage())
expect(sendSpy).toHaveBeenCalledTimes(1)
expect(result).toBeNull()
expect(peer.state.type).toEqual('DISCONNECTED')
})

it('Leaves peer connected if _send returns false', () => {
const connection = new WebSocketConnection(
new ws(''),
ConnectionDirection.Outbound,
createRootLogger(),
)
expect(connection.state.type).toEqual('CONNECTING')

const peer = new Peer(null)

connection.setState({ type: 'CONNECTED', identity: mockIdentity('peer') })
peer.setWebSocketConnection(connection)
jest.spyOn(connection, '_send').mockReturnValue(false)

expect(peer.state.type).toEqual('CONNECTED')
const result = peer.send(new PeerListRequestMessage())
expect(result).toBeNull()
expect(peer.state.type).toEqual('CONNECTED')
})

it('Falls back to WebSockets if available and WebRTC send fails', async () => {
const nodeDataChannel = await import('node-datachannel')

Expand All @@ -157,11 +173,7 @@ describe('Handles WebRTC message send failure', () => {
peer.setWebRtcConnection(wrtcConnection)
peer.setWebSocketConnection(wsConnection)

if (wrtcConnection['datachannel']) {
jest.spyOn(wrtcConnection['datachannel'], 'sendMessage').mockImplementation(() => {
throw new Error('Error')
})
}
jest.spyOn(wrtcConnection, '_send').mockReturnValue(false)

const wsSendSpy = jest.spyOn(wsConnection, 'send')
const message = new PeerListRequestMessage()
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"coverage:upload": "lerna exec '\"yarn codecov -t $CODECOV_TOKEN -f ./coverage/clover.xml -F $LERNA_PACKAGE_NAME -p $ROOT_PATH/ --disable=gcov\"'"
},
"devDependencies": {
"@types/jest": "29.2.4",
"@types/jest": "29.5.8",
"@typescript-eslint/eslint-plugin": "4.28.1",
"@typescript-eslint/parser": "4.28.1",
"codecov": "3.8.3",
Expand All @@ -50,12 +50,12 @@
"eslint-plugin-react": "7.24.0",
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-simple-import-sort": "7.0.0",
"jest": "29.3.1",
"jest-jasmine2": "29.3.1",
"jest": "29.7.0",
"jest-jasmine2": "29.7.0",
"lerna": "6.4.1",
"node-gyp": "8.4.1",
"prettier": "2.3.2",
"ts-jest": "29.0.3",
"ts-jest": "29.1.1",
"typescript": "4.7.4"
},
"resolutions": {
Expand Down
Loading

0 comments on commit c7df900

Please sign in to comment.