Skip to content

Commit 118e4af

Browse files
committed
tests: begin work on tests
1 parent 78e2106 commit 118e4af

File tree

13 files changed

+217
-8
lines changed

13 files changed

+217
-8
lines changed

src/Api/Account.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66

77
class Account extends AbstractApi
88
{
9+
public function generate(): array
10+
{
11+
return $this->get(self::API_PATH, [
12+
'q' => 'generateAccount',
13+
]);
14+
}
15+
916
public function address(string $publicKey): array
1017
{
1118
return $this->get(self::API_PATH, [
@@ -30,13 +37,6 @@ public function publicKey(string $address): array
3037
]);
3138
}
3239

33-
public function generate(): array
34-
{
35-
return $this->get(self::API_PATH, [
36-
'q' => 'generateAccount',
37-
]);
38-
}
39-
4040
public function balance(string $address): array
4141
{
4242
return $this->get(self::API_PATH, [

src/Client.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@
2121
* @method Api\Account accounts()
2222
* @method Api\Account address()
2323
* @method Api\Account addresses()
24+
* @method Api\Asset asset()
25+
* @method Api\Asset assets()
26+
* @method Api\Block block()
27+
* @method Api\Block blocks()
2428
* @method Api\Node node()
2529
* @method Api\Node nodes()
2630
* @method Api\Other other()
2731
* @method Api\Other misc()
2832
* @method Api\Other miscellaneous()
33+
* @method Api\Transaction transaction()
34+
* @method Api\Transaction transactions()
2935
*/
3036
final class Client
3137
{
@@ -57,6 +63,7 @@ public function api(string $name): AbstractApi
5763
return match ($name) {
5864
'account', 'accounts', 'address', 'addresses' => new Api\Account($this),
5965
'asset', 'assets' => new Api\Asset($this),
66+
'block', 'blocks' => new Api\Block($this),
6067
'node', 'nodes' => new Api\Node($this),
6168
'other', 'misc', 'miscellaneous' => new Api\Other($this),
6269
'transaction', 'transactions' => new Api\Transaction($this),

src/Enums/Node.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ enum Node: string
1919

2020
public static function providedOrRandom(string|null $uri = null): string
2121
{
22-
if (str_starts_with($uri, 'http')) {
22+
if (str_starts_with($uri ?? '', 'http')) {
2323
return $uri;
2424
}
2525

tests/.gitkeep

Whitespace-only changes.

tests/Api/AccountTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use OwenVoke\Arionum\Api\Account;
6+
7+
beforeEach(fn () => $this->apiClass = Account::class);
8+
9+
it('can generate an account', function () {
10+
$response = [
11+
'data' => [
12+
'address' => '2tR6BWvwpwrQLUWN8GpVP4b6srCxgR2PnrsXs7jYfdeBj3FimJ5Tjd4xzWcWe8y59ZtEBXgQJxe6Uibux1cCDfxL',
13+
'public_key' => 'PZ8Tyr4Nx8MHsRAGMpZmZ6TWY63dXWSCyPP8v9FpH75La76KNgkUpZ2KiMHxHQsUKFytyEMXFPkh3yC25p5JoiR1dEsTgJJkNSrrkTM96BcMae5h6NeSdrH1',
14+
'private_key' => 'Lzhp9LopCF2mJMHtXj13vuZorf5qMDmYYpjBMLcUshSyyycjFt7YqSjFrzK4AUFpRWw3XPBYcA2maavRp1kbDe7iHwcLaTVwQ6sH2n5vRqZSoAzvcx4JHACDSF4K6TzA3WdspLXZYKbq612psVmtqBuYwvUkDhd2j',
15+
],
16+
];
17+
18+
$api = $this->getApiMock();
19+
20+
$api->expects($this->once())
21+
->method('get')
22+
->with('/api.php', [
23+
'q' => 'generateAccount',
24+
])
25+
->willReturn($response);
26+
27+
/** @var Account $api */
28+
expect($api->generate())->toBe($response);
29+
});
30+
31+
it('can get an address by public key');
32+
33+
it('can get the balance for an address');
34+
35+
it('can get the balance for an alias');
36+
37+
it('can get the balance for a public key');
38+
39+
it('can get the pending balance for a public key');
40+
41+
it('can get the alias for an address');
42+
43+
it('can get check that an address is valid');

tests/Api/AssetTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use OwenVoke\Arionum\Api\Asset;
6+
7+
beforeEach(fn () => $this->apiClass = Asset::class);
8+
9+
it('can get all assets');
10+
11+
it('can get a specific asset');
12+
13+
it('can get the asset balance for an account');
14+
15+
it('can get the asset orders for an address');

tests/Api/BlockTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use OwenVoke\Arionum\Api\Asset;
6+
7+
beforeEach(fn () => $this->apiClass = Asset::class);
8+
9+
it('can get the current block');
10+
11+
it('can get a specific block by its height');
12+
13+
it('can get the transactions for a block');

tests/Api/NodeTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use OwenVoke\Arionum\Api\Asset;
6+
7+
beforeEach(fn () => $this->apiClass = Asset::class);
8+
9+
it('can get the version of the current node');
10+
11+
it('can get information about the current node');
12+
13+
it('can get the sanity details for the current node');
14+
15+
it('can get a list of masternodes');

tests/Api/OtherTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use OwenVoke\Arionum\Api\Asset;
6+
7+
beforeEach(fn () => $this->apiClass = Asset::class);
8+
9+
it('can get a random number');
10+
11+
it('can get the Base58 encoded version of a string');
12+
13+
it('can check a signature is valid');

tests/Api/TransactionTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use OwenVoke\Arionum\Api\Asset;
6+
use OwenVoke\Arionum\Enums\TransactionVersion;
7+
8+
beforeEach(fn () => $this->apiClass = Asset::class);
9+
10+
it('can get the transactions for an address');
11+
12+
it('can get the transactions for a public key');
13+
14+
it('can get a specific transaction');
15+
16+
it('can create a transaction')->with(TransactionVersion::cases());
17+
18+
it('can get the number of transactions in the mempool');

0 commit comments

Comments
 (0)