Add Shh tests.
This commit is contained in:
parent
9e75e523be
commit
82087c92ce
@ -3,7 +3,9 @@
|
|||||||
namespace Test\Unit;
|
namespace Test\Unit;
|
||||||
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
use InvalidArgumentException;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
|
use Web3\Shh;
|
||||||
|
|
||||||
class ShhApiTest extends TestCase
|
class ShhApiTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -463,4 +465,36 @@ class ShhApiTest extends TestCase
|
|||||||
// $this->assertTrue(true);
|
// $this->assertTrue(true);
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
/**
|
||||||
|
* testUnallowedMethod
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testUnallowedMethod()
|
||||||
|
{
|
||||||
|
$this->expectException(RuntimeException::class);
|
||||||
|
|
||||||
|
$shh = $this->shh;
|
||||||
|
|
||||||
|
$shh->hello(function ($err, $hello) {
|
||||||
|
if ($err !== null) {
|
||||||
|
return $this->fail($err->getMessage());
|
||||||
|
}
|
||||||
|
$this->assertTrue(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testWrongCallback
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testWrongCallback()
|
||||||
|
{
|
||||||
|
$this->expectException(InvalidArgumentException::class);
|
||||||
|
|
||||||
|
$shh = $this->shh;
|
||||||
|
|
||||||
|
$shh->version();
|
||||||
|
}
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ use Test\TestCase;
|
|||||||
use Web3\Providers\HttpProvider;
|
use Web3\Providers\HttpProvider;
|
||||||
use Web3\RequestManagers\RequestManager;
|
use Web3\RequestManagers\RequestManager;
|
||||||
use Web3\RequestManagers\HttpRequestManager;
|
use Web3\RequestManagers\HttpRequestManager;
|
||||||
|
use Web3\Shh;
|
||||||
|
|
||||||
class ShhTest extends TestCase
|
class ShhTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -36,7 +37,7 @@ class ShhTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInstance()
|
public function testInstance()
|
||||||
{
|
{
|
||||||
$shh = $this->shh;
|
$shh = new Shh($this->testHost);
|
||||||
|
|
||||||
$this->assertTrue($shh->provider instanceof HttpProvider);
|
$this->assertTrue($shh->provider instanceof HttpProvider);
|
||||||
$this->assertTrue($shh->provider->requestManager instanceof RequestManager);
|
$this->assertTrue($shh->provider->requestManager instanceof RequestManager);
|
||||||
@ -54,5 +55,22 @@ class ShhTest extends TestCase
|
|||||||
$shh->provider = new HttpProvider($requestManager);
|
$shh->provider = new HttpProvider($requestManager);
|
||||||
|
|
||||||
$this->assertEquals($shh->provider->requestManager->host, 'http://localhost:8545');
|
$this->assertEquals($shh->provider->requestManager->host, 'http://localhost:8545');
|
||||||
|
|
||||||
|
$shh->provider = null;
|
||||||
|
|
||||||
|
$this->assertEquals($shh->provider->requestManager->host, 'http://localhost:8545');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testCallThrowRuntimeException
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testCallThrowRuntimeException()
|
||||||
|
{
|
||||||
|
$this->expectException(RuntimeException::class);
|
||||||
|
|
||||||
|
$shh = new Shh(null);
|
||||||
|
$shh->post([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user