From 09531cbfdedc2787306243e35039668144261f04 Mon Sep 17 00:00:00 2001 From: Quentin Roques Date: Thu, 20 Jun 2024 19:25:57 +1100 Subject: [PATCH] fix: file handling (#10) --- src/Assembler.php | 1 + src/ResilientData.php | 32 +++++++++++++++-------- tests/fixtures/fragments/fragment_0.txt | 2 +- tests/fixtures/fragments/fragment_1.txt | 2 +- tests/fixtures/fragments/fragment_2.txt | 2 +- tests/fixtures/fragments/fragment_3.txt | 2 +- tests/fixtures/fragments/fragment_4.txt | 2 +- tests/fixtures/image.png | Bin 0 -> 8022 bytes tests/integration/SplitThenMergeTest.php | 29 ++++++++++++++++++-- tests/unit/AssemblerTest.php | 14 +++++----- tests/unit/SplitterTest.php | 2 +- 11 files changed, 62 insertions(+), 26 deletions(-) create mode 100644 tests/fixtures/image.png diff --git a/src/Assembler.php b/src/Assembler.php index beedb81..d737951 100644 --- a/src/Assembler.php +++ b/src/Assembler.php @@ -36,6 +36,7 @@ public function assemble(array $fragments): ResilientData } } } + $resilientData = ResilientData::fromBinaryData($data); if (!$resilientData->getHash()->equals($manifest->resilientDataHash)) { diff --git a/src/ResilientData.php b/src/ResilientData.php index 81eaa5f..fe9affb 100644 --- a/src/ResilientData.php +++ b/src/ResilientData.php @@ -6,9 +6,25 @@ class ResilientData { - public function __construct(private readonly mixed $data) {} + private function __construct(private readonly string $data) {} - public function getData(): mixed + public static function fromFile(string $filename): self + { + $data = file_get_contents($filename); + + if (false === $data) { + throw new \RuntimeException('Could not read the file'); + } + + return new self($data); + } + + public static function fromString(string $data): self + { + return new self($data); + } + + public function getData(): string { return $this->data; } @@ -20,17 +36,11 @@ public function getHash(): Hash public function getBinaryData(): string { - $stringData = json_encode($this->data); - - if (false === $stringData) { - throw new \RuntimeException('Failed to encode data to JSON: '.json_last_error_msg()); - } - - return base64_encode($stringData); + return base64_encode($this->data); } - public static function fromBinaryData(string $data): self + public static function fromBinaryData(string $binaryData): self { - return new self(json_decode(base64_decode($data))); + return new self(base64_decode($binaryData)); } } diff --git a/tests/fixtures/fragments/fragment_0.txt b/tests/fixtures/fragments/fragment_0.txt index 535753c..44212eb 100644 --- a/tests/fixtures/fragments/fragment_0.txt +++ b/tests/fixtures/fragments/fragment_0.txt @@ -1 +1 @@ -O:30:"Qroques\ResilientData\Fragment":3:{s:10:"dataChunks";O:32:"Qroques\ResilientData\Collection":1:{s:5:"items";a:6:{i:0;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:7;}s:4:"data";s:274:"IkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0LCBjb25zZWN0ZXR1ciBhZGlwaXNjaW5nIGVsaXQuIFNlZCBub24gcmlzdXMuIFN1c3BlbmRpc3NlIGxlY3R1cyB0b3J0b3IsIGRpZ25pc3NpbSBzaXQgYW1ldCwgYWRpcGlzY2luZyBuZWMsIHVsdHJpY2llcyBzZWQsIGRvbG9yLiBDcmFzIGVsZW1lbnR1bSB1bHRyaWNlcyBkaWFtLiBNYWVjZW5hcyBsaWd1bGEgbW";}i:1;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:11;}s:4:"data";s:274:"Fzc2EsIHZhcml1cyBhLCBzZW1wZXIgY29uZ3VlLCBldWlzbW9kIG5vbiwgbWkuIFByb2luIHBvcnR0aXRvciwgb3JjaSBuZWMgbm9udW1teSBtb2xlc3RpZSwgZW5pbSBlc3QgZWxlaWZlbmQgbWksIG5vbiBmZXJtZW50dW0gZGlhbSBuaXNsIHNpdCBhbWV0IGVyYXQuIER1aXMgc2VtcGVyLiBEdWlzIGFyY3UgbWFzc2EsIHNjZWxlcmlzcXVlIHZpdGFlLCBjb25z";}i:2;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:13;}s:4:"data";s:274:"ZXF1YXQgaW4sIHByZXRpdW0gYSwgZW5pbS4gUGVsbGVudGVzcXVlIGNvbmd1ZS4gVXQgaW4gcmlzdXMgdm9sdXRwYXQgbGliZXJvIHBoYXJldHJhIHRlbXBvci4gQ3JhcyB2ZXN0aWJ1bHVtIGJpYmVuZHVtIGF1Z3VlLiBQcmFlc2VudCBlZ2VzdGFzIGxlbyBpbiBwZWRlLiBQcmFlc2VudCBibGFuZGl0IG9kaW8gZXUgZW5pbS4gUGVsbGVudGVzcXVlIHNlZCBkdW";}i:3;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:19;}s:4:"data";s:274:"b24gZGlhbSBzb2RhbGVzIGhlbmRyZXJpdC5cblV0IHZlbGl0IG1hdXJpcywgZWdlc3RhcyBzZWQsIGdyYXZpZGEgbmVjLCBvcm5hcmUgdXQsIG1pLiBBZW5lYW4gdXQgb3JjaSB2ZWwgbWFzc2Egc3VzY2lwaXQgcHVsdmluYXIuIE51bGxhIHNvbGxpY2l0dWRpbi4gRnVzY2UgdmFyaXVzLCBsaWd1bGEgbm9uIHRlbXB1cyBhbGlxdWFtLCBudW5jIHR1cnBpcyB1bG";}i:4;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:21;}s:4:"data";s:274:"xhbWNvcnBlciBuaWJoLCBpbiB0ZW1wdXMgc2FwaWVuIGVyb3Mgdml0YWUgbGlndWxhLiBQZWxsZW50ZXNxdWUgcmhvbmN1cyBudW5jIGV0IGF1Z3VlLiBJbnRlZ2VyIGlkIGZlbGlzLiBDdXJhYml0dXIgYWxpcXVldCBwZWxsZW50ZXNxdWUgZGlhbS4gSW50ZWdlciBxdWlzIG1ldHVzIHZpdGFlIGVsaXQgbG9ib3J0aXMgZWdlc3Rhcy4gTG9yZW0gaXBzdW0gZG9s";}i:5;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:25;}s:4:"data";s:274:"RhZSBlcmF0LiBQcm9pbiBmZXVnaWF0LCBhdWd1ZSBub24gZWxlbWVudHVtIHBvc3VlcmUsIG1ldHVzIHB1cnVzIGlhY3VsaXMgbGVjdHVzLCBldCB0cmlzdGlxdWUgbGlndWxhIGp1c3RvIHZpdGFlIG1hZ25hLlxuQWxpcXVhbSBjb252YWxsaXMgc29sbGljaXR1ZGluIHB1cnVzLiBQcmFlc2VudCBhbGlxdWFtLCBlbmltIGF0IGZlcm1lbnR1bSBtb2xsaXMsIGxp";}}}s:10:"identifier";O:40:"Qroques\ResilientData\FragmentIdentifier":1:{s:5:"value";i:0;}s:8:"manifest";O:30:"Qroques\ResilientData\Manifest":2:{s:17:"resilientDataHash";O:26:"Qroques\ResilientData\Hash":1:{s:4:"hash";s:64:"e5a00d17fdf9193553d3201f96594ed5ebf28c1932c1a19057863f67a4525972";}s:22:"splittingConfiguration";O:44:"Qroques\ResilientData\SplittingConfiguration":2:{s:17:"numberOfFragments";i:5;s:14:"acceptableLoss";i:2;}}} \ No newline at end of file +O:30:"Qroques\ResilientData\Fragment":3:{s:10:"dataChunks";O:32:"Qroques\ResilientData\Collection":1:{s:5:"items";a:6:{i:0;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:7;}s:4:"data";s:274:"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gU2VkIG5vbiByaXN1cy4gU3VzcGVuZGlzc2UgbGVjdHVzIHRvcnRvciwgZGlnbmlzc2ltIHNpdCBhbWV0LCBhZGlwaXNjaW5nIG5lYywgdWx0cmljaWVzIHNlZCwgZG9sb3IuIENyYXMgZWxlbWVudHVtIHVsdHJpY2VzIGRpYW0uIE1hZWNlbmFzIGxpZ3VsYSBtYX";}i:1;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:11;}s:4:"data";s:274:"NzYSwgdmFyaXVzIGEsIHNlbXBlciBjb25ndWUsIGV1aXNtb2Qgbm9uLCBtaS4gUHJvaW4gcG9ydHRpdG9yLCBvcmNpIG5lYyBub251bW15IG1vbGVzdGllLCBlbmltIGVzdCBlbGVpZmVuZCBtaSwgbm9uIGZlcm1lbnR1bSBkaWFtIG5pc2wgc2l0IGFtZXQgZXJhdC4gRHVpcyBzZW1wZXIuIER1aXMgYXJjdSBtYXNzYSwgc2NlbGVyaXNxdWUgdml0YWUsIGNvbnNl";}i:2;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:13;}s:4:"data";s:274:"cXVhdCBpbiwgcHJldGl1bSBhLCBlbmltLiBQZWxsZW50ZXNxdWUgY29uZ3VlLiBVdCBpbiByaXN1cyB2b2x1dHBhdCBsaWJlcm8gcGhhcmV0cmEgdGVtcG9yLiBDcmFzIHZlc3RpYnVsdW0gYmliZW5kdW0gYXVndWUuIFByYWVzZW50IGVnZXN0YXMgbGVvIGluIHBlZGUuIFByYWVzZW50IGJsYW5kaXQgb2RpbyBldSBlbmltLiBQZWxsZW50ZXNxdWUgc2VkIGR1aS";}i:3;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:19;}s:4:"data";s:274:"biBkaWFtIHNvZGFsZXMgaGVuZHJlcml0LgpVdCB2ZWxpdCBtYXVyaXMsIGVnZXN0YXMgc2VkLCBncmF2aWRhIG5lYywgb3JuYXJlIHV0LCBtaS4gQWVuZWFuIHV0IG9yY2kgdmVsIG1hc3NhIHN1c2NpcGl0IHB1bHZpbmFyLiBOdWxsYSBzb2xsaWNpdHVkaW4uIEZ1c2NlIHZhcml1cywgbGlndWxhIG5vbiB0ZW1wdXMgYWxpcXVhbSwgbnVuYyB0dXJwaXMgdWxsYW";}i:4;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:21;}s:4:"data";s:274:"1jb3JwZXIgbmliaCwgaW4gdGVtcHVzIHNhcGllbiBlcm9zIHZpdGFlIGxpZ3VsYS4gUGVsbGVudGVzcXVlIHJob25jdXMgbnVuYyBldCBhdWd1ZS4gSW50ZWdlciBpZCBmZWxpcy4gQ3VyYWJpdHVyIGFsaXF1ZXQgcGVsbGVudGVzcXVlIGRpYW0uIEludGVnZXIgcXVpcyBtZXR1cyB2aXRhZSBlbGl0IGxvYm9ydGlzIGVnZXN0YXMuIExvcmVtIGlwc3VtIGRvbG9y";}i:5;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:25;}s:4:"data";s:274:"UgZXJhdC4gUHJvaW4gZmV1Z2lhdCwgYXVndWUgbm9uIGVsZW1lbnR1bSBwb3N1ZXJlLCBtZXR1cyBwdXJ1cyBpYWN1bGlzIGxlY3R1cywgZXQgdHJpc3RpcXVlIGxpZ3VsYSBqdXN0byB2aXRhZSBtYWduYS4KQWxpcXVhbSBjb252YWxsaXMgc29sbGljaXR1ZGluIHB1cnVzLiBQcmFlc2VudCBhbGlxdWFtLCBlbmltIGF0IGZlcm1lbnR1bSBtb2xsaXMsIGxpZ3Vs";}}}s:10:"identifier";O:40:"Qroques\ResilientData\FragmentIdentifier":1:{s:5:"value";i:0;}s:8:"manifest";O:30:"Qroques\ResilientData\Manifest":2:{s:17:"resilientDataHash";O:26:"Qroques\ResilientData\Hash":1:{s:4:"hash";s:64:"ccec74f22f298deb6bc62053b4043839561ea1a08650e7d79f798b6e018202a6";}s:22:"splittingConfiguration";O:44:"Qroques\ResilientData\SplittingConfiguration":2:{s:17:"numberOfFragments";i:5;s:14:"acceptableLoss";i:2;}}} \ No newline at end of file diff --git a/tests/fixtures/fragments/fragment_1.txt b/tests/fixtures/fragments/fragment_1.txt index f905cd8..35a2fe0 100644 --- a/tests/fixtures/fragments/fragment_1.txt +++ b/tests/fixtures/fragments/fragment_1.txt @@ -1 +1 @@ -O:30:"Qroques\ResilientData\Fragment":3:{s:10:"dataChunks";O:32:"Qroques\ResilientData\Collection":1:{s:5:"items";a:6:{i:0;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:7;}s:4:"data";s:274:"IkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0LCBjb25zZWN0ZXR1ciBhZGlwaXNjaW5nIGVsaXQuIFNlZCBub24gcmlzdXMuIFN1c3BlbmRpc3NlIGxlY3R1cyB0b3J0b3IsIGRpZ25pc3NpbSBzaXQgYW1ldCwgYWRpcGlzY2luZyBuZWMsIHVsdHJpY2llcyBzZWQsIGRvbG9yLiBDcmFzIGVsZW1lbnR1bSB1bHRyaWNlcyBkaWFtLiBNYWVjZW5hcyBsaWd1bGEgbW";}i:1;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:11;}s:4:"data";s:274:"Fzc2EsIHZhcml1cyBhLCBzZW1wZXIgY29uZ3VlLCBldWlzbW9kIG5vbiwgbWkuIFByb2luIHBvcnR0aXRvciwgb3JjaSBuZWMgbm9udW1teSBtb2xlc3RpZSwgZW5pbSBlc3QgZWxlaWZlbmQgbWksIG5vbiBmZXJtZW50dW0gZGlhbSBuaXNsIHNpdCBhbWV0IGVyYXQuIER1aXMgc2VtcGVyLiBEdWlzIGFyY3UgbWFzc2EsIHNjZWxlcmlzcXVlIHZpdGFlLCBjb25z";}i:2;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:14;}s:4:"data";s:274:"kgdXQgYXVndWUgYmxhbmRpdCBzb2RhbGVzLiBWZXN0aWJ1bHVtIGFudGUgaXBzdW0gcHJpbWlzIGluIGZhdWNpYnVzIG9yY2kgbHVjdHVzIGV0IHVsdHJpY2VzIHBvc3VlcmUgY3ViaWxpYSBDdXJhZTsgQWxpcXVhbSBuaWJoLiBNYXVyaXMgYWMgbWF1cmlzIHNlZCBwZWRlIHBlbGxlbnRlc3F1ZSBmZXJtZW50dW0uIE1hZWNlbmFzIGFkaXBpc2NpbmcgYW50ZSBu";}i:3;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:19;}s:4:"data";s:274:"b24gZGlhbSBzb2RhbGVzIGhlbmRyZXJpdC5cblV0IHZlbGl0IG1hdXJpcywgZWdlc3RhcyBzZWQsIGdyYXZpZGEgbmVjLCBvcm5hcmUgdXQsIG1pLiBBZW5lYW4gdXQgb3JjaSB2ZWwgbWFzc2Egc3VzY2lwaXQgcHVsdmluYXIuIE51bGxhIHNvbGxpY2l0dWRpbi4gRnVzY2UgdmFyaXVzLCBsaWd1bGEgbm9uIHRlbXB1cyBhbGlxdWFtLCBudW5jIHR1cnBpcyB1bG";}i:4;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:22;}s:4:"data";s:274:"b3Igc2l0IGFtZXQsIGNvbnNlY3RldHVlciBhZGlwaXNjaW5nIGVsaXQuIE1vcmJpIHZlbCBlcmF0IG5vbiBtYXVyaXMgY29udmFsbGlzIHZlaGljdWxhLiBOdWxsYSBldCBzYXBpZW4uIEludGVnZXIgdG9ydG9yIHRlbGx1cywgYWxpcXVhbSBmYXVjaWJ1cywgY29udmFsbGlzIGlkLCBjb25ndWUgZXUsIHF1YW0uIE1hdXJpcyB1bGxhbWNvcnBlciBmZWxpcyB2aX";}i:5;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:26;}s:4:"data";s:274:"Z3VsYSBtYXNzYSBhZGlwaXNjaW5nIG5pc2wsIGFjIGV1aXNtb2QgbmliaCBuaXNsIGV1IGxlY3R1cy4gRnVzY2UgdnVscHV0YXRlIHNlbSBhdCBzYXBpZW4uIFZpdmFtdXMgbGVvLiBBbGlxdWFtIGV1aXNtb2QgbGliZXJvIGV1IGVuaW0uIE51bGxhIG5lYyBmZWxpcyBzZWQgbGVvIHBsYWNlcmF0IGltcGVyZGlldC4gQWVuZWFuIHN1c2NpcGl0IG51bGxhIGluIG";}}}s:10:"identifier";O:40:"Qroques\ResilientData\FragmentIdentifier":1:{s:5:"value";i:1;}s:8:"manifest";O:30:"Qroques\ResilientData\Manifest":2:{s:17:"resilientDataHash";O:26:"Qroques\ResilientData\Hash":1:{s:4:"hash";s:64:"e5a00d17fdf9193553d3201f96594ed5ebf28c1932c1a19057863f67a4525972";}s:22:"splittingConfiguration";O:44:"Qroques\ResilientData\SplittingConfiguration":2:{s:17:"numberOfFragments";i:5;s:14:"acceptableLoss";i:2;}}} \ No newline at end of file +O:30:"Qroques\ResilientData\Fragment":3:{s:10:"dataChunks";O:32:"Qroques\ResilientData\Collection":1:{s:5:"items";a:6:{i:0;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:7;}s:4:"data";s:274:"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gU2VkIG5vbiByaXN1cy4gU3VzcGVuZGlzc2UgbGVjdHVzIHRvcnRvciwgZGlnbmlzc2ltIHNpdCBhbWV0LCBhZGlwaXNjaW5nIG5lYywgdWx0cmljaWVzIHNlZCwgZG9sb3IuIENyYXMgZWxlbWVudHVtIHVsdHJpY2VzIGRpYW0uIE1hZWNlbmFzIGxpZ3VsYSBtYX";}i:1;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:11;}s:4:"data";s:274:"NzYSwgdmFyaXVzIGEsIHNlbXBlciBjb25ndWUsIGV1aXNtb2Qgbm9uLCBtaS4gUHJvaW4gcG9ydHRpdG9yLCBvcmNpIG5lYyBub251bW15IG1vbGVzdGllLCBlbmltIGVzdCBlbGVpZmVuZCBtaSwgbm9uIGZlcm1lbnR1bSBkaWFtIG5pc2wgc2l0IGFtZXQgZXJhdC4gRHVpcyBzZW1wZXIuIER1aXMgYXJjdSBtYXNzYSwgc2NlbGVyaXNxdWUgdml0YWUsIGNvbnNl";}i:2;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:14;}s:4:"data";s:274:"B1dCBhdWd1ZSBibGFuZGl0IHNvZGFsZXMuIFZlc3RpYnVsdW0gYW50ZSBpcHN1bSBwcmltaXMgaW4gZmF1Y2lidXMgb3JjaSBsdWN0dXMgZXQgdWx0cmljZXMgcG9zdWVyZSBjdWJpbGlhIEN1cmFlOyBBbGlxdWFtIG5pYmguIE1hdXJpcyBhYyBtYXVyaXMgc2VkIHBlZGUgcGVsbGVudGVzcXVlIGZlcm1lbnR1bS4gTWFlY2VuYXMgYWRpcGlzY2luZyBhbnRlIG5v";}i:3;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:19;}s:4:"data";s:274:"biBkaWFtIHNvZGFsZXMgaGVuZHJlcml0LgpVdCB2ZWxpdCBtYXVyaXMsIGVnZXN0YXMgc2VkLCBncmF2aWRhIG5lYywgb3JuYXJlIHV0LCBtaS4gQWVuZWFuIHV0IG9yY2kgdmVsIG1hc3NhIHN1c2NpcGl0IHB1bHZpbmFyLiBOdWxsYSBzb2xsaWNpdHVkaW4uIEZ1c2NlIHZhcml1cywgbGlndWxhIG5vbiB0ZW1wdXMgYWxpcXVhbSwgbnVuYyB0dXJwaXMgdWxsYW";}i:4;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:22;}s:4:"data";s:274:"IHNpdCBhbWV0LCBjb25zZWN0ZXR1ZXIgYWRpcGlzY2luZyBlbGl0LiBNb3JiaSB2ZWwgZXJhdCBub24gbWF1cmlzIGNvbnZhbGxpcyB2ZWhpY3VsYS4gTnVsbGEgZXQgc2FwaWVuLiBJbnRlZ2VyIHRvcnRvciB0ZWxsdXMsIGFsaXF1YW0gZmF1Y2lidXMsIGNvbnZhbGxpcyBpZCwgY29uZ3VlIGV1LCBxdWFtLiBNYXVyaXMgdWxsYW1jb3JwZXIgZmVsaXMgdml0YW";}i:5;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:26;}s:4:"data";s:274:"YSBtYXNzYSBhZGlwaXNjaW5nIG5pc2wsIGFjIGV1aXNtb2QgbmliaCBuaXNsIGV1IGxlY3R1cy4gRnVzY2UgdnVscHV0YXRlIHNlbSBhdCBzYXBpZW4uIFZpdmFtdXMgbGVvLiBBbGlxdWFtIGV1aXNtb2QgbGliZXJvIGV1IGVuaW0uIE51bGxhIG5lYyBmZWxpcyBzZWQgbGVvIHBsYWNlcmF0IGltcGVyZGlldC4gQWVuZWFuIHN1c2NpcGl0IG51bGxhIGluIGp1c3";}}}s:10:"identifier";O:40:"Qroques\ResilientData\FragmentIdentifier":1:{s:5:"value";i:1;}s:8:"manifest";O:30:"Qroques\ResilientData\Manifest":2:{s:17:"resilientDataHash";O:26:"Qroques\ResilientData\Hash":1:{s:4:"hash";s:64:"ccec74f22f298deb6bc62053b4043839561ea1a08650e7d79f798b6e018202a6";}s:22:"splittingConfiguration";O:44:"Qroques\ResilientData\SplittingConfiguration":2:{s:17:"numberOfFragments";i:5;s:14:"acceptableLoss";i:2;}}} \ No newline at end of file diff --git a/tests/fixtures/fragments/fragment_2.txt b/tests/fixtures/fragments/fragment_2.txt index 99a9dbc..383053f 100644 --- a/tests/fixtures/fragments/fragment_2.txt +++ b/tests/fixtures/fragments/fragment_2.txt @@ -1 +1 @@ -O:30:"Qroques\ResilientData\Fragment":3:{s:10:"dataChunks";O:32:"Qroques\ResilientData\Collection":1:{s:5:"items";a:6:{i:0;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:7;}s:4:"data";s:274:"IkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0LCBjb25zZWN0ZXR1ciBhZGlwaXNjaW5nIGVsaXQuIFNlZCBub24gcmlzdXMuIFN1c3BlbmRpc3NlIGxlY3R1cyB0b3J0b3IsIGRpZ25pc3NpbSBzaXQgYW1ldCwgYWRpcGlzY2luZyBuZWMsIHVsdHJpY2llcyBzZWQsIGRvbG9yLiBDcmFzIGVsZW1lbnR1bSB1bHRyaWNlcyBkaWFtLiBNYWVjZW5hcyBsaWd1bGEgbW";}i:1;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:13;}s:4:"data";s:274:"ZXF1YXQgaW4sIHByZXRpdW0gYSwgZW5pbS4gUGVsbGVudGVzcXVlIGNvbmd1ZS4gVXQgaW4gcmlzdXMgdm9sdXRwYXQgbGliZXJvIHBoYXJldHJhIHRlbXBvci4gQ3JhcyB2ZXN0aWJ1bHVtIGJpYmVuZHVtIGF1Z3VlLiBQcmFlc2VudCBlZ2VzdGFzIGxlbyBpbiBwZWRlLiBQcmFlc2VudCBibGFuZGl0IG9kaW8gZXUgZW5pbS4gUGVsbGVudGVzcXVlIHNlZCBkdW";}i:2;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:14;}s:4:"data";s:274:"kgdXQgYXVndWUgYmxhbmRpdCBzb2RhbGVzLiBWZXN0aWJ1bHVtIGFudGUgaXBzdW0gcHJpbWlzIGluIGZhdWNpYnVzIG9yY2kgbHVjdHVzIGV0IHVsdHJpY2VzIHBvc3VlcmUgY3ViaWxpYSBDdXJhZTsgQWxpcXVhbSBuaWJoLiBNYXVyaXMgYWMgbWF1cmlzIHNlZCBwZWRlIHBlbGxlbnRlc3F1ZSBmZXJtZW50dW0uIE1hZWNlbmFzIGFkaXBpc2NpbmcgYW50ZSBu";}i:3;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:21;}s:4:"data";s:274:"xhbWNvcnBlciBuaWJoLCBpbiB0ZW1wdXMgc2FwaWVuIGVyb3Mgdml0YWUgbGlndWxhLiBQZWxsZW50ZXNxdWUgcmhvbmN1cyBudW5jIGV0IGF1Z3VlLiBJbnRlZ2VyIGlkIGZlbGlzLiBDdXJhYml0dXIgYWxpcXVldCBwZWxsZW50ZXNxdWUgZGlhbS4gSW50ZWdlciBxdWlzIG1ldHVzIHZpdGFlIGVsaXQgbG9ib3J0aXMgZWdlc3Rhcy4gTG9yZW0gaXBzdW0gZG9s";}i:4;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:22;}s:4:"data";s:274:"b3Igc2l0IGFtZXQsIGNvbnNlY3RldHVlciBhZGlwaXNjaW5nIGVsaXQuIE1vcmJpIHZlbCBlcmF0IG5vbiBtYXVyaXMgY29udmFsbGlzIHZlaGljdWxhLiBOdWxsYSBldCBzYXBpZW4uIEludGVnZXIgdG9ydG9yIHRlbGx1cywgYWxpcXVhbSBmYXVjaWJ1cywgY29udmFsbGlzIGlkLCBjb25ndWUgZXUsIHF1YW0uIE1hdXJpcyB1bGxhbWNvcnBlciBmZWxpcyB2aX";}i:5;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:28;}s:4:"data";s:274:"p1c3RvLiBTdXNwZW5kaXNzZSBjdXJzdXMgcnV0cnVtIGF1Z3VlLiBOdWxsYSB0aW5jaWR1bnQgdGluY2lkdW50IG1pLiBDdXJhYml0dXIgaWFjdWxpcywgbG9yZW0gdmVsIHJob25jdXMgZmF1Y2lidXMsIGZlbGlzIG1hZ25hIGZlcm1lbnR1bSBhdWd1ZSwgZXQgdWx0cmljaWVzIGxhY3VzIGxvcmVtIHZhcml1cyBwdXJ1cy4gQ3VyYWJpdHVyIGV1IGFtZXRcbiI=";}}}s:10:"identifier";O:40:"Qroques\ResilientData\FragmentIdentifier":1:{s:5:"value";i:2;}s:8:"manifest";O:30:"Qroques\ResilientData\Manifest":2:{s:17:"resilientDataHash";O:26:"Qroques\ResilientData\Hash":1:{s:4:"hash";s:64:"e5a00d17fdf9193553d3201f96594ed5ebf28c1932c1a19057863f67a4525972";}s:22:"splittingConfiguration";O:44:"Qroques\ResilientData\SplittingConfiguration":2:{s:17:"numberOfFragments";i:5;s:14:"acceptableLoss";i:2;}}} \ No newline at end of file +O:30:"Qroques\ResilientData\Fragment":3:{s:10:"dataChunks";O:32:"Qroques\ResilientData\Collection":1:{s:5:"items";a:6:{i:0;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:7;}s:4:"data";s:274:"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gU2VkIG5vbiByaXN1cy4gU3VzcGVuZGlzc2UgbGVjdHVzIHRvcnRvciwgZGlnbmlzc2ltIHNpdCBhbWV0LCBhZGlwaXNjaW5nIG5lYywgdWx0cmljaWVzIHNlZCwgZG9sb3IuIENyYXMgZWxlbWVudHVtIHVsdHJpY2VzIGRpYW0uIE1hZWNlbmFzIGxpZ3VsYSBtYX";}i:1;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:13;}s:4:"data";s:274:"cXVhdCBpbiwgcHJldGl1bSBhLCBlbmltLiBQZWxsZW50ZXNxdWUgY29uZ3VlLiBVdCBpbiByaXN1cyB2b2x1dHBhdCBsaWJlcm8gcGhhcmV0cmEgdGVtcG9yLiBDcmFzIHZlc3RpYnVsdW0gYmliZW5kdW0gYXVndWUuIFByYWVzZW50IGVnZXN0YXMgbGVvIGluIHBlZGUuIFByYWVzZW50IGJsYW5kaXQgb2RpbyBldSBlbmltLiBQZWxsZW50ZXNxdWUgc2VkIGR1aS";}i:2;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:14;}s:4:"data";s:274:"B1dCBhdWd1ZSBibGFuZGl0IHNvZGFsZXMuIFZlc3RpYnVsdW0gYW50ZSBpcHN1bSBwcmltaXMgaW4gZmF1Y2lidXMgb3JjaSBsdWN0dXMgZXQgdWx0cmljZXMgcG9zdWVyZSBjdWJpbGlhIEN1cmFlOyBBbGlxdWFtIG5pYmguIE1hdXJpcyBhYyBtYXVyaXMgc2VkIHBlZGUgcGVsbGVudGVzcXVlIGZlcm1lbnR1bS4gTWFlY2VuYXMgYWRpcGlzY2luZyBhbnRlIG5v";}i:3;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:21;}s:4:"data";s:274:"1jb3JwZXIgbmliaCwgaW4gdGVtcHVzIHNhcGllbiBlcm9zIHZpdGFlIGxpZ3VsYS4gUGVsbGVudGVzcXVlIHJob25jdXMgbnVuYyBldCBhdWd1ZS4gSW50ZWdlciBpZCBmZWxpcy4gQ3VyYWJpdHVyIGFsaXF1ZXQgcGVsbGVudGVzcXVlIGRpYW0uIEludGVnZXIgcXVpcyBtZXR1cyB2aXRhZSBlbGl0IGxvYm9ydGlzIGVnZXN0YXMuIExvcmVtIGlwc3VtIGRvbG9y";}i:4;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:22;}s:4:"data";s:274:"IHNpdCBhbWV0LCBjb25zZWN0ZXR1ZXIgYWRpcGlzY2luZyBlbGl0LiBNb3JiaSB2ZWwgZXJhdCBub24gbWF1cmlzIGNvbnZhbGxpcyB2ZWhpY3VsYS4gTnVsbGEgZXQgc2FwaWVuLiBJbnRlZ2VyIHRvcnRvciB0ZWxsdXMsIGFsaXF1YW0gZmF1Y2lidXMsIGNvbnZhbGxpcyBpZCwgY29uZ3VlIGV1LCBxdWFtLiBNYXVyaXMgdWxsYW1jb3JwZXIgZmVsaXMgdml0YW";}i:5;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:28;}s:4:"data";s:266:"RvLiBTdXNwZW5kaXNzZSBjdXJzdXMgcnV0cnVtIGF1Z3VlLiBOdWxsYSB0aW5jaWR1bnQgdGluY2lkdW50IG1pLiBDdXJhYml0dXIgaWFjdWxpcywgbG9yZW0gdmVsIHJob25jdXMgZmF1Y2lidXMsIGZlbGlzIG1hZ25hIGZlcm1lbnR1bSBhdWd1ZSwgZXQgdWx0cmljaWVzIGxhY3VzIGxvcmVtIHZhcml1cyBwdXJ1cy4gQ3VyYWJpdHVyIGV1IGFtZXQK";}}}s:10:"identifier";O:40:"Qroques\ResilientData\FragmentIdentifier":1:{s:5:"value";i:2;}s:8:"manifest";O:30:"Qroques\ResilientData\Manifest":2:{s:17:"resilientDataHash";O:26:"Qroques\ResilientData\Hash":1:{s:4:"hash";s:64:"ccec74f22f298deb6bc62053b4043839561ea1a08650e7d79f798b6e018202a6";}s:22:"splittingConfiguration";O:44:"Qroques\ResilientData\SplittingConfiguration":2:{s:17:"numberOfFragments";i:5;s:14:"acceptableLoss";i:2;}}} \ No newline at end of file diff --git a/tests/fixtures/fragments/fragment_3.txt b/tests/fixtures/fragments/fragment_3.txt index 041ba9d..2a5d8e4 100644 --- a/tests/fixtures/fragments/fragment_3.txt +++ b/tests/fixtures/fragments/fragment_3.txt @@ -1 +1 @@ -O:30:"Qroques\ResilientData\Fragment":3:{s:10:"dataChunks";O:32:"Qroques\ResilientData\Collection":1:{s:5:"items";a:6:{i:0;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:11;}s:4:"data";s:274:"Fzc2EsIHZhcml1cyBhLCBzZW1wZXIgY29uZ3VlLCBldWlzbW9kIG5vbiwgbWkuIFByb2luIHBvcnR0aXRvciwgb3JjaSBuZWMgbm9udW1teSBtb2xlc3RpZSwgZW5pbSBlc3QgZWxlaWZlbmQgbWksIG5vbiBmZXJtZW50dW0gZGlhbSBuaXNsIHNpdCBhbWV0IGVyYXQuIER1aXMgc2VtcGVyLiBEdWlzIGFyY3UgbWFzc2EsIHNjZWxlcmlzcXVlIHZpdGFlLCBjb25z";}i:1;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:13;}s:4:"data";s:274:"ZXF1YXQgaW4sIHByZXRpdW0gYSwgZW5pbS4gUGVsbGVudGVzcXVlIGNvbmd1ZS4gVXQgaW4gcmlzdXMgdm9sdXRwYXQgbGliZXJvIHBoYXJldHJhIHRlbXBvci4gQ3JhcyB2ZXN0aWJ1bHVtIGJpYmVuZHVtIGF1Z3VlLiBQcmFlc2VudCBlZ2VzdGFzIGxlbyBpbiBwZWRlLiBQcmFlc2VudCBibGFuZGl0IG9kaW8gZXUgZW5pbS4gUGVsbGVudGVzcXVlIHNlZCBkdW";}i:2;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:14;}s:4:"data";s:274:"kgdXQgYXVndWUgYmxhbmRpdCBzb2RhbGVzLiBWZXN0aWJ1bHVtIGFudGUgaXBzdW0gcHJpbWlzIGluIGZhdWNpYnVzIG9yY2kgbHVjdHVzIGV0IHVsdHJpY2VzIHBvc3VlcmUgY3ViaWxpYSBDdXJhZTsgQWxpcXVhbSBuaWJoLiBNYXVyaXMgYWMgbWF1cmlzIHNlZCBwZWRlIHBlbGxlbnRlc3F1ZSBmZXJtZW50dW0uIE1hZWNlbmFzIGFkaXBpc2NpbmcgYW50ZSBu";}i:3;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:25;}s:4:"data";s:274:"RhZSBlcmF0LiBQcm9pbiBmZXVnaWF0LCBhdWd1ZSBub24gZWxlbWVudHVtIHBvc3VlcmUsIG1ldHVzIHB1cnVzIGlhY3VsaXMgbGVjdHVzLCBldCB0cmlzdGlxdWUgbGlndWxhIGp1c3RvIHZpdGFlIG1hZ25hLlxuQWxpcXVhbSBjb252YWxsaXMgc29sbGljaXR1ZGluIHB1cnVzLiBQcmFlc2VudCBhbGlxdWFtLCBlbmltIGF0IGZlcm1lbnR1bSBtb2xsaXMsIGxp";}i:4;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:26;}s:4:"data";s:274:"Z3VsYSBtYXNzYSBhZGlwaXNjaW5nIG5pc2wsIGFjIGV1aXNtb2QgbmliaCBuaXNsIGV1IGxlY3R1cy4gRnVzY2UgdnVscHV0YXRlIHNlbSBhdCBzYXBpZW4uIFZpdmFtdXMgbGVvLiBBbGlxdWFtIGV1aXNtb2QgbGliZXJvIGV1IGVuaW0uIE51bGxhIG5lYyBmZWxpcyBzZWQgbGVvIHBsYWNlcmF0IGltcGVyZGlldC4gQWVuZWFuIHN1c2NpcGl0IG51bGxhIGluIG";}i:5;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:28;}s:4:"data";s:274:"p1c3RvLiBTdXNwZW5kaXNzZSBjdXJzdXMgcnV0cnVtIGF1Z3VlLiBOdWxsYSB0aW5jaWR1bnQgdGluY2lkdW50IG1pLiBDdXJhYml0dXIgaWFjdWxpcywgbG9yZW0gdmVsIHJob25jdXMgZmF1Y2lidXMsIGZlbGlzIG1hZ25hIGZlcm1lbnR1bSBhdWd1ZSwgZXQgdWx0cmljaWVzIGxhY3VzIGxvcmVtIHZhcml1cyBwdXJ1cy4gQ3VyYWJpdHVyIGV1IGFtZXRcbiI=";}}}s:10:"identifier";O:40:"Qroques\ResilientData\FragmentIdentifier":1:{s:5:"value";i:3;}s:8:"manifest";O:30:"Qroques\ResilientData\Manifest":2:{s:17:"resilientDataHash";O:26:"Qroques\ResilientData\Hash":1:{s:4:"hash";s:64:"e5a00d17fdf9193553d3201f96594ed5ebf28c1932c1a19057863f67a4525972";}s:22:"splittingConfiguration";O:44:"Qroques\ResilientData\SplittingConfiguration":2:{s:17:"numberOfFragments";i:5;s:14:"acceptableLoss";i:2;}}} \ No newline at end of file +O:30:"Qroques\ResilientData\Fragment":3:{s:10:"dataChunks";O:32:"Qroques\ResilientData\Collection":1:{s:5:"items";a:6:{i:0;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:11;}s:4:"data";s:274:"NzYSwgdmFyaXVzIGEsIHNlbXBlciBjb25ndWUsIGV1aXNtb2Qgbm9uLCBtaS4gUHJvaW4gcG9ydHRpdG9yLCBvcmNpIG5lYyBub251bW15IG1vbGVzdGllLCBlbmltIGVzdCBlbGVpZmVuZCBtaSwgbm9uIGZlcm1lbnR1bSBkaWFtIG5pc2wgc2l0IGFtZXQgZXJhdC4gRHVpcyBzZW1wZXIuIER1aXMgYXJjdSBtYXNzYSwgc2NlbGVyaXNxdWUgdml0YWUsIGNvbnNl";}i:1;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:13;}s:4:"data";s:274:"cXVhdCBpbiwgcHJldGl1bSBhLCBlbmltLiBQZWxsZW50ZXNxdWUgY29uZ3VlLiBVdCBpbiByaXN1cyB2b2x1dHBhdCBsaWJlcm8gcGhhcmV0cmEgdGVtcG9yLiBDcmFzIHZlc3RpYnVsdW0gYmliZW5kdW0gYXVndWUuIFByYWVzZW50IGVnZXN0YXMgbGVvIGluIHBlZGUuIFByYWVzZW50IGJsYW5kaXQgb2RpbyBldSBlbmltLiBQZWxsZW50ZXNxdWUgc2VkIGR1aS";}i:2;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:14;}s:4:"data";s:274:"B1dCBhdWd1ZSBibGFuZGl0IHNvZGFsZXMuIFZlc3RpYnVsdW0gYW50ZSBpcHN1bSBwcmltaXMgaW4gZmF1Y2lidXMgb3JjaSBsdWN0dXMgZXQgdWx0cmljZXMgcG9zdWVyZSBjdWJpbGlhIEN1cmFlOyBBbGlxdWFtIG5pYmguIE1hdXJpcyBhYyBtYXVyaXMgc2VkIHBlZGUgcGVsbGVudGVzcXVlIGZlcm1lbnR1bS4gTWFlY2VuYXMgYWRpcGlzY2luZyBhbnRlIG5v";}i:3;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:25;}s:4:"data";s:274:"UgZXJhdC4gUHJvaW4gZmV1Z2lhdCwgYXVndWUgbm9uIGVsZW1lbnR1bSBwb3N1ZXJlLCBtZXR1cyBwdXJ1cyBpYWN1bGlzIGxlY3R1cywgZXQgdHJpc3RpcXVlIGxpZ3VsYSBqdXN0byB2aXRhZSBtYWduYS4KQWxpcXVhbSBjb252YWxsaXMgc29sbGljaXR1ZGluIHB1cnVzLiBQcmFlc2VudCBhbGlxdWFtLCBlbmltIGF0IGZlcm1lbnR1bSBtb2xsaXMsIGxpZ3Vs";}i:4;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:26;}s:4:"data";s:274:"YSBtYXNzYSBhZGlwaXNjaW5nIG5pc2wsIGFjIGV1aXNtb2QgbmliaCBuaXNsIGV1IGxlY3R1cy4gRnVzY2UgdnVscHV0YXRlIHNlbSBhdCBzYXBpZW4uIFZpdmFtdXMgbGVvLiBBbGlxdWFtIGV1aXNtb2QgbGliZXJvIGV1IGVuaW0uIE51bGxhIG5lYyBmZWxpcyBzZWQgbGVvIHBsYWNlcmF0IGltcGVyZGlldC4gQWVuZWFuIHN1c2NpcGl0IG51bGxhIGluIGp1c3";}i:5;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:28;}s:4:"data";s:266:"RvLiBTdXNwZW5kaXNzZSBjdXJzdXMgcnV0cnVtIGF1Z3VlLiBOdWxsYSB0aW5jaWR1bnQgdGluY2lkdW50IG1pLiBDdXJhYml0dXIgaWFjdWxpcywgbG9yZW0gdmVsIHJob25jdXMgZmF1Y2lidXMsIGZlbGlzIG1hZ25hIGZlcm1lbnR1bSBhdWd1ZSwgZXQgdWx0cmljaWVzIGxhY3VzIGxvcmVtIHZhcml1cyBwdXJ1cy4gQ3VyYWJpdHVyIGV1IGFtZXQK";}}}s:10:"identifier";O:40:"Qroques\ResilientData\FragmentIdentifier":1:{s:5:"value";i:3;}s:8:"manifest";O:30:"Qroques\ResilientData\Manifest":2:{s:17:"resilientDataHash";O:26:"Qroques\ResilientData\Hash":1:{s:4:"hash";s:64:"ccec74f22f298deb6bc62053b4043839561ea1a08650e7d79f798b6e018202a6";}s:22:"splittingConfiguration";O:44:"Qroques\ResilientData\SplittingConfiguration":2:{s:17:"numberOfFragments";i:5;s:14:"acceptableLoss";i:2;}}} \ No newline at end of file diff --git a/tests/fixtures/fragments/fragment_4.txt b/tests/fixtures/fragments/fragment_4.txt index b1a270f..b1f09d7 100644 --- a/tests/fixtures/fragments/fragment_4.txt +++ b/tests/fixtures/fragments/fragment_4.txt @@ -1 +1 @@ -O:30:"Qroques\ResilientData\Fragment":3:{s:10:"dataChunks";O:32:"Qroques\ResilientData\Collection":1:{s:5:"items";a:6:{i:0;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:19;}s:4:"data";s:274:"b24gZGlhbSBzb2RhbGVzIGhlbmRyZXJpdC5cblV0IHZlbGl0IG1hdXJpcywgZWdlc3RhcyBzZWQsIGdyYXZpZGEgbmVjLCBvcm5hcmUgdXQsIG1pLiBBZW5lYW4gdXQgb3JjaSB2ZWwgbWFzc2Egc3VzY2lwaXQgcHVsdmluYXIuIE51bGxhIHNvbGxpY2l0dWRpbi4gRnVzY2UgdmFyaXVzLCBsaWd1bGEgbm9uIHRlbXB1cyBhbGlxdWFtLCBudW5jIHR1cnBpcyB1bG";}i:1;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:21;}s:4:"data";s:274:"xhbWNvcnBlciBuaWJoLCBpbiB0ZW1wdXMgc2FwaWVuIGVyb3Mgdml0YWUgbGlndWxhLiBQZWxsZW50ZXNxdWUgcmhvbmN1cyBudW5jIGV0IGF1Z3VlLiBJbnRlZ2VyIGlkIGZlbGlzLiBDdXJhYml0dXIgYWxpcXVldCBwZWxsZW50ZXNxdWUgZGlhbS4gSW50ZWdlciBxdWlzIG1ldHVzIHZpdGFlIGVsaXQgbG9ib3J0aXMgZWdlc3Rhcy4gTG9yZW0gaXBzdW0gZG9s";}i:2;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:22;}s:4:"data";s:274:"b3Igc2l0IGFtZXQsIGNvbnNlY3RldHVlciBhZGlwaXNjaW5nIGVsaXQuIE1vcmJpIHZlbCBlcmF0IG5vbiBtYXVyaXMgY29udmFsbGlzIHZlaGljdWxhLiBOdWxsYSBldCBzYXBpZW4uIEludGVnZXIgdG9ydG9yIHRlbGx1cywgYWxpcXVhbSBmYXVjaWJ1cywgY29udmFsbGlzIGlkLCBjb25ndWUgZXUsIHF1YW0uIE1hdXJpcyB1bGxhbWNvcnBlciBmZWxpcyB2aX";}i:3;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:25;}s:4:"data";s:274:"RhZSBlcmF0LiBQcm9pbiBmZXVnaWF0LCBhdWd1ZSBub24gZWxlbWVudHVtIHBvc3VlcmUsIG1ldHVzIHB1cnVzIGlhY3VsaXMgbGVjdHVzLCBldCB0cmlzdGlxdWUgbGlndWxhIGp1c3RvIHZpdGFlIG1hZ25hLlxuQWxpcXVhbSBjb252YWxsaXMgc29sbGljaXR1ZGluIHB1cnVzLiBQcmFlc2VudCBhbGlxdWFtLCBlbmltIGF0IGZlcm1lbnR1bSBtb2xsaXMsIGxp";}i:4;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:26;}s:4:"data";s:274:"Z3VsYSBtYXNzYSBhZGlwaXNjaW5nIG5pc2wsIGFjIGV1aXNtb2QgbmliaCBuaXNsIGV1IGxlY3R1cy4gRnVzY2UgdnVscHV0YXRlIHNlbSBhdCBzYXBpZW4uIFZpdmFtdXMgbGVvLiBBbGlxdWFtIGV1aXNtb2QgbGliZXJvIGV1IGVuaW0uIE51bGxhIG5lYyBmZWxpcyBzZWQgbGVvIHBsYWNlcmF0IGltcGVyZGlldC4gQWVuZWFuIHN1c2NpcGl0IG51bGxhIGluIG";}i:5;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:28;}s:4:"data";s:274:"p1c3RvLiBTdXNwZW5kaXNzZSBjdXJzdXMgcnV0cnVtIGF1Z3VlLiBOdWxsYSB0aW5jaWR1bnQgdGluY2lkdW50IG1pLiBDdXJhYml0dXIgaWFjdWxpcywgbG9yZW0gdmVsIHJob25jdXMgZmF1Y2lidXMsIGZlbGlzIG1hZ25hIGZlcm1lbnR1bSBhdWd1ZSwgZXQgdWx0cmljaWVzIGxhY3VzIGxvcmVtIHZhcml1cyBwdXJ1cy4gQ3VyYWJpdHVyIGV1IGFtZXRcbiI=";}}}s:10:"identifier";O:40:"Qroques\ResilientData\FragmentIdentifier":1:{s:5:"value";i:4;}s:8:"manifest";O:30:"Qroques\ResilientData\Manifest":2:{s:17:"resilientDataHash";O:26:"Qroques\ResilientData\Hash":1:{s:4:"hash";s:64:"e5a00d17fdf9193553d3201f96594ed5ebf28c1932c1a19057863f67a4525972";}s:22:"splittingConfiguration";O:44:"Qroques\ResilientData\SplittingConfiguration":2:{s:17:"numberOfFragments";i:5;s:14:"acceptableLoss";i:2;}}} \ No newline at end of file +O:30:"Qroques\ResilientData\Fragment":3:{s:10:"dataChunks";O:32:"Qroques\ResilientData\Collection":1:{s:5:"items";a:6:{i:0;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:19;}s:4:"data";s:274:"biBkaWFtIHNvZGFsZXMgaGVuZHJlcml0LgpVdCB2ZWxpdCBtYXVyaXMsIGVnZXN0YXMgc2VkLCBncmF2aWRhIG5lYywgb3JuYXJlIHV0LCBtaS4gQWVuZWFuIHV0IG9yY2kgdmVsIG1hc3NhIHN1c2NpcGl0IHB1bHZpbmFyLiBOdWxsYSBzb2xsaWNpdHVkaW4uIEZ1c2NlIHZhcml1cywgbGlndWxhIG5vbiB0ZW1wdXMgYWxpcXVhbSwgbnVuYyB0dXJwaXMgdWxsYW";}i:1;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:21;}s:4:"data";s:274:"1jb3JwZXIgbmliaCwgaW4gdGVtcHVzIHNhcGllbiBlcm9zIHZpdGFlIGxpZ3VsYS4gUGVsbGVudGVzcXVlIHJob25jdXMgbnVuYyBldCBhdWd1ZS4gSW50ZWdlciBpZCBmZWxpcy4gQ3VyYWJpdHVyIGFsaXF1ZXQgcGVsbGVudGVzcXVlIGRpYW0uIEludGVnZXIgcXVpcyBtZXR1cyB2aXRhZSBlbGl0IGxvYm9ydGlzIGVnZXN0YXMuIExvcmVtIGlwc3VtIGRvbG9y";}i:2;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:22;}s:4:"data";s:274:"IHNpdCBhbWV0LCBjb25zZWN0ZXR1ZXIgYWRpcGlzY2luZyBlbGl0LiBNb3JiaSB2ZWwgZXJhdCBub24gbWF1cmlzIGNvbnZhbGxpcyB2ZWhpY3VsYS4gTnVsbGEgZXQgc2FwaWVuLiBJbnRlZ2VyIHRvcnRvciB0ZWxsdXMsIGFsaXF1YW0gZmF1Y2lidXMsIGNvbnZhbGxpcyBpZCwgY29uZ3VlIGV1LCBxdWFtLiBNYXVyaXMgdWxsYW1jb3JwZXIgZmVsaXMgdml0YW";}i:3;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:25;}s:4:"data";s:274:"UgZXJhdC4gUHJvaW4gZmV1Z2lhdCwgYXVndWUgbm9uIGVsZW1lbnR1bSBwb3N1ZXJlLCBtZXR1cyBwdXJ1cyBpYWN1bGlzIGxlY3R1cywgZXQgdHJpc3RpcXVlIGxpZ3VsYSBqdXN0byB2aXRhZSBtYWduYS4KQWxpcXVhbSBjb252YWxsaXMgc29sbGljaXR1ZGluIHB1cnVzLiBQcmFlc2VudCBhbGlxdWFtLCBlbmltIGF0IGZlcm1lbnR1bSBtb2xsaXMsIGxpZ3Vs";}i:4;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:26;}s:4:"data";s:274:"YSBtYXNzYSBhZGlwaXNjaW5nIG5pc2wsIGFjIGV1aXNtb2QgbmliaCBuaXNsIGV1IGxlY3R1cy4gRnVzY2UgdnVscHV0YXRlIHNlbSBhdCBzYXBpZW4uIFZpdmFtdXMgbGVvLiBBbGlxdWFtIGV1aXNtb2QgbGliZXJvIGV1IGVuaW0uIE51bGxhIG5lYyBmZWxpcyBzZWQgbGVvIHBsYWNlcmF0IGltcGVyZGlldC4gQWVuZWFuIHN1c2NpcGl0IG51bGxhIGluIGp1c3";}i:5;O:31:"Qroques\ResilientData\DataChunk":2:{s:10:"identifier";O:41:"Qroques\ResilientData\DataChunkIdentifier":1:{s:5:"value";i:28;}s:4:"data";s:266:"RvLiBTdXNwZW5kaXNzZSBjdXJzdXMgcnV0cnVtIGF1Z3VlLiBOdWxsYSB0aW5jaWR1bnQgdGluY2lkdW50IG1pLiBDdXJhYml0dXIgaWFjdWxpcywgbG9yZW0gdmVsIHJob25jdXMgZmF1Y2lidXMsIGZlbGlzIG1hZ25hIGZlcm1lbnR1bSBhdWd1ZSwgZXQgdWx0cmljaWVzIGxhY3VzIGxvcmVtIHZhcml1cyBwdXJ1cy4gQ3VyYWJpdHVyIGV1IGFtZXQK";}}}s:10:"identifier";O:40:"Qroques\ResilientData\FragmentIdentifier":1:{s:5:"value";i:4;}s:8:"manifest";O:30:"Qroques\ResilientData\Manifest":2:{s:17:"resilientDataHash";O:26:"Qroques\ResilientData\Hash":1:{s:4:"hash";s:64:"ccec74f22f298deb6bc62053b4043839561ea1a08650e7d79f798b6e018202a6";}s:22:"splittingConfiguration";O:44:"Qroques\ResilientData\SplittingConfiguration":2:{s:17:"numberOfFragments";i:5;s:14:"acceptableLoss";i:2;}}} \ No newline at end of file diff --git a/tests/fixtures/image.png b/tests/fixtures/image.png new file mode 100644 index 0000000000000000000000000000000000000000..cac66fc1943fb8b567e01e2ac925948e8623f3cb GIT binary patch literal 8022 zcmcIp29QJK|oMCl%*R%x>;d~C0F`# z|A%`&JZHYmIcLtCdFJ;_thS~yF~JK0002O&s-ggSvYAgv!pD4Cv)Wtsp3E~>6(bJ- zfaKTz0waTmgbn~;#8*}LPtQ01D98kAZJ4w6y*}Wid9u8wy`z0~wR`F{tvY2AG4p?9 zvB{`6fF#=pcBT|2hGa|uKb0~o1|h8!Unt8NSSbZ;#y-XcXRJ|8ViQ3oE zb@|x4ln=*@9j|EEZ@+?gDhedapev$ zcuzGO%Un1Azrk$lV}H^`hWSQcUr`4-Xju*nAp=8GJdV3anRop7BeK=mArr2G(M%Cc zov$jZ7Dgyl*$78TsS-X(=tG{myo7Zv1tC7eGfEWug9`pr14! z@Hg|Z$iTkGZHVscaTnS1F=5CE8RqGTL>6Sm#~5Z{y3kBFwuxFRk_otKF1mL#%G^Hn zm1bBEe!SO`y|&T;LP0OM6NKR^?K}U>Tibae-b6gNtT*dwZ*1(7AZ6w(&-VZ+F=OxR z=T_&C?2)-nH1pQhsNsKUan4o3|E~d9O$>mjo!sl#-^vRvW3a7OrOz1il$WLJ>$6SJ zS{h|Ow*=#t86!w1+8}E9n_V1dbuG-;ki3gggWBCLxf*hY#GD@8UkNR(_AeY@Ew4wL zD(wF@d?Vv7j~Or`-76;dKY4Bm88N68%~7|2GGqHcMvy7$0GN~tJO(w$Y{g#)t^M8A zSK}%-hGl}H9{jHk7taxsNlL5;`sd`zmx*+i=@7(Z5yxHx*^xJ0@7|tGrgho11VT|~ zYR30fxHPtKS@N0%3tU2sAxSlo!nWvUuCf~yDZp9Io~BxeDC@Hk%a(tmX5rv~{B8K* z2z_fs=i==A@NZ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;-1HPc%f%#sc=A4p$!VP zl-ZVGJDsplit($resilientData, $splittingConfiguration); @@ -29,4 +29,29 @@ public function testSplitThenMerge() $reassembledResilientData = $assembler->assemble($fragments); $this->assertEquals($data, $reassembledResilientData->getData()); } + + public function testSplitThenMergeImageFile() + { + $data = file_get_contents('tests/fixtures/image.png'); + $resilientData = ResilientData::fromFile('tests/fixtures/image.png'); + $splittingConfiguration = new SplittingConfiguration(7, 3); + $splitter = new Splitter(); + $fragments = $splitter->split($resilientData, $splittingConfiguration); + + $assembler = new Assembler(); + $reassembledResilientData = $assembler->assemble($fragments); + $this->assertEquals($data, $reassembledResilientData->getData()); + } + + public function testSplitThenMergeText() + { + $resilientData = ResilientData::fromString('Lorem ipsum dolor sit amet, consectetur adipiscing elit.'); + $splittingConfiguration = new SplittingConfiguration(7, 3); + $splitter = new Splitter(); + $fragments = $splitter->split($resilientData, $splittingConfiguration); + + $assembler = new Assembler(); + $reassembledResilientData = $assembler->assemble($fragments); + $this->assertEquals('Lorem ipsum dolor sit amet, consectetur adipiscing elit.', $reassembledResilientData->getData()); + } } diff --git a/tests/unit/AssemblerTest.php b/tests/unit/AssemblerTest.php index 0d0836c..f61492c 100644 --- a/tests/unit/AssemblerTest.php +++ b/tests/unit/AssemblerTest.php @@ -25,10 +25,10 @@ class AssemblerTest extends TestCase public function testAssemble(): void { $assembler = new Assembler(); - $chunk3 = new DataChunk(new DataChunkIdentifier(3), 'IlRoaXMg'); - $chunk5 = new DataChunk(new DataChunkIdentifier(5), 'aXMgYSBk'); - $chunk6 = new DataChunk(new DataChunkIdentifier(6), 'YXRhISI='); - $manifest = new Manifest(Hash::fromContent(base64_encode(json_encode('This is a data!'))), new SplittingConfiguration(3, 1)); + $chunk3 = new DataChunk(new DataChunkIdentifier(3), 'VGhpcyB'); + $chunk5 = new DataChunk(new DataChunkIdentifier(5), 'pcyBhIG'); + $chunk6 = new DataChunk(new DataChunkIdentifier(6), 'RhdGEh'); + $manifest = new Manifest(Hash::fromContent(base64_encode('This is a data!')), new SplittingConfiguration(3, 1)); $fragment0 = new Fragment(new FragmentIdentifier(0), $manifest, [$chunk3, $chunk5]); $fragment1 = new Fragment(new FragmentIdentifier(1), $manifest, [$chunk3, $chunk6]); @@ -50,9 +50,9 @@ public function testAssemble(): void public function testAssembleWithMissingData(): void { $assembler = new Assembler(); - $chunk3 = new DataChunk(new DataChunkIdentifier(3), 'IlRoaXMg'); - $chunk5 = new DataChunk(new DataChunkIdentifier(5), 'aXMgYSBk'); - $chunk6 = new DataChunk(new DataChunkIdentifier(6), 'YXRhISI='); + $chunk3 = new DataChunk(new DataChunkIdentifier(3), 'VGhpcyB'); + $chunk5 = new DataChunk(new DataChunkIdentifier(5), 'pcyBhIG'); + $chunk6 = new DataChunk(new DataChunkIdentifier(6), 'RhdGEh'); $manifest = new Manifest(Hash::fromContent(base64_encode(json_encode('This is a data!'))), new SplittingConfiguration(3, 1)); $fragment0 = new Fragment(new FragmentIdentifier(0), $manifest, [$chunk3, $chunk5]); diff --git a/tests/unit/SplitterTest.php b/tests/unit/SplitterTest.php index ec2f8ea..0161630 100644 --- a/tests/unit/SplitterTest.php +++ b/tests/unit/SplitterTest.php @@ -19,7 +19,7 @@ class SplitterTest extends TestCase public function testSplit(): void { $splitter = new Splitter(); - $resilientData = new ResilientData('12345'); + $resilientData = ResilientData::fromString('Lorem ipsum dolor sit amet, consectetur adipiscing elit.'); $fragments = $splitter->split($resilientData, new SplittingConfiguration(5, 2)); $this->assertCount(5, $fragments); }