OSDN Git Service

merge tx signer
[bytom/bytom-java-sdk.git] / java-sdk / src / test / java / io / bytom / integration / KeyTest.java
1 package io.bytom.integration;
2
3 import io.bytom.TestUtils;
4 import io.bytom.api.Key;
5 import io.bytom.exception.BytomException;
6 import io.bytom.http.Client;
7 import org.junit.Test;
8
9 import java.util.List;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotEquals;
13 import static org.junit.Assert.assertNotNull;
14
15 public class KeyTest {
16
17     static Client client;
18     static Key key;
19
20     @Test
21     public void testClientKeyCreate() throws Exception {
22         client = TestUtils.generateClient();
23
24         String alias = "KeyTest.testKeyCreate.successli004";
25         String password = "123456";
26
27         Key.Builder builder = new Key.Builder().setAlias(alias).setPassword(password);
28         key = Key.create(client, builder);
29
30         assertNotNull(key.xpub);
31         assertEquals(alias.toLowerCase(), key.alias);
32     }
33
34     @Test
35     public void testClientKeyList() throws Exception {
36         //client = TestUtils.generateClient();
37         client = new Client("http://127.0.0.1:9888/");
38         List<Key> keyList = Key.list(client);
39     }
40
41     @Test
42     public void testClientKeyDelete() throws Exception {
43         client = TestUtils.generateClient();
44         List<Key> keyList = Key.list(client);
45         String xpub = keyList.get(keyList.size()-1).xpub;
46         //delete the last Key Object
47         Key.delete(client, xpub, "123456");
48     }
49
50     @Test
51     public void testClientKeyResetPassword() throws BytomException {
52         client = TestUtils.generateClient();
53         List<Key> keyList = Key.list(client);
54         String xpub = keyList.get(keyList.size()-1).xpub;
55         Key.resetPassword(client, xpub, "123456", "123456789");
56         Key.delete(client, xpub, "123456789");
57     }
58
59 }