factom 2.1.1

Factom API client
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
use::factom::*;
use std::{iter,thread, time};
use rand::{Rng, thread_rng, distributions::Alphanumeric};

// Hopefully it doesn't need to be said but please don't use these addresses as 
// they are publicly known! They should be funded on testnet for further usage,
// as needed. Please raise an issue if they aren't or top them up yourself at:
// https://faucet.factoid.org/
const FCT_PUB: &str = "FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q";
const FCT_PRIV: &str = "Fs3E9gV6DXsYzf7Fqx1fVBQPQXV695eP3k5XbmHEZVRLkMdD9qCK";
const EC_PUB: &str = "EC2MJzCcHqYJyujnPzjitEaHhtEPVBhmEWUKkv4SVaaKeYcq3fqK";
// const EC_PRIV: &str = "Es3LS7zYa9DSzZuUC14HDpMinehmzz61JG1XFY62rX5pVDenH8Pk";

const ABLOCK_KEYMR: &str = "072334d94450296810cb647172812a5dc7ce518d29ecab411d47494d38ca4c88";
const ABLOCK_HEIGHT: u32 = 220000;
const DBLOCK_KEYMR: &str = "90b344dabe065bcb38c90948cde8ab388e22364257f811da7e7a7e8102efc33f";
const ECBLOCK_KEYMR: &str = "06a56a6917ff26d118b67117908a58832ad741433a3047ce4ec45f03754aeed6";
const ECBLOCK_BODYHASH: &str = "c8b7120687c6bc465a5f0fb0517c9bbaf27ee733238aef3f4b79b772a9590030";
const FBLOCK_KEYMR: &str = "32bf997a124dd31c897cca5d92648f8a1fa18626ff396a89cb34a59aaa47c5b3";
const FBLOCK_HEIGHT: u32 = 218668;
const FBLOCK_BODYMR: &str = "9886c838cd8eddfaaf809a1425d71c49539e86223d1e624dfd0d65fdc1aa8674";

//pnet chain
const CHAIN_ID: &str = "a642a8674f46696cc47fdb6b65f9c87b2a19c5ea8123b3d2f0c13b6f33a9d5ef";
const ENTRY_HASH: &str = "716526c3279184bca11fc453fa9c2ab2f4488a03c821ee107664c9052f01d733";
const RAW_DATA_HASH: &str = "0ae2ab2cf543eed52a13a5a405bded712444cc8f8b6724a00602e1c8550a4ec2";
const RAW_DATA: &str = "000caff62ea5b5aa015c706add7b2463a5be07e1f0537617f553558090f23c7f5600420040e57283e4618f13b18c2be8d14926999331ef4ab905639a82d748634201cd85ae1c22b6186a72eee3f4ae12b8f6fa9c73a8a98b5eae238ed6133424bcef062f0e7b224150494d6574686f64223a2268747470733a2f2f706f6c6f6e6965782e636f6d2f7075626c69633f636f6d6d616e643d72657475726e4f72646572426f6f6b5c753030323663757272656e6379506169723d4254435f4e58545c753030323664657074683d34222c2252657475726e44617461223a227b5c2261736b735c223a5b5b5c22302e30303030313334315c222c343437342e37323033353739345d2c5b5c22302e30303030313334325c222c363038302e39363930373133355d2c5b5c22302e30303030313334355c222c31343831342e38353833353730375d2c5b5c22302e30303030313337385c222c38303030305d5d2c5c22626964735c223a5b5b5c22302e30303030313332375c222c363032382e303333313537355d2c5b5c22302e30303030313332365c222c3236302e34333839313430335d2c5b5c22302e30303030313332355c222c3130393931352e30363731363938315d2c5b5c22302e30303030313332335c222c31323030305d5d2c5c22697346726f7a656e5c223a5c22305c227d222c2254696d657374616d70223a313435303134373830317d";

const ID_PRIV: &str = "idsec2rWrfNTD1x9HPPesA3fz8dmMNZdjmSBULHx8VTXE1J4D9icmAK";
const ID_PUB: &str = "idpub2g25nPNZ2kf6KGTjthYdHT3nykDbwEUEPyGJ52fo55SHwtAvLA";

const KOINIFY: &str = "yellow yellow yellow yellow yellow yellow yellow yellow yellow yellow yellow yellow";
const KOINIFY_PUB: &str = "FA3cih2o2tjEUsnnFR4jX1tQXPpSXFwsp3rhVp6odL5PNCHWvZV1";

