eth_getBlockByHash

This commit is contained in:
sc0Vu 2017-12-14 17:52:06 +08:00
parent 113c71e27a
commit 2fee27e6ca
2 changed files with 35 additions and 0 deletions

View File

@ -12,6 +12,7 @@ use Web3\Validators\QuantityValidator;
use Web3\Validators\BlockHashValidator; use Web3\Validators\BlockHashValidator;
use Web3\Validators\HexValidator; use Web3\Validators\HexValidator;
use Web3\Validators\TransactionValidator; use Web3\Validators\TransactionValidator;
use Web3\Validators\BooleanValidator;
class Eth class Eth
{ {
@ -161,6 +162,15 @@ class Eth
'validators' => TransactionValidator::class 'validators' => TransactionValidator::class
] ]
] ]
],
'eth_getBlockByHash' => [
'params' => [
[
'validators' => BlockHashValidator::class
], [
'validators' => BooleanValidator::class
]
]
] ]
]; ];

View File

@ -531,6 +531,31 @@ class EthTest extends TestCase
}); });
} }
/**
* testGetBlockByHash
*
* @return void
*/
public function testGetBlockByHash()
{
$eth = $this->web3->eth;
$eth->getBlockByHash('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', false, function ($err, $block) {
if ($err !== null) {
return $this->fail($err->getMessage());
}
if (isset($block->result)) {
$this->assertTrue(is_string($block->result));
} else {
if (isset($block->error)) {
$this->fail($block->error->message);
} else {
$this->assertTrue(true);
}
}
});
}
/** /**
* testUnallowedMethod * testUnallowedMethod
* *