Skip to content

Commit

Permalink
test: unit coverage for MemoryWallet (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
faustbrian committed Nov 2, 2020
1 parent 58576eb commit 46fb566
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/Unit/DTO/MemoryWalletTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

use App\DTO\MemoryWallet;
use App\Services\Cache\WalletCache;

it('should make an instance from a address', function () {
$subject = MemoryWallet::fromAddress('D6Z26L69gdk9qYmTv5uzk3uGepigtHY4ax');

expect($subject->address())->toBe('D6Z26L69gdk9qYmTv5uzk3uGepigtHY4ax');
expect($subject->publicKey())->toBeNull();
expect($subject->username())->toBeNull();
expect($subject->isDelegate())->toBeFalse();
});

it('should make an instance from a public key', function () {
$subject = MemoryWallet::fromPublicKey('03d3fdad9c5b25bf8880e6b519eb3611a5c0b31adebc8455f0e096175b28321aff');

expect($subject->address())->toBe('D6Z26L69gdk9qYmTv5uzk3uGepigtHY4ax');
expect($subject->publicKey())->toBe('03d3fdad9c5b25bf8880e6b519eb3611a5c0b31adebc8455f0e096175b28321aff');
expect($subject->username())->toBeNull();
expect($subject->isDelegate())->toBeFalse();
});

it('should be a delegate', function () {
(new WalletCache())->setUsernameByAddress('D6Z26L69gdk9qYmTv5uzk3uGepigtHY4ax', 'username');

$subject = MemoryWallet::fromPublicKey('03d3fdad9c5b25bf8880e6b519eb3611a5c0b31adebc8455f0e096175b28321aff');

expect($subject->address())->toBe('D6Z26L69gdk9qYmTv5uzk3uGepigtHY4ax');
expect($subject->publicKey())->toBe('03d3fdad9c5b25bf8880e6b519eb3611a5c0b31adebc8455f0e096175b28321aff');
expect($subject->username())->toBe('username');
expect($subject->isDelegate())->toBeTrue();
});

0 comments on commit 46fb566

Please sign in to comment.