Skip to content

Commit

Permalink
Add submitblock command
Browse files Browse the repository at this point in the history
  • Loading branch information
vherus committed Apr 18, 2018
1 parent 977127b commit 347791e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Command/Mining/SubmitBlock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace ZenCash\Rpc\Command\Mining;

use ZenCash\Rpc\Command;

final class SubmitBlock implements Command
{
private const METHOD = 'submitblock';
private $hexData;

public function __construct(string $hexData)
{
$this->hexData = $hexData;
}

public function jsonSerialize(): object
{
return (object) [
'jsonrpc' => Command::JSON_RPC_VERSION,
'id' => Command::ID,
'method' => self::METHOD,
'params' => [$this->hexData]
];
}
}
20 changes: 20 additions & 0 deletions tests/Command/Mining/SubmitBlockTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace ZenCash\Rpc\Command\Mining;

use PHPUnit\Framework\TestCase;

class SubmitBlockTest extends TestCase
{
public function test_serialize_returns_expected_object()
{
$expected = (object) [
'jsonrpc' => '1.0',
'id' => 'curl',
'method' => 'submitblock',
'params' => ['mytestdata']
];

$this->assertEquals($expected, (new SubmitBlock('mytestdata'))->jsonSerialize());
}
}

0 comments on commit 347791e

Please sign in to comment.