mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-05-21 14:59:50 -05:00
* 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.
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
let userUtils = require('./../../dev-tools/users-utils');
|
|
let User = userUtils.User;
|
|
|
|
describe('Simulator abstraction layer features', function () {
|
|
describe('Battle', function () {
|
|
describe('player identifiers', function () {
|
|
let p1, p2, room;
|
|
afterEach(function () {
|
|
if (p1) {
|
|
p1.disconnectAll();
|
|
p1.destroy();
|
|
}
|
|
if (p2) {
|
|
p2.disconnectAll();
|
|
p2.destroy();
|
|
}
|
|
if (room) room.destroy();
|
|
});
|
|
|
|
it('should not get players out of sync in rated battles on rename', function () {
|
|
// Regression test for 47263c8749
|
|
let packedTeam = 'Weavile||lifeorb||swordsdance,knockoff,iceshard,iciclecrash|Jolly|,252,,,4,252|||||';
|
|
p1 = new User();
|
|
p2 = new User();
|
|
p1.forceRename("Missingno."); // Don't do this at home
|
|
room = Rooms.global.startBattle(p1, p2, '', packedTeam, packedTeam, {rated: true});
|
|
p1.resetName();
|
|
for (let i = 0; i < room.battle.playerNames.length; i++) {
|
|
let playerName = room.battle.playerNames[i];
|
|
let playerData = room.battle['p' + (i + 1)];
|
|
assert.strictEqual(playerData.name, playerName);
|
|
assert.strictEqual(playerData, room.battle.players[toId(playerName)]);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|