-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(diag): stats replay would stop when reaching eof, should go until…
… buffer has been processed. (#271)
- Loading branch information
1 parent
648c3d6
commit 4794b17
Showing
8 changed files
with
161 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { ReplayStatsProvider } from './replay-stats-provider'; | ||
import { StatData, StatsListener } from './stats-provider'; | ||
import path from 'path'; | ||
|
||
describe('ReplayStatsProvider', () => { | ||
it('should load base64-gzip encoded replay data and trigger events', async () => { | ||
const replayFilePath = path.resolve('./test/diagnostics-replay-compressed.mcstats'); | ||
const replay = new ReplayStatsProvider(replayFilePath); | ||
let statCount = 0; | ||
let statsCallback: StatsListener = { | ||
onStatUpdated: (stat: StatData) => { | ||
statCount++; | ||
expect(stat).toBeDefined(); | ||
}, | ||
}; | ||
replay.addStatListener(statsCallback); | ||
await replay.start(); | ||
expect(statCount).toBeGreaterThan(0); // no idea how many are in there | ||
}); | ||
|
||
it('shoud load uncompressed replay data and trigger events', async () => { | ||
const replayFilePath = path.resolve('./test/diagnostics-replay-uncompressed.mcstats'); | ||
const replay = new ReplayStatsProvider(replayFilePath); | ||
let statCount = 0; | ||
let statsCallback: StatsListener = { | ||
onStatUpdated: (stat: StatData) => { | ||
statCount++; | ||
expect(stat).toBeDefined(); | ||
}, | ||
}; | ||
replay.addStatListener(statsCallback); | ||
await replay.start(); | ||
expect(statCount).toBeGreaterThan(0); | ||
}); | ||
|
||
it('should fire notification on invalid file read', async () => { | ||
const replayFilePath = path.resolve('./test/not-a-valid-file.mcstats'); | ||
const replay = new ReplayStatsProvider(replayFilePath); | ||
let notification = ''; | ||
let statsCallback: StatsListener = { | ||
onNotification: (message: string) => { | ||
notification = message; | ||
}, | ||
}; | ||
replay.addStatListener(statsCallback); | ||
await replay.start(); | ||
expect(notification).toBe('Failed to read replay file.'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{"encoding":"base64-gzip"} | ||
H4sIAAAAAAAACq2RMQvCMBCF/0q5ORRaULSbQ3EVlDqIyJEebTBeS3JVRPzvJg4iiIPS8fE+vntwNxCjj1BM5rNsMs0VyLUnKGAtKOWZWHJQ4EPwUOxuwHiKbYtcWzrobuBQKNCtsbUjfmcaYnIonUuEvHyBShYj11Ce0Q4Ub2T5/r6/qxdRIRtrMVmGuAkinyxs3+J4vhGXVdnfsi06j5cRVjny3eA0rVAfU6oHjWI6TpvQxj+kT+w3+bueImPIf1IP7xkEAUoCAAA= | ||
H4sIAAAAAAAACq2SzWrDMBCEX8XoLEzkn6TxLYfQa6ElPRQTtvJiq5ElI61dQsi7V84hGIyhLbkIlhl9O1rthZGSJ1bk2yeRr1PO6NwhK9grAe0HNJQwznwoPCs+LsxAO6oNmErjUdreBIEz2ShdOTRTT40GHZB1EaGnBdPekKJzEAfQPY49RFJeyyu/Ow5glNYQPYfyLYB8tNNdA4/jPTDZQfwb9g7Ow/cDUjn0tncSX0CeYqx6CaSsieugjv8Q32x/g0/xHt2A7jguTThaZeqlqBoH1DfjlJjlK8EzscnL+6q1SjrrUVpTeTZtJZ3qaEbYrNZ8vc1+ff/Lfs4YQohkxZM0Txc500fjOBiFfj6aH/azqd4/AwAA | ||
H4sIAAAAAAAACq2RQQuCQBCF/4rMWQSlorx1kK5BUYeQGNZBl7YxdsdCxP/e2iGE6FB4fLyPbx5MB6LVBdL5ahnPF7MQpL0RpLATlOxOLAmE4HxwkJ46YLwObYVcGDqrumFfhKAqbQpLPGZKYrIotQ2EnHyBMhYtrS/vaBoabsRJ3ud9+CYOyNoYDDY+7r3IBWtzq3A634TLDvHfsiNah48JVllydWMVbVFdIioahaJrjkrfDn+IXthv8rGeBkaT+6SeqVlmQ0oCAAA= |
Large diffs are not rendered by default.
Oops, something went wrong.