const ACK_HASH: &str = "e96cca381bf25f6dd4dfdf9f7009ff84ee6edaa3f47f9ccf06d2787482438f4b";
const ACK_CHAIN: &str = "f9164cd66af9d5773b4523a510b5eefb9a5e626480feeb6671ef2d17510ca300";
const ACK_COMMITTXID: &str = "4876ffeb8f95b72911b4a5115dc8a9fbb89d874db2263a75a9062f37bbbf1fa7";

const FCT_TX_ID: &str = "774ec19ff567b202ca2702b1f3411901ccae8995df46517c134ab3560100c848";
const FCT_TX_TIMESTAMP: usize = 1575574473164;

fn random_string(len: usize)-> String {
  let mut rng = thread_rng();
  iter::repeat(())
        .map(|()| rng.sample(Alphanumeric))
        .take(len)
        .collect()
}

// Address module
#[test]
fn address(){
  let client = Factom::new();
  let import = import::import_addresses(&client, vec!(FCT_PRIV));
  fetch(import).unwrap();
  let query = factom::address::address(&client, FCT_PUB);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  assert_eq!(response.result.secret, FCT_PRIV);
}

#[test]
fn all_addresses(){
  let client = Factom::new();
  let import = import::import_addresses(&client, vec!(FCT_PRIV));
  fetch(import).unwrap();
  let query = address::all_addresses(&client);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  let address_present = response
                        .result
                        .addresses
                        .iter()
                        .find(|&x| x.public == FCT_PUB);
  assert!(address_present.is_some());
}

#[test]
fn rm_address(){
  let client = Factom::new();
  let query = generate::factoid_address(&client);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  let address = response.result.public;
  let rm_query = address::remove_address(&client, &address);
  let rm_response = fetch(rm_query).expect("Fetching Query");
  dbg!(&rm_response);
  assert!(rm_response.result.success);
}

// Balance module
#[test]
fn balance(){
  let client = Factom::testnet_node();
  let query = balance::factoid_balance(&client, FCT_PUB);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  assert_eq!(response.error.code, 0);
}

#[test]
fn ec_balance(){
  let client = Factom::testnet_node();
  let query = balance::entry_credit_balance(&client, EC_PUB);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  assert_eq!(response.error.code, 0);
}

#[test]
fn multiple_balances(){
  let client = Factom::testnet_node();
  let query = balance::multiple_fct_balances(&client, vec!(FCT_PUB));
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  assert_eq!(response.error.code, 0);
}

#[test]
fn multiple_ec_balances(){
  let client = Factom::testnet_node();
  let query = balance::multiple_ec_balances(&client, vec!(EC_PUB));
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  assert_eq!(response.error.code, 0);
}

// Block module
#[test]
fn ablock_height(){
  let client = Factom::open_node();
  let query = block::ablock_by_height(&client, ABLOCK_HEIGHT);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  assert_eq!(response.result.ablock.header.dbheight, ABLOCK_HEIGHT as usize);
}

#[test]
fn admin_block(){
  let client = Factom::open_node();
  let query = block::admin_block(&client, ABLOCK_KEYMR);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  assert_eq!(response.result.ablock.header.dbheight, ABLOCK_HEIGHT as usize);
}

#[test]
fn anchors(){
  let client = Factom::open_node();
  let query = block::anchors(
                        &client, 
                        block::AnchorType::Height(ABLOCK_HEIGHT as usize)
                      );
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
}

#[test]
fn dblock_height(){
  let client = Factom::open_node();
  let query = block::dblock_by_height(&client, ABLOCK_HEIGHT);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response.result.dblock.header);
  assert_eq!(response.result.dblock.header.dbheight, ABLOCK_HEIGHT as usize);
}

#[test]
fn directory_block(){
  let client = Factom::open_node();
  let query = block::directory_block(&client, DBLOCK_KEYMR);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response.result.header);
  assert_eq!(response.result.header.timestamp, 1573694640);
}

#[test]
fn directory_block_head(){
  let client = Factom::open_node();
  let query = block::directory_block_head(&client);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  assert_eq!(response.error.code, 0);
}

#[test]
fn ecblock_height(){
  let client = Factom::open_node();
  let query = block::ecblock_by_height(&client, 218668);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response.result.ecblock.header);
  assert_eq!(response.result.ecblock.header.bodyhash, ECBLOCK_BODYHASH);
}

#[test]
fn ec_block(){
  let client = Factom::open_node();
  let query = block::entry_credit_block(&client, ECBLOCK_KEYMR);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response.result.ecblock.header);
  assert_eq!(response.result.ecblock.header.bodyhash, ECBLOCK_BODYHASH);
}

#[test]
fn fct_block(){
  let client = Factom::open_node();
  let query = block::factoid_block(&client, FBLOCK_KEYMR);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response.result.fblock);
  assert_eq!(response.result.fblock.bodymr, FBLOCK_BODYMR);
}

