Skip to content

Commit fc78cbd

Browse files
committed
speed up the test by 15x for external storage
1 parent a9d8c06 commit fc78cbd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/Units/Domain/WalletFloatTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Bavix\Wallet\Exceptions\AmountInvalid;
88
use Bavix\Wallet\Exceptions\BalanceIsEmpty;
99
use Bavix\Wallet\Internal\Exceptions\ExceptionInterface;
10+
use Bavix\Wallet\Internal\Service\DatabaseServiceInterface;
1011
use Bavix\Wallet\Internal\Service\MathServiceInterface;
1112
use Bavix\Wallet\Models\Transaction;
1213
use Bavix\Wallet\Test\Infra\Factories\UserFloatFactory;
@@ -284,9 +285,12 @@ public function testBitcoin(): void
284285

285286
$math = app(MathServiceInterface::class);
286287

287-
for ($i = 0; $i < 256; ++$i) {
288-
$user->depositFloat('0.00000001'); // Satoshi
289-
}
288+
// optimize
289+
app(DatabaseServiceInterface::class)->transaction(function () use ($user) {
290+
for ($i = 0; $i < 256; ++$i) {
291+
$user->depositFloat('0.00000001'); // Satoshi
292+
}
293+
});
290294

291295
self::assertSame($user->balance, '256'.str_repeat('0', 32 - 8));
292296
self::assertSame(0, $math->compare($user->balanceFloat, '0.00000256'));

0 commit comments

Comments
 (0)