Skip to content

Commit

Permalink
Add test for personal_lockAccount
Browse files Browse the repository at this point in the history
Change:
* Add test for personal_lockAccount
  • Loading branch information
sc0Vu committed Dec 13, 2018
1 parent 28627c5 commit f325910
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
13 changes: 13 additions & 0 deletions examples/personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,16 @@
}
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;
}
});
5 changes: 0 additions & 5 deletions src/Methods/Personal/LockAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
33 changes: 33 additions & 0 deletions test/unit/PersonalApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,39 @@ public function testUnlockAccountWithDuration()
});
}

/**
* 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
*
Expand Down

0 comments on commit f325910

Please sign in to comment.