eth_getBlockByHash
This commit is contained in:
parent
113c71e27a
commit
2fee27e6ca
10
src/Eth.php
10
src/Eth.php
@ -12,6 +12,7 @@ use Web3\Validators\QuantityValidator;
|
||||
use Web3\Validators\BlockHashValidator;
|
||||
use Web3\Validators\HexValidator;
|
||||
use Web3\Validators\TransactionValidator;
|
||||
use Web3\Validators\BooleanValidator;
|
||||
|
||||
class Eth
|
||||
{
|
||||
@ -161,6 +162,15 @@ class Eth
|
||||
'validators' => TransactionValidator::class
|
||||
]
|
||||
]
|
||||
],
|
||||
'eth_getBlockByHash' => [
|
||||
'params' => [
|
||||
[
|
||||
'validators' => BlockHashValidator::class
|
||||
], [
|
||||
'validators' => BooleanValidator::class
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
|
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user