Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: unit coverage for MemoryWallet #356

Merged
merged 13 commits into from
Nov 2, 2020
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();
});