@@ -344,38 +344,54 @@ public function testDeserializeHybridUrlReturnsCorrectItemid(): void
344344 // -----------------------------------------------------------------------
345345
346346 /**
347- * A masked link whose proto payload begins with hex 'A6 ' (XOR key = 0xA6).
347+ * Three real-world masked links whose first hex digit is 'A ' (XOR key = 0xA4 or 0xA6).
348348 * Previously, extractHex() wrongly treated the 'A' as the classic asset-ID
349- * prefix marker and stripped it, producing 47 hex chars ( odd length) which
349+ * prefix marker and stripped it, producing an odd- length hex string which
350350 * caused hex2bin to return false / an InvalidArgumentException.
351+ *
352+ * A_START_HEX_1 key=0xA6, longer payload → defindex=34 (M4A1-S)
353+ * A_START_HEX_2 key=0xA4, shorter payload → defindex=4676
354+ * A_START_HEX_3 key=0xA6, shorter payload → defindex=1377
351355 */
352- private const A_START_HEX = 'A6B617190F659DBE47AC86A68EA096A2CEB4D6AFBFFA9FD2 ' ;
356+ private const A_START_HEX_1 = 'A6B6710C51510DA7BE848628A18EA396A29E1C181D56A5E682CEE8D6AEE7BC380F ' ;
357+ private const A_START_HEX_2 = 'A4B4725C7B1EE6BC608084A48CA294A0CC9CD4AD3EDF347E ' ;
358+ private const A_START_HEX_3 = 'A6B617190F659DBE47AC86A68EA096A2CEB4D6AFBFFA9FD2 ' ;
353359
354- private const A_START_URL = 'steam://run/730//+csgo_econ_action_preview%20 ' . self ::A_START_HEX ;
360+ /** @return array<string, array{string, int}> */
361+ public static function aStartingPayloadProvider (): array
362+ {
363+ return [
364+ 'key=0xA6 long ' => [self ::A_START_HEX_1 , 34 ],
365+ 'key=0xA4 short ' => [self ::A_START_HEX_2 , 4676 ],
366+ 'key=0xA6 short ' => [self ::A_START_HEX_3 , 1377 ],
367+ ];
368+ }
355369
356- public function testIsMaskedReturnsTrueForAStartingPayload (): void
370+ #[\PHPUnit \Framework \Attributes \DataProvider('aStartingPayloadProvider ' )]
371+ public function testIsMaskedReturnsTrueForAStartingPayload (string $ hex , int $ _defindex ): void
357372 {
358- $ this ->assertTrue (InspectLink::isMasked (self ::A_START_URL ));
373+ $ url = 'steam://run/730//+csgo_econ_action_preview%20 ' . $ hex ;
374+ $ this ->assertTrue (InspectLink::isMasked ($ url ));
359375 }
360376
361- public function testDeserializeAStartingPayloadDoesNotThrow (): void
377+ #[\PHPUnit \Framework \Attributes \DataProvider('aStartingPayloadProvider ' )]
378+ public function testDeserializeAStartingBareHex (string $ hex , int $ defindex ): void
362379 {
363- $ item = InspectLink::deserialize (self ::A_START_URL );
364- // Payload has XOR key 0xA6; after decryption defindex decodes to 1377.
365- $ this ->assertSame (1377 , $ item ->defindex );
380+ $ this ->assertSame ($ defindex , InspectLink::deserialize ($ hex )->defindex );
366381 }
367382
368- public function testDeserializeAStartingBareHexDoesNotThrow (): void
383+ #[\PHPUnit \Framework \Attributes \DataProvider('aStartingPayloadProvider ' )]
384+ public function testDeserializeAStartingSteamRunUrl (string $ hex , int $ defindex ): void
369385 {
370- $ item = InspectLink:: deserialize ( self :: A_START_HEX ) ;
371- $ this ->assertSame (1377 , $ item ->defindex );
386+ $ url = ' steam://run/730//+csgo_econ_action_preview%20 ' . $ hex ;
387+ $ this ->assertSame ($ defindex , InspectLink:: deserialize ( $ url ) ->defindex );
372388 }
373389
374- public function testAStartingPayloadInsideSteamRunguameUrl (): void
390+ #[\PHPUnit \Framework \Attributes \DataProvider('aStartingPayloadProvider ' )]
391+ public function testDeserializeAStartingSteamRungameUrl (string $ hex , int $ defindex ): void
375392 {
376- $ url = 'steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20 ' . self ::A_START_HEX ;
377- $ item = InspectLink::deserialize ($ url );
378- $ this ->assertSame (1377 , $ item ->defindex );
393+ $ url = 'steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20 ' . $ hex ;
394+ $ this ->assertSame ($ defindex , InspectLink::deserialize ($ url )->defindex );
379395 }
380396
381397 // -----------------------------------------------------------------------
0 commit comments