shh_newIdentity
This commit is contained in:
parent
5e12df17a5
commit
2d394c825c
58
src/Methods/Shh/NewIdentity.php
Normal file
58
src/Methods/Shh/NewIdentity.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of web3.php package.
|
||||
*
|
||||
* (c) Kuan-Cheng,Lai <alk03073135@gmail.com>
|
||||
*
|
||||
* @author Peter Lai <alk03073135@gmail.com>
|
||||
* @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);
|
||||
// }
|
||||
}
|
62
test/unit/ShhApiTest.php
Normal file
62
test/unit/ShhApiTest.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Test\Unit;
|
||||
|
||||
use RuntimeException;
|
||||
use Test\TestCase;
|
||||
|
||||
class ShhApiTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* shh
|
||||
*
|
||||
* @var Web3\Shh
|
||||
*/
|
||||
protected $shh;
|
||||
|
||||
/**
|
||||
* setUp
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->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);
|
||||
});
|
||||
}
|
||||
}
|
50
test/unit/ShhBatchTest.php
Normal file
50
test/unit/ShhBatchTest.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Test\Unit;
|
||||
|
||||
use RuntimeException;
|
||||
use Test\TestCase;
|
||||
|
||||
class ShhBatchTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* shh
|
||||
*
|
||||
* @var Web3\Shh
|
||||
*/
|
||||
protected $shh;
|
||||
|
||||
/**
|
||||
* setUp
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->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);
|
||||
});
|
||||
}
|
||||
}
|
58
test/unit/ShhTest.php
Normal file
58
test/unit/ShhTest.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace Test\Unit;
|
||||
|
||||
use RuntimeException;
|
||||
use Test\TestCase;
|
||||
use Web3\Providers\HttpProvider;
|
||||
use Web3\RequestManagers\RequestManager;
|
||||
use Web3\RequestManagers\HttpRequestManager;
|
||||
|
||||
class PersonalTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* shh
|
||||
*
|
||||
* @var Web3\Shh
|
||||
*/
|
||||
protected $shh;
|
||||
|
||||
/**
|
||||
* setUp
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->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');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user