Merge pull request #131 from sc0Vu/add-test
Add test for personal_lockAccount
This commit is contained in:
commit
d579535485
@ -38,3 +38,16 @@ $web3->eth->getBalance($newAccount, function ($err, $balance) {
|
||||
}
|
||||
echo 'Balance: ' . $balance->toString() . PHP_EOL;
|
||||
});
|
||||
|
||||
// remember to lock account after transaction
|
||||
$personal->lockAccount($newAccount, function ($err, $locked) {
|
||||
if ($err !== null) {
|
||||
echo 'Error: ' . $err->getMessage();
|
||||
return;
|
||||
}
|
||||
if ($locked) {
|
||||
echo 'New account is locked!' . PHP_EOL;
|
||||
} else {
|
||||
echo 'New account isn\'t locked' . PHP_EOL;
|
||||
}
|
||||
});
|
||||
|
@ -11,14 +11,9 @@
|
||||
|
||||
namespace Web3\Methods\Personal;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Web3\Methods\EthMethod;
|
||||
use Web3\Validators\AddressValidator;
|
||||
use Web3\Validators\StringValidator;
|
||||
use Web3\Validators\QuantityValidator;
|
||||
use Web3\Formatters\AddressFormatter;
|
||||
use Web3\Formatters\StringFormatter;
|
||||
use Web3\Formatters\NumberFormatter;
|
||||
|
||||
class LockAccount extends EthMethod
|
||||
{
|
||||
|
@ -121,6 +121,39 @@ class PersonalApiTest extends TestCase
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* testLockAccount
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testLockAccount()
|
||||
{
|
||||
$personal = $this->personal;
|
||||
|
||||
// create account
|
||||
$personal->newAccount('123456', function ($err, $account) {
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->newAccount = $account;
|
||||
$this->assertTrue(is_string($account));
|
||||
});
|
||||
|
||||
$personal->unlockAccount($this->newAccount, '123456', function ($err, $unlocked) {
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->assertTrue($unlocked);
|
||||
});
|
||||
|
||||
$personal->lockAccount($this->newAccount, function ($err, $locked) {
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->assertTrue($locked);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* testSendTransaction
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user