tolerate internet latency for initial inputs
All checks were successful
build / image (push) Successful in 1m49s
All checks were successful
build / image (push) Successful in 1m49s
This commit is contained in:
@@ -151,6 +151,34 @@ test("the developer-facing API compiles named sections into a networked game", (
|
||||
);
|
||||
server.step();
|
||||
assert.equal(server.currentState.value, 3);
|
||||
|
||||
// Internet clients can be several ticks behind the server when their first
|
||||
// input arrives. Accept it within the default one-second transport window
|
||||
// and apply it on the next authoritative step.
|
||||
for (let index = 0; index < 6; index++) server.step();
|
||||
assert.deepEqual(
|
||||
server.submitInput(1, {
|
||||
sequence: 2,
|
||||
targetTick: 2,
|
||||
observedTick: 2,
|
||||
input: { amount: 2 },
|
||||
}),
|
||||
{ accepted: true },
|
||||
);
|
||||
server.step();
|
||||
assert.equal(server.currentState.value, 5);
|
||||
|
||||
for (let index = 0; index < 7; index++) server.step();
|
||||
assert.deepEqual(
|
||||
server.submitInput(1, {
|
||||
sequence: 3,
|
||||
targetTick: 2,
|
||||
observedTick: 2,
|
||||
input: { amount: 2 },
|
||||
}),
|
||||
{ accepted: false, reason: "past" },
|
||||
);
|
||||
|
||||
assert.deepEqual(codec.decode(codec.encode({ unicode: "flux ⚡" })), {
|
||||
unicode: "flux ⚡",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user