personal_listAccounts
This commit is contained in:
parent
4aa3e07576
commit
20e3dcde10
73
test/unit/PersonalApiTest.php
Normal file
73
test/unit/PersonalApiTest.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Test\Unit;
|
||||
|
||||
use RuntimeException;
|
||||
use Test\TestCase;
|
||||
|
||||
class PersonalApiTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* personal
|
||||
*
|
||||
* @var Web3\Personal
|
||||
*/
|
||||
protected $personal;
|
||||
|
||||
/**
|
||||
* setUp
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->personal = $this->web3->personal;
|
||||
}
|
||||
|
||||
/**
|
||||
* testListAccounts
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testListAccounts()
|
||||
{
|
||||
$personal = $this->personal;
|
||||
|
||||
$personal->listAccounts(function ($err, $accounts) {
|
||||
if ($err !== null) {
|
||||
// infura banned us to use list accounts
|
||||
return $this->assertTrue($err->getCode() === 405);
|
||||
}
|
||||
if (isset($accounts->result)) {
|
||||
$this->assertTrue(is_array($accounts->result));
|
||||
} else {
|
||||
$this->fail($accounts->error->message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* testUnallowedMethod
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testUnallowedMethod()
|
||||
{
|
||||
$this->expectException(RuntimeException::class);
|
||||
|
||||
$personal = $this->personal;
|
||||
|
||||
$personal->hello(function ($err, $hello) {
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
if (isset($hello->result)) {
|
||||
$this->assertTrue(true);
|
||||
} else {
|
||||
$this->fail($hello->error->message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user