Commit Graph

12 Commits

Author SHA1 Message Date
Ben Davies
5031794f97 Sockets: fix unit tests (#3281)
* Sockets: fix Sockets.killWorker not disconnecting connections

* Sockets: fix unit tests

- Fix crash when constructing mock sockets in certain cases
- Properly prevent workers from writing to stdout
- Fix race conditions in workers-related tests that were causing false
  positives

* Tests: mock workers now more closely imitate sockets' workers

This helps catch cases where messages are being sent in the wrong order
to the workers, e.g. messages sent to sockets that no longer exist.
2017-02-24 05:38:37 -06:00
Taylor Everding
1a1f64fe95 Remove .js extension from requires (#2725) 2016-08-30 00:04:40 -05:00
Guangcong Luo
1a1530f4ff Refactor Connection#rooms to Set
Connection#rooms, previously a null-prototype roomid:room Object,
is now Connection#inRooms, a roomid Set.

This, incidentally, makes it stop retaining rooms, which may make the
GC's job easier and may also lead to unexpected bugs if we get
inconsistent state (we often do get inconsistent state, so look
forward to that!)

The rename is mostly to put it in line with the new User#inRooms,
and for ease of greppability without running into Rooms.rooms.
2016-08-22 03:57:52 -05:00
Ben Davies
5c4834f3fd Tests: tweak user mocks, add Connection tests, fix Trivia tests (#2682)
Worker mocks now have proper ids. Trivia tests now dispose of user objects
rather than letting them stay in memory for the rest of the tests.
2016-08-09 04:02:27 -05:00
Bär Halberkamp
b450b0617f Move things relating to punishments to punishments.js (#2540) 2016-05-02 12:16:25 -07:00
Guangcong Luo
b665660608 Refactor for more ES6 features
Now that nodejs/node#3072 is mostly fixed, we can finally start using
Node 4+ features.

This refactor:

- uses arrow functions where appropriate

  Note that arrow functions still aren't used in Mocha, where `this`
  is sometimes meaningful.

  This also removes the need for .bind() nearly everywhere, as well
  as the `self = this` trick.

- refactors Validator and Connection into ES6 classes

- no longer uses Array#forEach for iterating arrays

  We strongly prefer for (let i = 0; i < arr.length; i++) because of
  performance reasons. Most forEaches have been replaced with for..of,
  though, which is 5x slower than the long-form loop but 2x faster
  than forEach, which is good enough outside of most inner loops.

  The only exception is tournaments, which is due for a more invasive
  refactor soon anyway.
2016-02-10 17:40:21 -06:00
Guangcong Luo
332a65f9c0 Convert some Users tables to ES6 Maps
Specifically, Users.users, Users.connections, and Users.pastUsers
are now ES6 Maps. In theory, this should be a minor performance
upgrade, but we still need to profile to make sure.
2015-12-10 11:52:26 -05:00
Juanma Serrano
c4ac8d6e2f Use strict mode and let and const instead of var
This commit also fixes some duplicated variable declarations.
2015-11-06 21:56:52 -05:00
Ivo Julca
b441375b5a Test: move utility functions to dev-tools/ 2015-07-07 03:08:18 -05:00
Guangcong Luo
e35ed8ebd5 Refactor login
finishRename was a really huge function. This splits it into three
much more manageable functions with more useful names.
2015-06-25 04:43:34 -04:00
Ivo Julca
68aaa48974 Gulpfile: no files are exempt from style checks
- Streams are merged to make sure that all errors and warnings are reported.
- Adds dev dependencies: `merge-stream` and `lazypipe`.
- Tracks a fork of `gulp-jshint` to fix https://github.com/spalger/gulp-jshint/issues/88
2015-02-18 19:51:15 -05:00
Ivo Julca
18ee206833 Add some basic application tests 2015-02-15 13:28:03 -05:00