feat(core): harden sessions settlement and credit activity
This commit is contained in:
@@ -17,6 +17,7 @@ use App\Events\PlayCatalogUpdatedBroadcast;
|
||||
use Database\Seeders\LotterySettingsSeeder;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use App\Services\Config\RiskCapStreamService;
|
||||
use App\Events\PlayerSessionReplacedBroadcast;
|
||||
use App\Services\Wallet\LotteryTransferService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use App\Services\Wallet\WalletBalanceRealtimeNotifier;
|
||||
@@ -39,6 +40,21 @@ test('balance update broadcasts only on the player private channel', function ()
|
||||
->and($channels[0]->name)->toBe('private-player.42');
|
||||
});
|
||||
|
||||
test('session replacement broadcasts the monotonic version on the player private channel', function (): void {
|
||||
$event = new PlayerSessionReplacedBroadcast(42, 3, 1_234_567);
|
||||
$channels = $event->broadcastOn();
|
||||
|
||||
expect($channels)->toHaveCount(1)
|
||||
->and($channels[0])->toBeInstanceOf(PrivateChannel::class)
|
||||
->and($channels[0]->name)->toBe('private-player.42')
|
||||
->and($event->broadcastAs())->toBe('session.replaced')
|
||||
->and($event->broadcastWith())->toBe([
|
||||
'player_id' => 42,
|
||||
'session_version' => 3,
|
||||
'emitted_at_ms' => 1_234_567,
|
||||
]);
|
||||
});
|
||||
|
||||
test('player private channel auth allows only the matching bearer player', function (): void {
|
||||
config([
|
||||
'broadcasting.default' => 'reverb',
|
||||
|
||||
Reference in New Issue
Block a user