@@ -37,39 +37,31 @@ public class TestChainsql {
37
37
public static String smUserAddress = "zKzpkRTZPtsaQ733G8aRRG5x5Z2bTqhGbt" ;
38
38
39
39
public static String smUserPublicKey = "pYvKjFb71Qrx26jpfMPAkpN1zfr5WTQoHCpsEtE98ZrBCv2EoxEs4rmWR7DcqTwSwEY81opTgL7pzZ2rZ3948vHi4H23vnY3" ;
40
- public static void main (String [] args ) {
41
-
42
-
43
-
44
- // {
45
- // JSONObject options = new JSONObject();
46
- // options.put("algorithm","softGMAlg");
47
- //
48
- // JSONObject ret = c.generateAddress(userSecret);
49
- //
50
- // //c.as(ret.getString("address"), ret.getString("secret"));
51
- //
52
- // System.out.println(ret);
53
- // }
54
40
55
41
42
+ public static String smNewUserSecret = "p96dJiLZfazo4gicnt1UCumwP6LJfFuo6iR4EVLwzYBWqKrJVgf" ;
43
+ public static String smNewUserAddress = "zQA9xJDn2qzdexq2PMXjLhdoNffW1qdXq" ;
56
44
57
- c .connect ("ws://192.168.29.116:5006" );
58
- //c.connect("ws://192.168.29.116:6005");
59
-
60
- sTableName = "JM2" ;
61
- sTableName2 = "tTable2" ;
62
- sReName = "tTable3" ;
63
-
64
- // {"address":"zKvWitcHvViJ7iVk8U313rkrp8ChYcJUk4","secret":"xhhMqARTEB2aUJgJs4pxvKxcKxHAj","publicKey":"cBQNvNdVSQqPXqWnUMvnsoDhGxzCZfxmoJpVMGzBCdDboDTgLvBv"}
65
- sNewAccountId = "zpMZ2H58HFPB5QTycMGWSXUeF47eA8jyd4" ;
66
- c .as (rootAddress , rootSecret );
45
+ public static String smNewUserPublicKey = "pYvNX91FDmctDr7F9PPk8kEJz5XddiXyRfjHVWPP8Rekpb9Qc6WBrN1PBoNwMhkF1dHb46KpeUMzZahwL1sRqg3FDyGkRqhs" ;
67
46
68
- //c.generateAddress()
47
+ public static void main ( String [] args ) {
69
48
70
- //String pemContent = readCertFile("D:\\git\\ca\\test\\userCert.cert");
71
- //c.useCert(pemContent);
49
+ c .connect ("ws://192.168.29.69:5003" );
72
50
51
+ //
52
+ sTableName = "B19" ;
53
+ // sTableName2 = "tTable2";
54
+ // sReName = "tTable3";
55
+ //
56
+ // // {"address":"zKvWitcHvViJ7iVk8U313rkrp8ChYcJUk4","secret":"xhhMqARTEB2aUJgJs4pxvKxcKxHAj","publicKey":"cBQNvNdVSQqPXqWnUMvnsoDhGxzCZfxmoJpVMGzBCdDboDTgLvBv"}
57
+ // sNewAccountId = "zpMZ2H58HFPB5QTycMGWSXUeF47eA8jyd4";
58
+ c .as (smRootAddress , smRootSecret );
59
+ //
60
+ // //c.generateAddress()
61
+ //
62
+ // //String pemContent = readCertFile("D:\\git\\ca\\test\\userCert.cert");
63
+ // //c.useCert(pemContent);
64
+ //
73
65
//testRipple();
74
66
testChainSql ();
75
67
}
@@ -112,23 +104,23 @@ private static String readCertFile(String pemPath){
112
104
private static void testChainSql () {
113
105
TestChainsql test = new TestChainsql ();
114
106
//建表
115
- // test.testCreateTable();
107
+ test .testCreateTable ();
116
108
//建表,用于重命名,删除
117
109
// test.testCreateTable1();
118
110
// //插入数据
119
- // test.testinsert();
111
+ test .testinsert ();
120
112
// //更新表数据
121
- // test.testUpdateTable();
113
+ test .testUpdateTable ();
122
114
// //删除表数据
123
- // test.testdelete();
115
+ test .testdelete ();
124
116
// //重命名表
125
- // test.testrename();
117
+ test .testrename ();
126
118
// //查询表数据
127
- // test.testget();
119
+ test .testget ();
128
120
// //删除表
129
- // test.testdrop();
121
+ test .testdrop ();
130
122
// //授权
131
- // test.grant();
123
+ test .grant ();
132
124
// //授权后使用被授权账户插入数据
133
125
test .insertAfterGrant ();
134
126
@@ -147,7 +139,7 @@ private static void testRipple() {
147
139
// //生成新账户
148
140
// test.generateAccount();
149
141
// //给新账户打钱
150
- test .activateAccount (smUserAddress );
142
+ test .activateAccount (smNewUserAddress );
151
143
152
144
// test.getTransactions();
153
145
// test.getTransaction();
@@ -259,7 +251,7 @@ public void testCreateTable() {
259
251
"{'field':'name','type':'varchar','length':50,'default':null}" , "{'field':'age','type':'int'}" );
260
252
261
253
JSONObject obj ;
262
- obj = c .createTable (sTableName ,args ,true ).submit (SyncCond .db_success );
254
+ obj = c .createTable (sTableName ,args ,false ).submit (SyncCond .db_success );
263
255
System .out .println ("create result:" + obj );
264
256
}
265
257
@@ -269,28 +261,28 @@ public void testinsert() {
269
261
// obj = c.table(sTableName).insert(orgs).submit(SyncCond.db_success);
270
262
// System.out.println("insert result:" + obj);
271
263
for (int i = 0 ; i <1 ; i ++) {
272
- List <String > orgs = Util .array ("{'id':1 ,'age': 333,'name':'hello'}" );
264
+ List <String > orgs = Util .array ("{'id':11 ,'age': 333,'name':'hello'}" );
273
265
JSONObject obj ;
274
266
obj = c .table (sTableName ).insert (orgs ).submit (SyncCond .db_success );
275
267
System .out .println ("insert result:" + obj );
276
- orgs = Util .array ("{'id':2 ,'age': 444,'name':'sss'}" );
268
+ orgs = Util .array ("{'id':22 ,'age': 444,'name':'sss'}" );
277
269
obj = c .table (sTableName ).insert (orgs ).submit (SyncCond .db_success );
278
270
System .out .println ("insert result:" + obj );
279
- orgs = Util .array ("{'id':3 ,'age': 555,'name':'rrr'}" );
271
+ orgs = Util .array ("{'id':33 ,'age': 555,'name':'rrr'}" );
280
272
obj = c .table (sTableName ).insert (orgs ).submit (SyncCond .db_success );
281
273
System .out .println ("insert result:" + obj );
282
274
}
283
275
284
276
}
285
277
286
278
public void insertAfterGrant (){
287
- c .as (userAddress , userSecret );
288
- c .use (rootAddress );
289
- List <String > orgs = Util .array ("{'id':100 ,'age': 333,'name':'hello'}" ,"{'id':101 ,'age': 444,'name':'sss'}" ,"{'id':102 ,'age': 555,'name':'rrr'}" );
279
+ c .as (smNewUserAddress , smNewUserSecret );
280
+ c .use (smRootAddress );
281
+ List <String > orgs = Util .array ("{'id':105 ,'age': 333,'name':'hello'}" ,"{'id':106 ,'age': 444,'name':'sss'}" ,"{'id':107 ,'age': 555,'name':'rrr'}" );
290
282
JSONObject obj ;
291
283
obj = c .table (sTableName ).insert (orgs ).submit (SyncCond .db_success );
292
284
System .out .println ("insert after grant result:" + obj );
293
- c .as (rootAddress , rootSecret );
285
+ // c.as(rootAddress, rootSecret);
294
286
}
295
287
296
288
public void testUpdateTable () {
@@ -373,7 +365,7 @@ public void testGetBySqlUser() {
373
365
374
366
public void grant () {
375
367
JSONObject obj = new JSONObject ();
376
- obj = c .grant (sTableName , userAddress , userPublicKey ,"{insert:true,update:true}" )
368
+ obj = c .grant (sTableName , smNewUserAddress , smNewUserPublicKey ,"{insert:true,update:true}" )
377
369
.submit (SyncCond .validate_success );
378
370
System .out .println ("grant result:" + obj .toString ());
379
371
}
0 commit comments