From 4a2d64c398cf796791f85bf7b68f15f5860d7aa3 Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Thu, 14 Dec 2017 22:01:09 +0800 Subject: [PATCH] eth_newBlockFilter --- src/Eth.php | 7 +++++++ test/unit/EthTest.php | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/Eth.php b/src/Eth.php index cf5938b..cb5ab62 100644 --- a/src/Eth.php +++ b/src/Eth.php @@ -267,6 +267,13 @@ class Eth 'validators' => FilterValidator::class ] ] + ], + 'eth_newBlockFilter' => [ + 'params' => [ + [ + 'validators' => QuantityValidator::class + ] + ] ] ]; diff --git a/test/unit/EthTest.php b/test/unit/EthTest.php index b3a9787..6b8e052 100644 --- a/test/unit/EthTest.php +++ b/test/unit/EthTest.php @@ -865,6 +865,32 @@ class EthTest extends TestCase }); } + /** + * testNewBlockFilter + * + * @return void + */ + public function testNewBlockFilter() + { + $eth = $this->eth; + + $eth->newBlockFilter('0x01', function ($err, $filter) { + if ($err !== null) { + // infura banned us to new filter + return $this->assertTrue($err->getCode() === 405); + } + if (isset($filter->result)) { + $this->assertTrue(is_string($filter->result)); + } else { + if (isset($filter->error)) { + $this->assertTrue(is_string($filter->error->message)); + } else { + $this->assertTrue(true); + } + } + }); + } + /** * testUnallowedMethod *