From 596a3599dec2c3e0174c546b053479c99db3e036 Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Fri, 12 Jan 2018 16:11:47 +0800 Subject: [PATCH] Personal api unlockAccount unit test. --- test/unit/PersonalApiTest.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/test/unit/PersonalApiTest.php b/test/unit/PersonalApiTest.php index e9a449a..055bbf6 100644 --- a/test/unit/PersonalApiTest.php +++ b/test/unit/PersonalApiTest.php @@ -14,6 +14,13 @@ class PersonalApiTest extends TestCase */ protected $personal; + /** + * newAccount + * + * @var string + */ + protected $newAccount; + /** * setUp * @@ -55,8 +62,7 @@ class PersonalApiTest extends TestCase $personal->newAccount('123456', function ($err, $account) { if ($err !== null) { - // infura banned us to use new account - return $this->assertTrue($err->getCode() === 405); + return $this->fail($e->getMessage()); } $this->assertTrue(is_string($account)); }); @@ -71,12 +77,21 @@ class PersonalApiTest extends TestCase { $personal = $this->personal; - $personal->unlockAccount('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '123456', function ($err, $account) { + // create account + $personal->newAccount('123456', function ($err, $account) { + if ($err !== null) { + return $this->fail($e->getMessage()); + } + $this->newAccount = $account; + $this->assertTrue(is_string($account)); + }); + + $personal->unlockAccount($this->newAccount, '123456', function ($err, $unlocked) { if ($err !== null) { // infura banned us to use unlock account return $this->assertTrue($err->getCode() === 405); } - $this->assertTrue(is_bool($account)); + $this->assertTrue($unlocked); }); }