-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathAddressTest.php
More file actions
54 lines (35 loc) · 1.41 KB
/
AddressTest.php
File metadata and controls
54 lines (35 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
declare(strict_types=1);
namespace ArkEcosystem\Tests\Crypto\Unit\Identities;
use ArkEcosystem\Crypto\Configuration\Network;
use ArkEcosystem\Crypto\Identities\Address;
use ArkEcosystem\Crypto\Identities\PrivateKey;
use ArkEcosystem\Crypto\Networks\Testnet;
beforeEach(function () {
Network::set(Testnet::new());
});
it('should get the address from passphrase', function () {
$fixture = $this->getFixture('identity');
$actual = Address::fromPassphrase($fixture['passphrase']);
expect($actual)->toBe($fixture['data']['address']);
});
it('should get the address from public key', function () {
$fixture = $this->getFixture('identity');
$actual = Address::fromPublicKey($fixture['data']['publicKey']);
expect($actual)->toBe($fixture['data']['address']);
});
it('should get the address from private key', function () {
$fixture = $this->getFixture('identity');
$privateKey = PrivateKey::fromPassphrase($fixture['passphrase']);
$actual = Address::fromPrivateKey($privateKey);
expect($actual)->toBe($fixture['data']['address']);
});
it('should validate an address', function () {
$fixture = $this->getFixture('identity');
$actual = Address::validate($fixture['data']['address']);
expect($actual)->toBeTrue();
});
it('should return false for invalid an address', function () {
$actual = Address::validate('invalid-address');
expect($actual)->toBeFalse();
});