#[test]
fn fctblock_height(){
  let client = Factom::open_node();
  let query = block::fblock_by_height(&client, FBLOCK_HEIGHT);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response.result.fblock);
  assert_eq!(response.result.fblock.bodymr, FBLOCK_BODYMR);
}

#[test]
fn chain_head(){
  let client = Factom::open_node();
  let query = chain::chain_head(&client, CHAIN_ID);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  assert!(response.success());
}

// This test only passes with a local or testnet factomd 
#[test]
fn create_chain_and_make_entry(){
  // Create Chain
  let client = Factom::new();
  let rand_ext_id = &random_string(12);
  let ext_ids = vec!("Api Client", "Test Chain", rand_ext_id);
  let content = random_string(32);
  
  let compose_query = compose::compose_chain(&client, ext_ids, &content, EC_PUB);
  let compose_response = fetch(compose_query).expect("Fetching Query");
  dbg!(&compose_response);
  
  let commit = compose_response.result.commit.params.message;
  let commit_query = chain::commit_chain(&client, &commit);
  let commit_response = fetch(commit_query).expect("Fetching Query");
  dbg!(&commit_response);
  let reveal = compose_response.result.reveal.params.entry;
  let reveal_query = chain::reveal_chain(&client, &reveal);
  let reveal_response = fetch(reveal_query).expect("Fetching Query");
  dbg!(&reveal_response);
  assert!(reveal_response.success());

  // Make Entry
  let rand_ext_id = &random_string(12);
  let ext_ids = vec!("Api Client", "Test Entry", rand_ext_id);
  let content = random_string(32);
  
  let chainid = &reveal_response.result.chainid;
  dbg!(chainid);

  // Wait for next block
  thread::sleep(time::Duration::from_secs(10));

  let compose_query = compose::compose_entry(&client,
                                            chainid,
                                            ext_ids, 
                                            &content, 
                                            EC_PUB);
  let compose_response = fetch(compose_query).expect("Fetching Query");
  dbg!(&compose_response);

  let commit = compose_response.result.commit.params.message;
  let commit_query = entry::commit_entry(&client, &commit);
  let commit_response = fetch(commit_query).expect("Fetching Query");
  dbg!(&commit_response);

  let reveal = compose_response.result.reveal.params.entry;
  let reveal_query = entry::reveal_entry(&client, &reveal);
  let reveal_response = fetch(reveal_query).expect("Fetching Query");
  dbg!(&reveal_response);
  assert!(reveal_response.success());
}

// Debug Module
// Open_node doesn't expose debug functionality, these can all be tested with a 
//local factomd  node running a debug network with a command such as factomd -network=LOCAL
// #[test]
// fn holding_queue(){
//   let client = Factom::new();
//   let query = debug::holding_queue(&client);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn network_info(){
//   let client = Factom::new();
//   let query = debug::network_info(&client);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn predictive_fer(){
//   let client = Factom::new();
//   let query = debug::predictive_fer(&client);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn audit_servers(){
//   let client = Factom::new();
//   let query = debug::audit_servers(&client);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn federated_servers(){
//   let client = Factom::new();
//   let query = debug::federated_servers(&client);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn configuration(){
//   let client = Factom::new();
//   let query = debug::configuration(&client);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn process_list(){
//   let client = Factom::new();
//   let query = debug::process_list(&client);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn authorities(){
//   let client = Factom::new();
//   let query = debug::authorities(&client);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn reload_configuration(){
//   let client = Factom::new();
//   let query = debug::reload_configuration(&client);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn drop_rate(){
//   let client = Factom::new();
//   let query = debug::network_info(&client);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn set_drop_rate(){
//   let client = Factom::new();
//   let query = debug::set_drop_rate(&client, 10);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn delay(){
//   let client = Factom::new();
//   let query = debug::delay(&client);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn set_delay(){
//   let client = Factom::new();
//   let query = debug::set_delay(&client, 10);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn summary(){
//   let client = Factom::new();
//   let query = debug::summary(&client);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Debug tests only work with a local factomd node
// #[test]
// fn messages(){
//   let client = Factom::new();
//   let query = debug::messages(&client);
//   let response = fetch(query).expect("Fetching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

// Entry Module
#[test]
fn entry(){
  let client = Factom::open_node();
  let query = entry::entry(&client, ENTRY_HASH);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  assert_eq!(response.result.chainid, CHAIN_ID);
}

#[test]
fn raw_data(){
  let client = Factom::open_node();
  let query = entry::raw_data(&client, RAW_DATA_HASH);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert_eq!(response.result.data, RAW_DATA);  
}

#[test]
fn pending_entries(){
  let client = Factom::open_node();
  let query = entry::pending_entries(&client);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());  
}

