eth_getBlockByNumber

This commit is contained in:
sc0Vu 2017-12-14 18:22:55 +08:00
parent 54159e3c6f
commit f48df7d2c7
2 changed files with 37 additions and 0 deletions

View File

@ -171,6 +171,17 @@ class Eth
'validators' => BooleanValidator::class 'validators' => BooleanValidator::class
] ]
] ]
],
'eth_getBlockByNumber' => [
'params' => [
[
'validators' => [
QuantityValidator::class, TagValidator::class
]
], [
'validators' => BooleanValidator::class
]
]
] ]
]; ];

View File

@ -557,6 +557,32 @@ class EthTest extends TestCase
}); });
} }
/**
* testGetBlockByNumber
*
* @return void
*/
public function testGetBlockByNumber()
{
$eth = $this->eth;
$eth->getBlockByNumber('latest', false, function ($err, $block) {
if ($err !== null) {
return $this->fail($err->getMessage());
}
if (isset($block->result)) {
// weired behavior, see https://github.com/sc0Vu/web3.php/issues/16
$this->assertTrue($block->result !== null);
} else {
if (isset($block->error)) {
$this->fail($block->error->message);
} else {
$this->assertTrue(true);
}
}
});
}
/** /**
* testUnallowedMethod * testUnallowedMethod
* *