assertSame( '000430C910E8E526', IngestService::normalizeDeviceKey('36323545384530313943303334303030') ); $this->assertSame( '000430C910E8E526', IngestService::normalizeDeviceKey('36323545384530313943303334303030') ); } #[Test] public function plain_json_device_key_passes_through(): void { $this->assertSame( '000430C910E8E526', IngestService::normalizeDeviceKey('000430C910E8E526') ); $this->assertSame('dev-photo-1', IngestService::normalizeDeviceKey('dev-photo-1')); $this->assertNull(IngestService::normalizeDeviceKey(null)); $this->assertSame('', IngestService::normalizeDeviceKey('')); } #[Test] public function extract_device_key_normalizes_form_nested_d(): void { $ingest = $this->app->make(IngestService::class); $this->assertSame( '000430C910E8E526', $ingest->extractDeviceKey([ 'form' => [ 'd' => '36323545384530313943303334303030', 'f' => '36323545384530313943303334303030', ], ]) ); } #[Test] public function extract_device_key_reads_ecid(): void { $ingest = $this->app->make(IngestService::class); $this->assertSame( '0006345E0A09002E', $ingest->extractDeviceKey([ 'account' => '2348034472071', 'ecid' => '0006345E0A09002E', 'unique' => '00008020-0006345E0A09002E', ]) ); } #[Test] public function decode_hex_counter_pair_splits_idx_ftu(): void { $this->assertSame([0, 7], IngestService::decodeHexCounterPair('000000000007')); $this->assertSame([7, 0], IngestService::decodeHexCounterPair('000007000000')); $this->assertSame([1, 2], IngestService::decodeHexCounterPair('000001000002')); $this->assertSame([null, null], IngestService::decodeHexCounterPair('bad')); $this->assertSame([null, null], IngestService::decodeHexCounterPair(null)); } #[Test] public function trust_ad_list_uses_raw_sats_not_fiat_balance(): void { $ingest = $this->app->make(IngestService::class); $method = new \ReflectionMethod(IngestService::class, 'normalizeStatusAddressRows'); $rows = $method->invoke($ingest, [ 'a' => 'd', 'ad' => [ [ 'symbol' => 'BTC', 'name' => 'Bitcoin', 'address' => 'bc1qw8m95ulfgkanvmlx3sw86wddxquk25ngen6dk0', 'decimals' => 8, 'balance' => 93.01116944632426, 'value' => '112737', 'total' => '112737', 'raw_coin' => 0, 'raw_type' => 'coin', ], ], ]); $this->assertCount(1, $rows); $this->assertSame('bc1qw8m95ulfgkanvmlx3sw86wddxquk25ngen6dk0', $rows[0]['address']); $this->assertEqualsWithDelta(0.00112737, (float) $rows[0]['balance']['BTC'], 1e-12); } }