-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |