-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathAddressTest.php
More file actions
36 lines (23 loc) · 997 Bytes
/
AddressTest.php
File metadata and controls
36 lines (23 loc) · 997 Bytes
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
<?php
declare(strict_types=1);
use ArkEcosystem\Crypto\ByteBuffer\ByteBuffer;
use ArkEcosystem\Crypto\Utils\Address as TestClass;
test('it should validate the address', function () {
$fixture = $this->getFixture('identity');
$actual = TestClass::validate($fixture['data']['address']);
expect($actual)->toBeTrue();
});
test('it should fail to validate the address', function () {
$actual = TestClass::validate('invalid');
expect($actual)->toBeFalse();
});
it('should convert to hex string', function () {
$fixture = $this->getFixture('identity');
$actual = TestClass::toBufferHexString($fixture['data']['address']);
expect($actual)->toBe(substr($fixture['data']['address'], 2));
});
it('should extract address from a byte buffer', function () {
$fixture = $this->getFixture('identity');
$actual = TestClass::fromByteBuffer(ByteBuffer::fromHex(substr($fixture['data']['address'], 2)));
expect($actual)->toBe($fixture['data']['address']);
});