Skip to content

Commit

Permalink
Merge pull request #938 from bavix/pending-balances
Browse files Browse the repository at this point in the history
Pending Balances
  • Loading branch information
rez1dent3 committed Apr 17, 2024
2 parents bc60fb8 + 41dac42 commit 3638b50
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/Units/Domain/ExtraTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,31 @@ public function testExtraExchangeWithdraw(): void
'message' => 'Write off from the ruble account',
], $transfer->withdraw->meta);
}

public function testPendingBalances(): void
{
/** @var Buyer $user1 */
/** @var Buyer $user2 */
[$user1, $user2] = BuyerFactory::times(2)->create();

$user1->deposit(1000);
self::assertSame(1000, $user1->balanceInt);
self::assertSame(0, $user2->balanceInt);

$transfer = $user1->transfer($user2, 500, new Extra(
deposit: new Option(null, confirmed: false),
withdraw: null,
));

self::assertNotNull($transfer);
self::assertTrue($transfer->withdraw->confirmed);
self::assertFalse($transfer->deposit->confirmed);

self::assertSame(500, $user1->balanceInt);
self::assertSame(0, $user2->balanceInt);

self::assertTrue($user2->wallet->confirm($transfer->deposit)); // confirmed

self::assertSame(500, $user2->balanceInt);
}
}

0 comments on commit 3638b50

Please sign in to comment.