// factomd module
#[test]
fn current_minute(){
  let client = Factom::open_node();
  let query = factomd::current_minute(&client);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
}

#[test]
fn diagnostics(){
  let client = Factom::open_node();
  let query = factomd::diagnostics(&client);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
}

#[test]
fn entry_credit_rate(){
  let client = Factom::open_node();
  let query = factomd::entry_credit_rate(&client);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
}

#[test]
fn heights(){
  let client = Factom::open_node();
  let query = factomd::heights(&client);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
}

#[test]
fn properties(){
  let client = Factom::open_node();
  let query = factomd::properties(&client);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
}

#[test]
fn receipt(){
  let client = Factom::open_node();
  let query = factomd::receipt(&client, ENTRY_HASH, false);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
}

// generate module
#[test]
fn generate_factoid_address(){
  let client = Factom::new();
  let query = generate::factoid_address(&client);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
}

#[test]
fn generate_ec_address(){
  let client = Factom::new();
  let query = generate::ec_address(&client);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
}

#[test]
fn generate_identity_key(){
  let client = Factom::new();
  let query = generate::identity_key(&client);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
}

// identity module
#[test]
fn all_id_keys(){
  let client = Factom::new();
  let query = identity::all_id_keys(&client);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
}

// #[test]
// fn active_id_keys(){
//   let client = Factom::open_node();
//   let query = identity::active_id_keys(&client, ID_CHAIN, Some(ID_HEIGHT));
//   let response = fetch(query).expect("Fectching Query");
//   dbg!(&response);
//   assert!(response.success());
// }

#[test]
fn remove_id_key(){
  let client = Factom::new();
  let gen_query = generate::identity_key(&client);
  let response = fetch(gen_query).expect("Fectching Query");
  let key = response.result.public;
  let rm_query = identity::remove_id_key(&client, &key);
  let response = fetch(rm_query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.result.success)
}

#[test]
fn id_key(){
  let client = Factom::new();
  let gen_query = generate::identity_key(&client);
  let response = fetch(gen_query).expect("Fectching Query");
  let key = response.result.public;
  let key_query = identity::id_key(&client, &key);
  let response = fetch(key_query).expect("Fectching Query");
  dbg!(&response);
  let rm_query = identity::remove_id_key(&client, &key);
  fetch(rm_query).expect("Fectching Query");
  assert_eq!(response.result.public, key.clone());
}

// import module
#[test]
fn import_addresses(){
  let client = Factom::new();
  let query = import::import_addresses(&client, vec!(FCT_PRIV));
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
  let query = address::remove_address(&client, FCT_PUB);
  fetch(query).expect("Fectching Query");
}

#[test]
fn import_id_keys(){
  let client = Factom::new();
  let query = import::import_identity_keys(&client, vec!(ID_PRIV));
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
  let query = identity::remove_id_key(&client, ID_PUB);
  fetch(query).expect("Fectching Query");
}

#[test]
fn import_koinify(){
  let client = Factom::new();
  let query = import::import_koinify(&client, KOINIFY);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
  let query = address::remove_address(&client, KOINIFY_PUB);
  fetch(query).expect("Fectching Query");
}

// txmodule
#[test]
fn ack(){
  let client = Factom::open_node();
  let query = tx::ec_ack(&client, ACK_HASH, ACK_CHAIN, None);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert_eq!(response.result.committxid, ACK_COMMITTXID);
}

#[test]
fn transaction(){
  let client = Factom::open_node();
  let query = tx::transaction(&client, FCT_TX_ID);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert_eq!(response.result.factoidtransaction.millitimestamp, FCT_TX_TIMESTAMP);
}

#[test]
fn pending_transactions(){
  let client = Factom::open_node();
  let query = tx::pending_transactions(&client, None);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
}

#[test]
fn new_and_delete_transaction(){
  let client = Factom::new();
  let tx_name = "api-client-test-tx";
  let query = tx::new_transaction(&client, tx_name);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
  let query = tx::delete_transaction(&client, tx_name);
  let response = fetch(query).expect("Fectching Query");
  dbg!(&response);
  assert!(response.success());
}

// Walletd module
#[test]
fn wallet_backup() {
  let client = Factom::new();
  let query = walletd::wallet_backup(&client);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  assert!(response.success());
}

#[test]
fn wallet_height() {
  let client = Factom::new();
  let query = walletd::wallet_height(&client);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  assert!(response.success());
}

#[test]
fn wallet_properties() {
  let client = Factom::new();
  let query = walletd::wallet_properties(&client);
  let response = fetch(query).expect("Fetching Query");
  dbg!(&response);
  assert!(response.success());
}