diff --git a/test/unit/HttpProviderTest.php b/test/unit/HttpProviderTest.php new file mode 100644 index 0000000..3a28bf2 --- /dev/null +++ b/test/unit/HttpProviderTest.php @@ -0,0 +1,60 @@ +send($method, function ($err, $version) { + if ($err !== null) { + $this->fail($err->getMessage()); + } + $this->assertTrue(is_string($version)); + }); + } + + /** + * testBatch + * + * @return void + */ + public function testBatch() + { + $requestManager = new HttpRequestManager('http://localhost:8545'); + $provider = new HttpProvider($requestManager); + $method = new ClientVersion('web3_clientVersion', []); + $callback = function ($err, $data) { + if ($err !== null) { + $this->fail($err->getMessage()); + } + $this->assertEquals($data[0], $data[1]); + }; + + try { + $provider->execute($callback); + } catch (RuntimeException $err) { + $this->assertTrue($err->getMessage() !== true); + } + + $provider->batch(true); + $provider->send($method, null); + $provider->send($method, null); + $provider->execute($callback); + } +} \ No newline at end of file