From 2d394c825c7148ee492dadb8f962b64ad95ca565 Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Fri, 26 Jan 2018 16:48:58 +0800 Subject: [PATCH] shh_newIdentity --- src/Methods/Shh/NewIdentity.php | 58 ++++++++++++++++++++++++++++++ test/unit/ShhApiTest.php | 62 +++++++++++++++++++++++++++++++++ test/unit/ShhBatchTest.php | 50 ++++++++++++++++++++++++++ test/unit/ShhTest.php | 58 ++++++++++++++++++++++++++++++ 4 files changed, 228 insertions(+) create mode 100644 src/Methods/Shh/NewIdentity.php create mode 100644 test/unit/ShhApiTest.php create mode 100644 test/unit/ShhBatchTest.php create mode 100644 test/unit/ShhTest.php diff --git a/src/Methods/Shh/NewIdentity.php b/src/Methods/Shh/NewIdentity.php new file mode 100644 index 0000000..00954db --- /dev/null +++ b/src/Methods/Shh/NewIdentity.php @@ -0,0 +1,58 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Shh; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; + +class NewIdentity extends EthMethod +{ + /** + * validators + * + * @var array + */ + protected $validators = []; + + /** + * inputFormatters + * + * @var array + */ + protected $inputFormatters = []; + + /** + * outputFormatters + * + * @var array + */ + protected $outputFormatters = []; + + /** + * defaultValues + * + * @var array + */ + protected $defaultValues = []; + + /** + * construct + * + * @param string $method + * @param array $arguments + * @return void + */ + // public function __construct($method='', $arguments=[]) + // { + // parent::__construct($method, $arguments); + // } +} \ No newline at end of file diff --git a/test/unit/ShhApiTest.php b/test/unit/ShhApiTest.php new file mode 100644 index 0000000..36d2445 --- /dev/null +++ b/test/unit/ShhApiTest.php @@ -0,0 +1,62 @@ +shh = $this->web3->shh; + } + + /** + * testVersion + * + * @return void + */ + public function testVersion() + { + $shh = $this->shh; + + $shh->version(function ($err, $version) { + if ($err !== null) { + return $this->fail($err->getMessage()); + } + $this->assertTrue(is_string($version)); + }); + } + + /** + * testNewIdentity + * + * @return void + */ + public function testNewIdentity() + { + $shh = $this->shh; + + $shh->newIdentity(function ($err, $identity) { + if ($err !== null) { + return $this->fail($err->getMessage()); + } + $this->assertEquals(mb_strlen($identity), 132); + }); + } +} \ No newline at end of file diff --git a/test/unit/ShhBatchTest.php b/test/unit/ShhBatchTest.php new file mode 100644 index 0000000..0af2786 --- /dev/null +++ b/test/unit/ShhBatchTest.php @@ -0,0 +1,50 @@ +shh = $this->web3->shh; + } + + /** + * testBatch + * + * @return void + */ + public function testBatch() + { + $shh = $this->shh; + + $shh->batch(true); + $shh->version(); + $shh->newIdentity(); + + $shh->provider->execute(function ($err, $data) { + if ($err !== null) { + return $this->fail('Got error!'); + } + $this->assertTrue(is_string($data[0])); + $this->assertEquals(mb_strlen($data[1]), 132); + }); + } +} \ No newline at end of file diff --git a/test/unit/ShhTest.php b/test/unit/ShhTest.php new file mode 100644 index 0000000..d83a74d --- /dev/null +++ b/test/unit/ShhTest.php @@ -0,0 +1,58 @@ +shh = $this->web3->shh; + } + + /** + * testInstance + * + * @return void + */ + public function testInstance() + { + $shh = $this->shh; + + $this->assertTrue($shh->provider instanceof HttpProvider); + $this->assertTrue($shh->provider->requestManager instanceof RequestManager); + } + + /** + * testSetProvider + * + * @return void + */ + public function testSetProvider() + { + $shh = $this->shh; + $requestManager = new HttpRequestManager('http://localhost:8545'); + $shh->provider = new HttpProvider($requestManager); + + $this->assertEquals($shh->provider->requestManager->host, 'http://localhost:8545'); + } +} \ No newline at end of file