aboutsummaryrefslogtreecommitdiffstats
path: root/mobile/android_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-12-08 20:42:31 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-01-05 18:58:03 +0800
commitb37d175e59cda8c6afd6b4b1d6b7ed921dc59279 (patch)
treed78f5ca6d55effcf4f91a37f3d123983d96421fa /mobile/android_test.go
parentbbce726c8a85e72141d9d7e690711738c09ede3b (diff)
downloaddexon-b37d175e59cda8c6afd6b4b1d6b7ed921dc59279.tar.gz
dexon-b37d175e59cda8c6afd6b4b1d6b7ed921dc59279.tar.zst
dexon-b37d175e59cda8c6afd6b4b1d6b7ed921dc59279.zip
accounts, internal, mobile: polish accounts API, extend Android tests
Diffstat (limited to 'mobile/android_test.go')
-rw-r--r--mobile/android_test.go37
1 files changed, 31 insertions, 6 deletions
diff --git a/mobile/android_test.go b/mobile/android_test.go
index 0a3fa93ae..9e38c1986 100644
--- a/mobile/android_test.go
+++ b/mobile/android_test.go
@@ -14,9 +14,6 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-// Contains all the wrappers from the accounts package to support client side key
-// management on mobile platforms.
-
package geth
import (
@@ -46,14 +43,42 @@ public class AndroidTest extends InstrumentationTestCase {
public AndroidTest() {}
public void testAccountManagement() {
- try {
- AccountManager am = new AccountManager(getInstrumentation().getContext().getFilesDir() + "/keystore", Geth.LightScryptN, Geth.LightScryptP);
+ // Create an encrypted keystore manager with light crypto parameters.
+ AccountManager am = new AccountManager(getInstrumentation().getContext().getFilesDir() + "/keystore", Geth.LightScryptN, Geth.LightScryptP);
+ try {
+ // Create a new account with the specified encryption passphrase.
Account newAcc = am.newAccount("Creation password");
+
+ // Export the newly created account with a different passphrase. The returned
+ // data from this method invocation is a JSON encoded, encrypted key-file.
byte[] jsonAcc = am.exportKey(newAcc, "Creation password", "Export password");
- am.deleteAccount(newAcc, "Creation password");
+ // Update the passphrase on the account created above inside the local keystore.
+ am.updateAccount(newAcc, "Creation password", "Update password");
+
+ // Delete the account updated above from the local keystore.
+ am.deleteAccount(newAcc, "Update password");
+
+ // Import back the account we've exported (and then deleted) above with yet
+ // again a fresh passphrase.
Account impAcc = am.importKey(jsonAcc, "Export password", "Import password");
+
+ // Create a new account to sign transactions with
+ Account signer = am.newAccount("Signer password");
+ Hash txHash = new Hash("0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef");
+
+ // Sign a transaction with a single authorization
+ byte[] signature = am.signWithPassphrase(signer, "Signer password", txHash.getBytes());
+
+ // Sign a transaction with multiple manually cancelled authorizations
+ am.unlock(signer, "Signer password");
+ signature = am.sign(signer.getAddress(), txHash.getBytes());
+ am.lock(signer.getAddress());
+
+ // Sign a transaction with multiple automatically cancelled authorizations
+ am.timedUnlock(signer, "Signer password", 1000000000);
+ signature = am.sign(signer.getAddress(), txHash.getBytes());
} catch (Exception e) {
fail(e.toString());
}