eth_getBlockTransactionCountByNumber

This commit is contained in:
sc0Vu 2017-12-13 21:06:56 +08:00
parent d14b6c7ee1
commit 6a95cdef15
3 changed files with 37 additions and 1 deletions

View File

@ -79,6 +79,16 @@ class Eth
] ]
] ]
], ],
'eth_getBlockTransactionCountByNumber' => [
'params' => [
[
'default' => 'latest',
'validators' => [
TagValidator::class, QuantityValidator::class,
]
]
]
],
]; ];
/** /**

View File

@ -15,6 +15,6 @@ class QuantityValidator
public static function validate($value) public static function validate($value)
{ {
// maybe change in_int and preg_match future // maybe change in_int and preg_match future
return (is_int($value) || preg_match('/^0x[a-fA-f0-9]+/', $value) >= 1); return (is_int($value) || preg_match('/^0x[a-fA-f0-9]+$/', $value) >= 1);
} }
} }

View File

@ -287,6 +287,32 @@ class EthTest extends TestCase
}); });
} }
/**
* testGetBlockTransactionCountByNumber
*
* @return void
*/
public function testGetBlockTransactionCountByNumber()
{
$eth = $this->web3->eth;
$eth->getBlockTransactionCountByNumber('0x0', function ($err, $transactionCount) {
if ($err !== null) {
return $this->fail($err->getMessage());
}
if (isset($transactionCount->result)) {
var_dump($transactionCount->result);
$this->assertTrue(is_string($transactionCount->result));
} else {
if (isset($transactionCount->error)) {
$this->fail($transactionCount->error->message);
} else {
$this->assertTrue(true);
}
}
});
}
/** /**
* testUnallowedMethod * testUnallowedMethod
* *