mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Added failing test case for region header validation
fucking PHP... what genius thought it was a good idea to cache file stats without even an attempt at keeping the cache up to date on modifications?
This commit is contained in:
parent
1a24afc6d1
commit
fe731b9018
@ -115,4 +115,19 @@ class RegionLoaderTest extends TestCase{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->region->readChunk($x, $z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that cached filesize() values don't break validation of region headers
|
||||
*/
|
||||
public function testRegionHeaderCachedFilesizeRegression() : void{
|
||||
$this->region->close();
|
||||
$region = new RegionLoader($this->regionPath, 0, 0); //now we have a region, so the header will be verified, triggering two filesize() calls
|
||||
$region->open();
|
||||
$data = str_repeat("hello", 2000);
|
||||
$region->writeChunk(0, 0, $data); //add some data to the end of the file, to make the cached filesize invalid
|
||||
$region->close();
|
||||
$region = new RegionLoader($this->regionPath, 0, 0);
|
||||
$region->open();
|
||||
self::assertSame($data, $region->readChunk(0, 0));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user