From f5286c03987c5c41ef14551e3ba48ce123b9881d Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Fri, 26 Jan 2018 17:27:55 +0800 Subject: [PATCH] shh_addToGroup --- src/Methods/Shh/AddToGroup.php | 61 ++++++++++++++++++++++++++++++++++ src/Shh.php | 2 +- test/unit/ShhApiTest.php | 27 +++++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 src/Methods/Shh/AddToGroup.php diff --git a/src/Methods/Shh/AddToGroup.php b/src/Methods/Shh/AddToGroup.php new file mode 100644 index 0000000..11c69c1 --- /dev/null +++ b/src/Methods/Shh/AddToGroup.php @@ -0,0 +1,61 @@ + + * + * @author Peter Lai + * @license MIT + */ + +namespace Web3\Methods\Shh; + +use InvalidArgumentException; +use Web3\Methods\EthMethod; +use Web3\Validators\IdentityValidator; + +class AddToGroup extends EthMethod +{ + /** + * validators + * + * @var array + */ + protected $validators = [ + IdentityValidator::class + ]; + + /** + * 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/src/Shh.php b/src/Shh.php index d700457..87e15e9 100644 --- a/src/Shh.php +++ b/src/Shh.php @@ -39,7 +39,7 @@ class Shh */ private $allowedMethods = [ 'shh_version', 'shh_newIdentity', 'shh_hasIdentity', - // doesn't exist: 'shh_newGroup' + // doesn't exist: 'shh_newGroup', 'shh_addToGroup' ]; /** diff --git a/test/unit/ShhApiTest.php b/test/unit/ShhApiTest.php index e216379..c6567dd 100644 --- a/test/unit/ShhApiTest.php +++ b/test/unit/ShhApiTest.php @@ -111,6 +111,33 @@ class ShhApiTest extends TestCase // }); // } + /** + * testAddToGroup + * + * @return void + */ + // public function testAddToGroup() + // { + // $shh = $this->shh; + // $newIdentity = ''; + + // $shh->newIdentity(function ($err, $identity) use (&$newIdentity) { + // if ($err !== null) { + // return $this->fail($err->getMessage()); + // } + // $newIdentity = $identity; + + // $this->assertEquals(mb_strlen($identity), 132); + // }); + + // $shh->addToGroup($newIdentity, function ($err, $hasAdded) { + // if ($err !== null) { + // return $this->fail($err->getMessage()); + // } + // $this->assertTrue($hasAdded); + // }); + // } + /** * testWrongParam * We transform data and throw invalid argument exception