forked from syscoin/syscoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_syscoin_services.cpp
More file actions
1126 lines (1044 loc) · 42.8 KB
/
test_syscoin_services.cpp
File metadata and controls
1126 lines (1044 loc) · 42.8 KB
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
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2016-2018 The Syscoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <test/test_syscoin_services.h>
#include <util/time.h>
#include <util/system.h>
#include <amount.h>
#include <rpc/server.h>
#include <services/asset.h>
#include <services/assetallocation.h>
#include <wallet/crypter.h>
#include <random.h>
#include <base58.h>
#include <chainparams.h>
#include <core_io.h>
#include <key_io.h>
#include <memory>
#include <string>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
#include <bech32.h>
#include <rpc/util.h>
#include <services/rpc/assetrpc.h>
static int node1LastBlock = 0;
static int node2LastBlock = 0;
static int node3LastBlock = 0;
static bool node1Online = false;
static bool node2Online = false;
static bool node3Online = false;
std::map<string, string> mapNodes;
// create a map between node alias names and URLs to be used in testing for example CallRPC("mynode", "getblockchaininfo") would call getblockchaininfo on the node alias mynode which would be pushed as a URL here.
// it is assumed RPC ports are open and u:p is the authentication
void InitNodeURLMap() {
mapNodes.clear();
mapNodes["node1"] = "http://127.0.0.1:28379";
mapNodes["node2"] = "http://127.0.0.1:38379";
mapNodes["node3"] = "http://127.0.0.1:48379";
}
// lookup the URL based on node passed in
string LookupURL(const string& node) {
if (mapNodes.find(node) != mapNodes.end())
return mapNodes[node];
return "";
}
// SYSCOIN testing setup
void StartNodes()
{
printf("Stopping any test nodes that are running...\n");
InitNodeURLMap();
StopNodes();
if (boost::filesystem::exists(boost::filesystem::system_complete("node1/regtest")))
boost::filesystem::remove_all(boost::filesystem::system_complete("node1/regtest"));
if (boost::filesystem::exists(boost::filesystem::system_complete("node2/regtest")))
boost::filesystem::remove_all(boost::filesystem::system_complete("node2/regtest"));
if (boost::filesystem::exists(boost::filesystem::system_complete("node3/regtest")))
boost::filesystem::remove_all(boost::filesystem::system_complete("node3/regtest"));
node1LastBlock = 0;
node2LastBlock = 0;
node3LastBlock = 0;
//StopMainNetNodes();
printf("Starting 3 nodes in a regtest setup...\n");
StartNode("node1");
BOOST_CHECK_NO_THROW(CallExtRPC("node1", "generate", "5"));
StartNode("node2");
StartNode("node3");
}
void StartMainNetNodes()
{
StopMainNetNodes();
printf("Starting 2 nodes in mainnet setup...\n");
StartNode("mainnet1", false);
SelectParams(CBaseChainParams::MAIN);
}
void StopMainNetNodes()
{
printf("Stopping mainnet1..\n");
StopNode("mainnet1", false);
printf("Done!\n");
}
void StopNodes()
{
StopNode("node1");
StopNode("node2");
StopNode("node3");
printf("Done!\n");
}
void StartNode(const string &dataDir, bool regTest, const string& extraArgs, bool reindex)
{
boost::filesystem::path fpath = boost::filesystem::system_complete("../syscoind");
string nodePath = fpath.string() + string(" -unittest -tpstest -assetindex -daemon -server -debug=0 -concurrentprocessing=1 -datadir=") + dataDir;
if (regTest)
nodePath += string(" -regtest");
if (reindex)
nodePath += string(" -reindex");
if (!extraArgs.empty())
nodePath += string(" ") + extraArgs;
boost::thread t(runCommand, nodePath);
printf("Launching %s, waiting 1 second before trying to ping...\n", nodePath.c_str());
MilliSleep(1000);
UniValue r;
while (1)
{
try {
printf("Calling getblockchaininfo!\n");
r = CallRPC(dataDir, "getblockchaininfo", regTest);
if (dataDir == "node1")
{
if (node1LastBlock > find_value(r.get_obj(), "blocks").get_int())
{
printf("Waiting for %s to catch up, current block number %d vs total blocks %d...\n", dataDir.c_str(), find_value(r.get_obj(), "blocks").get_int(), node1LastBlock);
MilliSleep(500);
continue;
}
node1Online = true;
node1LastBlock = 0;
}
else if (dataDir == "node2")
{
if (node2LastBlock > find_value(r.get_obj(), "blocks").get_int())
{
printf("Waiting for %s to catch up, current block number %d vs total blocks %d...\n", dataDir.c_str(), find_value(r.get_obj(), "blocks").get_int(), node2LastBlock);
MilliSleep(500);
continue;
}
node2Online = true;
node2LastBlock = 0;
}
else if (dataDir == "node3")
{
if (node3LastBlock > find_value(r.get_obj(), "blocks").get_int())
{
printf("Waiting for %s to catch up, current block number %d vs total blocks %d...\n", dataDir.c_str(), find_value(r.get_obj(), "blocks").get_int(), node3LastBlock);
MilliSleep(500);
continue;
}
node3Online = true;
node3LastBlock = 0;
}
MilliSleep(500);
}
catch (const runtime_error& error)
{
printf("Waiting for %s to come online, trying again in 1 second...\n", dataDir.c_str());
MilliSleep(1000);
continue;
}
break;
}
printf("Done!\n");
}
void StopNode(const string &dataDir, bool regtest) {
printf("Stopping %s..\n", dataDir.c_str());
UniValue r;
try {
r = CallRPC(dataDir, "getblockchaininfo", regtest);
if (r.isObject())
{
if (dataDir == "node1")
node1LastBlock = find_value(r.get_obj(), "blocks").get_int();
else if (dataDir == "node2")
node2LastBlock = find_value(r.get_obj(), "blocks").get_int();
else if (dataDir == "node3")
node3LastBlock = find_value(r.get_obj(), "blocks").get_int();
}
}
catch (const runtime_error& error)
{
}
try {
CallRPC(dataDir, "stop", regtest);
}
catch (const runtime_error& error)
{
}
while (1)
{
try {
MilliSleep(1000);
CallRPC(dataDir, "getblockchaininfo", regtest);
}
catch (const runtime_error& error)
{
break;
}
}
try {
if (dataDir == "node1")
node1Online = false;
else if (dataDir == "node2")
node2Online = false;
else if (dataDir == "node3")
node3Online = false;
}
catch (const runtime_error& error)
{
}
}
UniValue CallExtRPC(const string &node, const string& command, const string& args, bool readJson)
{
string url = LookupURL(node);
BOOST_CHECK(!url.empty());
UniValue val;
string curlcmd = "curl -s --user u:p --data-binary '{\"jsonrpc\":\"1.0\",\"id\":\"unittest\",\"method\":\"" + command + "\",\"params\":[" + args + "]}' -H 'content-type:text/plain;' " + url;
string rawJson = CallExternal(curlcmd);
val.read(rawJson);
if(!readJson)
return val;
if (val.isNull())
throw runtime_error("Could not parse rpc results");
// try to get error message if exist
UniValue errorValue = find_value(val.get_obj(), "error");
if (errorValue.isObject()) {
throw runtime_error(find_value(errorValue.get_obj(), "message").get_str());
}
return find_value(val.get_obj(), "result");
}
UniValue CallRPC(const string &dataDir, const string& commandWithArgs, bool regTest, bool readJson)
{
UniValue val;
boost::filesystem::path fpath = boost::filesystem::system_complete("../syscoin-cli");
string path = fpath.string() + string(" -datadir=") + dataDir;
if (regTest)
path += string(" -regtest ");
else
path += " ";
path += commandWithArgs;
string rawJson = CallExternal(path);
if (readJson)
{
val.read(rawJson);
if (val.isNull())
throw runtime_error("Could not parse rpc results");
}
else
val.setStr(rawJson);
return val;
}
int fsize(FILE *fp) {
int prev = ftell(fp);
fseek(fp, 0L, SEEK_END);
int sz = ftell(fp);
fseek(fp, prev, SEEK_SET); //go back to where we were
return sz;
}
void safe_fclose(FILE* file)
{
if (file)
BOOST_VERIFY(0 == fclose(file));
if (boost::filesystem::exists("cmdoutput.log"))
boost::filesystem::remove("cmdoutput.log");
}
int runSysCommand(const std::string& strCommand)
{
int nErr = ::system(strCommand.c_str());
return nErr;
}
std::string CallExternal(std::string &cmd)
{
cmd += " > cmdoutput.log || true";
if (runSysCommand(cmd))
return string("ERROR");
boost::shared_ptr<FILE> pipe(fopen("cmdoutput.log", "r"), safe_fclose);
if (!pipe) return "ERROR";
char buffer[128];
std::string result = "";
if (fsize(pipe.get()) > 0)
{
while (!feof(pipe.get())) {
if (fgets(buffer, 128, pipe.get()) != NULL)
result += buffer;
}
}
return result;
}
void GenerateMainNetBlocks(int nBlocks, const string& node)
{
int height, targetHeight, newHeight, timeoutCounter;
UniValue r;
BOOST_CHECK_NO_THROW(r = CallRPC(node, "getblockchaininfo", false));
targetHeight = find_value(r.get_obj(), "blocks").get_int() + nBlocks;
newHeight = 0;
const string &sBlocks = strprintf("%d", nBlocks);
string otherNode1, otherNode2;
GetOtherNodes(node, otherNode1, otherNode2);
while (newHeight < targetHeight)
{
BOOST_CHECK_NO_THROW(r = CallRPC(node, "generate " + sBlocks, false));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "getblockchaininfo", false));
newHeight = find_value(r.get_obj(), "blocks").get_int();
BOOST_CHECK_NO_THROW(r = CallRPC(node, "getwalletinfo", false));
CAmount balance = AmountFromValue(find_value(r.get_obj(), "balance"));
printf("Current block height %d, Target block height %d, balance %f\n", newHeight, targetHeight, ValueFromAmount(balance).get_real());
}
BOOST_CHECK(newHeight >= targetHeight);
height = 0;
timeoutCounter = 0;
MilliSleep(10);
while (!otherNode1.empty() && height < newHeight)
{
try
{
r = CallRPC(otherNode1, "getblockchaininfo", false);
}
catch (const runtime_error &e)
{
r = NullUniValue;
}
if (!r.isObject())
{
height = newHeight;
break;
}
height = find_value(r.get_obj(), "blocks").get_int();
timeoutCounter++;
if (timeoutCounter > 100) {
printf("Error: Timeout on getblockchaininfo for %s, height %d vs newHeight %d!\n", otherNode1.c_str(), height, newHeight);
break;
}
MilliSleep(10);
}
if (!otherNode1.empty())
BOOST_CHECK(height >= targetHeight);
}
// generate n Blocks, with up to 10 seconds relay time buffer for other nodes to get the blocks.
// may fail if your network is slow or you try to generate too many blocks such that can't relay within 10 seconds
void GenerateBlocks(int nBlocks, const string& node, bool bRegtest)
{
if(!bRegtest){
GenerateMainNetBlocks(nBlocks, node);
return;
}
int height, newHeight, timeoutCounter;
UniValue r;
string otherNode1, otherNode2;
GetOtherNodes(node, otherNode1, otherNode2);
try
{
r = CallRPC(node, "getblockchaininfo", bRegtest);
}
catch (const runtime_error &e)
{
return;
}
newHeight = find_value(r.get_obj(), "blocks").get_int() + nBlocks;
const string &sBlocks = strprintf("%d", nBlocks);
BOOST_CHECK_NO_THROW(r = CallRPC(node, "generate " + sBlocks, bRegtest));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "getblockchaininfo", bRegtest));
height = find_value(r.get_obj(), "blocks").get_int();
BOOST_CHECK(height >= newHeight);
height = 0;
timeoutCounter = 0;
MilliSleep(10);
while (!otherNode1.empty() && height < newHeight)
{
try
{
r = CallRPC(otherNode1, "getblockchaininfo", bRegtest);
}
catch (const runtime_error &e)
{
r = NullUniValue;
}
if (!r.isObject())
{
height = newHeight;
break;
}
height = find_value(r.get_obj(), "blocks").get_int();
timeoutCounter++;
if (timeoutCounter > 100) {
printf("Error: Timeout on getblockchaininfo for %s, height %d vs newHeight %d!\n", otherNode1.c_str(), height, newHeight);
break;
}
MilliSleep(10);
}
if (!otherNode1.empty())
BOOST_CHECK(height >= newHeight);
height = 0;
timeoutCounter = 0;
while (!otherNode2.empty() && height < newHeight)
{
try
{
r = CallRPC(otherNode2, "getblockchaininfo", bRegtest);
}
catch (const runtime_error &e)
{
r = NullUniValue;
}
if (!r.isObject())
{
height = newHeight;
break;
}
height = find_value(r.get_obj(), "blocks").get_int();
timeoutCounter++;
if (timeoutCounter > 100) {
printf("Error: Timeout on getblockchaininfo for %s, height %d vs newHeight %d!\n", otherNode2.c_str(), height, newHeight);
break;
}
MilliSleep(10);
}
if (!otherNode2.empty())
BOOST_CHECK(height >= newHeight);
height = 0;
timeoutCounter = 0;
}
void GenerateSpendableCoins() {
UniValue r;
const string &sBlocks = strprintf("%d", 101);
BOOST_CHECK_NO_THROW(r = CallExtRPC("node1", "generate", sBlocks));
BOOST_CHECK_NO_THROW(r = CallExtRPC("node1", "getnewaddress"));
string newaddress = r.get_str();
CallExtRPC("node1", "sendtoaddress", "\"" + newaddress + "\",\"100000\"", false);
GenerateBlocks(10, "node1");
BOOST_CHECK_NO_THROW(r = CallExtRPC("node2", "getnewaddress"));
newaddress = r.get_str();
CallExtRPC("node1", "sendtoaddress", "\"" + newaddress + "\",\"100000\"", false);
GenerateBlocks(10, "node1");
BOOST_CHECK_NO_THROW(r = CallExtRPC("node3", "getnewaddress"));
newaddress = r.get_str();
CallExtRPC("node1", "sendtoaddress", "\"" + newaddress + "\",\"100000\"", false);
GenerateBlocks(10, "node1");
}
string GetNewFundedAddress(const string &node, bool bRegtest) {
UniValue r;
BOOST_CHECK_NO_THROW(r = CallRPC(node, "getnewaddress", bRegtest, false));
string newaddress = r.get_str();
newaddress.erase(std::remove(newaddress.begin(), newaddress.end(), '\n'), newaddress.end());
string sendnode = "";
if (node == "node1")
sendnode = "node2";
else if (node == "node2")
sendnode = "node3";
else if (node == "node3")
sendnode = "node2";
else if(node == "mainnet1")
sendnode = "mainnet1";
CallRPC(bRegtest? sendnode: node, "sendtoaddress " + newaddress + " 10", bRegtest, false);
if(bRegtest)
GenerateBlocks(1, sendnode, bRegtest);
GenerateBlocks(1, node, bRegtest);
BOOST_CHECK_NO_THROW(r = CallRPC(node, "addressbalance " + newaddress, bRegtest));
CAmount nAmount = AmountFromValue(find_value(r.get_obj(), "amount"));
BOOST_CHECK_EQUAL(nAmount, 10*COIN);
return newaddress;
}
string GetNewFundedAddress(const string &node, string& txid) {
UniValue r;
BOOST_CHECK_NO_THROW(r = CallExtRPC(node, "getnewaddress"));
string newaddress = r.get_str();
string sendnode = "";
if (node == "node1")
sendnode = "node2";
else if (node == "node2")
sendnode = "node3";
else if (node == "node3")
sendnode = "node2";
r = CallExtRPC(sendnode, "sendtoaddress", "\"" + newaddress + "\",\"5\"");
r = CallExtRPC(sendnode, "sendtoaddress", "\"" + newaddress + "\",\"5\"");
r = CallExtRPC(sendnode, "sendtoaddress", "\"" + newaddress + "\",\"5\"");
r = CallExtRPC(sendnode, "sendtoaddress", "\"" + newaddress + "\",\"5\"");
r = CallExtRPC(sendnode, "sendtoaddress", "\"" + newaddress + "\",\"5\"");
txid = r.get_str();
GenerateBlocks(10, sendnode);
GenerateBlocks(10, node);
BOOST_CHECK_NO_THROW(r = CallRPC(node, "addressbalance " + newaddress));
CAmount nAmount = AmountFromValue(find_value(r.get_obj(), "amount"));
BOOST_CHECK_EQUAL(nAmount, 25*COIN);
return newaddress;
}
void SleepFor(const int& milliseconds, bool actualSleep) {
if (actualSleep)
MilliSleep(milliseconds);
float seconds = milliseconds / 1000;
BOOST_CHECK(seconds > 0);
UniValue r;
try
{
r = CallExtRPC("node1", "getblockchaininfo");
int64_t currentTime = find_value(r.get_obj(), "mediantime").get_int64();
currentTime += seconds;
SetSysMocktime(currentTime);
}
catch (const runtime_error &e)
{
}
try
{
r = CallExtRPC("node2", "getblockchaininfo");
int64_t currentTime = find_value(r.get_obj(), "mediantime").get_int64();
currentTime += seconds;
SetSysMocktime(currentTime);
}
catch (const runtime_error &e)
{
}
try
{
r = CallExtRPC("node3", "getblockchaininfo");
int64_t currentTime = find_value(r.get_obj(), "mediantime").get_int64();
currentTime += seconds;
SetSysMocktime(currentTime);
}
catch (const runtime_error &e)
{
}
}
void SetSysMocktime(const int64_t& expiryTime) {
BOOST_CHECK(expiryTime > 0);
string expiryStr = strprintf("%lld", expiryTime);
try
{
CallExtRPC("node1", "getblockchaininfo");
BOOST_CHECK_NO_THROW(CallExtRPC("node1", "setmocktime", "\"" + expiryStr + "\""));
GenerateBlocks(5, "node1");
GenerateBlocks(5, "node1");
GenerateBlocks(5, "node1");
UniValue r;
BOOST_CHECK_NO_THROW(r = CallExtRPC("node1", "getblockchaininfo"));
BOOST_CHECK(expiryTime <= find_value(r.get_obj(), "mediantime").get_int64());
}
catch (const runtime_error &e)
{
}
try
{
CallExtRPC("node2", "getblockchaininfo");
BOOST_CHECK_NO_THROW(CallExtRPC("node2", "setmocktime", "\"" + expiryStr + "\""));
GenerateBlocks(5, "node2");
GenerateBlocks(5, "node2");
GenerateBlocks(5, "node2");
UniValue r;
BOOST_CHECK_NO_THROW(r = CallExtRPC("node2", "getblockchaininfo"));
BOOST_CHECK(expiryTime <= find_value(r.get_obj(), "mediantime").get_int64());
}
catch (const runtime_error &e)
{
}
try
{
CallExtRPC("node3", "getblockchaininfo");
BOOST_CHECK_NO_THROW(CallExtRPC("node3", "setmocktime", "\"" + expiryStr + "\""));
GenerateBlocks(5, "node3");
GenerateBlocks(5, "node3");
GenerateBlocks(5, "node3");
UniValue r;
BOOST_CHECK_NO_THROW(r = CallExtRPC("node3", "getblockchaininfo"));
BOOST_CHECK(expiryTime <= find_value(r.get_obj(), "mediantime").get_int64());
}
catch (const runtime_error &e)
{
}
}
void GetOtherNodes(const string& node, string& otherNode1, string& otherNode2)
{
otherNode1 = "";
otherNode2 = "";
if (node == "node1")
{
if (node2Online)
otherNode1 = "node2";
if (node3Online)
otherNode2 = "node3";
}
else if (node == "node2")
{
if (node1Online)
otherNode1 = "node1";
if (node3Online)
otherNode2 = "node3";
}
else if (node == "node3")
{
if (node1Online)
otherNode1 = "node1";
if (node2Online)
otherNode2 = "node2";
}
}
string SyscoinMint(const string& node, const string& address, const string& amount, int height, const string& tx_hex, const string& txroot_hex, const string& txmerkleproof_hex, const string& txmerkleproofpath_hex, const string& receipt_hex, const string& receiptroot_hex, const string& receiptmerkleproof_hex, const string& witness)
{
string otherNode1, otherNode2;
GetOtherNodes(node, otherNode1, otherNode2);
UniValue r;
BOOST_CHECK_NO_THROW(r = CallRPC(node, "addressbalance " + address));
CAmount nAmountBefore = AmountFromValue(find_value(r.get_obj(), "amount"));
// ensure that block number you claim the burn is at least 1 hour old
int heightPlus240 = height+(ETHEREUM_CONFIRMS_REQUIRED*1.5);
string headerStr = "\"[[" + itostr(height) + ", \\\"" + itostr(height) + "\\\", \\\"" + itostr(height-1) + "\\\", \\\"" + txroot_hex + "\\\", \\\"" + receiptroot_hex + "\\\"]]\"";
BOOST_CHECK_NO_THROW(r = CallRPC(node, "syscoinsetethheaders " + headerStr));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "syscoinsetethstatus synced " + itostr(heightPlus240)));
if (!otherNode1.empty())
{
BOOST_CHECK_NO_THROW(r = CallRPC(otherNode1, "syscoinsetethheaders " + headerStr));
BOOST_CHECK_NO_THROW(r = CallRPC(otherNode1, "syscoinsetethstatus synced " + itostr(heightPlus240)));
}
if (!otherNode2.empty())
{
BOOST_CHECK_NO_THROW(r = CallRPC(otherNode2, "syscoinsetethheaders " + headerStr));
BOOST_CHECK_NO_THROW(r = CallRPC(otherNode2, "syscoinsetethstatus synced " + itostr(heightPlus240)));
}
// "syscoinmint [address] [amount] [blocknumber] [tx_hex] [txroot_hex] [txmerkleproof_hex] [txmerkleroofpath_hex] [receipt_hex] [receiptroot_hex] [receiptmerkleproof_hex] [witness]\n"
BOOST_CHECK_NO_THROW(r = CallRPC(node, "syscoinmint " + address + " " + amount + " " + itostr(height) + " " + tx_hex + " a0" + txroot_hex + " " + txmerkleproof_hex + " " + txmerkleproofpath_hex + " " + receipt_hex + " a0" + receiptroot_hex + " " + receiptmerkleproof_hex + " " + witness));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "signrawtransactionwithwallet " + find_value(r.get_obj(), "hex").get_str()));
string hex_str = find_value(r.get_obj(), "hex").get_str();
BOOST_CHECK_NO_THROW(r = CallRPC(node, "sendrawtransaction " + hex_str, true, false));
GenerateBlocks(5, node);
BOOST_CHECK_NO_THROW(r = CallRPC(node, "addressbalance " + address));
CAmount nAmountAfter = AmountFromValue(find_value(r.get_obj(), "amount"));
// account for fees
BOOST_CHECK(abs((nAmountBefore+AmountFromValue(amount)) - nAmountAfter) < 0.1*COIN);
return hex_str;
}
bool FindAssetGUIDFromAssetIndexResults(const UniValue& results, std::string guid){
UniValue arrayVal = results.get_array();
for(unsigned i = 0;i<arrayVal.size();i++){
UniValue r = arrayVal[i];
if(itostr(find_value(r.get_obj(), "asset_guid").get_int()) == guid)
return true;
}
return false;
}
string AssetNew(const string& node, const string& address, string pubdata, string contract, const string& precision, const string& supply, const string& maxsupply, const string& updateflags, const string& witness, const string& symbol, bool bRegtest)
{
string otherNode1, otherNode2;
GetOtherNodes(node, otherNode1, otherNode2);
UniValue r;
// "assetnew [address] [symbol] [public value] [contract] [precision=8] [supply] [max_supply] [update_flags] [witness]\n"
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetnew " + address + " " + symbol + " ""\"" + pubdata + "\" " + contract + " " + precision + " " + supply + " " + maxsupply + " " + updateflags + " " + witness, bRegtest));
if(contract == "''")
contract.clear();
if(pubdata == "''")
pubdata.clear();
string guid = itostr(find_value(r.get_obj(), "asset_guid").get_int());
BOOST_CHECK_NO_THROW(r = CallRPC(node, "signrawtransactionwithwallet " + find_value(r.get_obj(), "hex").get_str(), bRegtest));
string hex_str = find_value(r.get_obj(), "hex").get_str();
BOOST_CHECK_NO_THROW(r = CallRPC(node, "sendrawtransaction " + hex_str, bRegtest, false));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "decoderawtransaction " + hex_str + " true", bRegtest));
GenerateBlocks(1, node, bRegtest);
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetinfo " + guid, bRegtest ));
int nprecision;
ParseInt32(precision, &nprecision);
BOOST_CHECK(itostr(find_value(r.get_obj(), "asset_guid").get_int()) == guid);
BOOST_CHECK(find_value(r.get_obj(), "address").get_str() == address);
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "public_value").get_str() , pubdata);
UniValue balance = find_value(r.get_obj(), "balance");
UniValue totalsupply = find_value(r.get_obj(), "total_supply");
UniValue maxsupplyu = find_value(r.get_obj(), "max_supply");
UniValue supplytmp(UniValue::VSTR);
supplytmp.setStr(supply);
UniValue maxsupplytmp(UniValue::VSTR);
maxsupplytmp.setStr(maxsupply);
BOOST_CHECK(AssetAmountFromValue(balance, nprecision) == AssetAmountFromValue(supplytmp, nprecision));
BOOST_CHECK(AssetAmountFromValue(totalsupply, nprecision) == AssetAmountFromValue(supplytmp, nprecision));
BOOST_CHECK_EQUAL(AssetAmountFromValue(maxsupplyu, nprecision), AssetAmountFromValue(maxsupplytmp, nprecision));
int update_flags = find_value(r.get_obj(), "update_flags").get_int();
int paramUpdateFlags;
ParseInt32(updateflags, ¶mUpdateFlags);
BOOST_CHECK(update_flags == paramUpdateFlags);
BOOST_CHECK_NO_THROW(r = CallRPC(node, "listassetindexassets " + address , bRegtest));
BOOST_CHECK(FindAssetGUIDFromAssetIndexResults(r, guid));
GenerateBlocks(1, node, bRegtest);
if (!otherNode1.empty())
{
BOOST_CHECK_NO_THROW(r = CallRPC(otherNode1, "assetinfo " + guid , bRegtest));
BOOST_CHECK(itostr(find_value(r.get_obj(), "asset_guid").get_int()) == guid);
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "public_value").get_str() , pubdata);
UniValue balance = find_value(r.get_obj(), "balance");
UniValue totalsupply = find_value(r.get_obj(), "total_supply");
UniValue maxsupplyu = find_value(r.get_obj(), "max_supply");
BOOST_CHECK(AssetAmountFromValue(balance, nprecision) == AssetAmountFromValue(supplytmp, nprecision));
BOOST_CHECK(AssetAmountFromValue(totalsupply, nprecision) == AssetAmountFromValue(supplytmp, nprecision));
BOOST_CHECK_EQUAL(AssetAmountFromValue(maxsupplyu, nprecision), AssetAmountFromValue(maxsupplytmp, nprecision));
int update_flags = find_value(r.get_obj(), "update_flags").get_int();
int paramUpdateFlags;
ParseInt32(updateflags, ¶mUpdateFlags);
BOOST_CHECK(update_flags == paramUpdateFlags);
BOOST_CHECK_NO_THROW(r = CallRPC(otherNode1, "listassetindexassets " + address , bRegtest));
BOOST_CHECK(FindAssetGUIDFromAssetIndexResults(r, guid));
}
if (!otherNode2.empty())
{
BOOST_CHECK_NO_THROW(r = CallRPC(otherNode2, "assetinfo " + guid, bRegtest));
BOOST_CHECK(itostr(find_value(r.get_obj(), "asset_guid").get_int()) == guid);
BOOST_CHECK(find_value(r.get_obj(), "public_value").get_str() == pubdata);
UniValue balance = find_value(r.get_obj(), "balance");
UniValue totalsupply = find_value(r.get_obj(), "total_supply");
UniValue maxsupplyu = find_value(r.get_obj(), "max_supply");
BOOST_CHECK(AssetAmountFromValue(balance, nprecision) == AssetAmountFromValue(supplytmp, nprecision));
BOOST_CHECK(AssetAmountFromValue(totalsupply, nprecision) == AssetAmountFromValue(supplytmp, nprecision));
BOOST_CHECK_EQUAL(AssetAmountFromValue(maxsupplyu, nprecision), AssetAmountFromValue(maxsupplytmp, nprecision));
int update_flags = find_value(r.get_obj(), "update_flags").get_int();
int paramUpdateFlags;
ParseInt32(updateflags, ¶mUpdateFlags);
BOOST_CHECK(update_flags == paramUpdateFlags);
BOOST_CHECK_NO_THROW(r = CallRPC(otherNode2, "listassetindexassets " + address , bRegtest));
BOOST_CHECK(FindAssetGUIDFromAssetIndexResults(r, guid));
}
return guid;
}
void AssetUpdate(const string& node, const string& guid, const string& pubdata, const string& supply, const string& updateflags, const string& witness)
{
string otherNode1, otherNode2;
GetOtherNodes(node, otherNode1, otherNode2);
UniValue r;
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetinfo " + guid));
string oldaddress = find_value(r.get_obj(), "address").get_str();
string oldpubdata = find_value(r.get_obj(), "public_value").get_str();
UniValue totalsupply = find_value(r.get_obj(), "total_supply");
int nprecision = find_value(r.get_obj(), "precision").get_int();
CAmount oldsupplyamount = AssetAmountFromValue(totalsupply, nprecision);
int oldflags = find_value(r.get_obj(), "update_flags").get_int();
CAmount supplyamount = 0;
if (supply != "''") {
UniValue supplytmp(UniValue::VSTR);
supplytmp.setStr(supply);
supplyamount = AssetAmountFromValue(supplytmp, nprecision);
}
CAmount newamount = oldsupplyamount + supplyamount;
string newpubdata = pubdata == "''" ? oldpubdata : pubdata;
string newsupply = supply == "''" ? "0" : supply;
int flagsi;
ParseInt32(updateflags, &flagsi);
int newflags = updateflags == "''" ? oldflags : flagsi;
string newflagsstr = itostr(newflags);
// "assetupdate [asset] [public] [contract] [supply] [update_flags] [witness]\n"
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetupdate " + guid + " " + newpubdata + " '' " + newsupply + " " + newflagsstr + " " + witness));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "signrawtransactionwithwallet " + find_value(r.get_obj(), "hex").get_str()));
string hex_str = find_value(r.get_obj(), "hex").get_str();
BOOST_CHECK_NO_THROW(r = CallRPC(node, "sendrawtransaction " + hex_str, true, false));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "syscoindecoderawtransaction " + hex_str));
UniValue flagValue = find_value(r.get_obj(), "update_flags");
if (newflags != oldflags && newflags != 0) {
BOOST_CHECK_EQUAL(flagValue.get_int(), newflags);
}
else {
BOOST_CHECK(flagValue.isNull());
}
// ensure sender state not changed before generating blocks
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetinfo " + guid));
BOOST_CHECK(itostr(find_value(r.get_obj(), "asset_guid").get_int()) == guid);
BOOST_CHECK(find_value(r.get_obj(), "address").get_str() == oldaddress);
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "public_value").get_str(), oldpubdata);
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "update_flags").get_int(), oldflags);
totalsupply = find_value(r.get_obj(), "total_supply");
BOOST_CHECK(AssetAmountFromValue(totalsupply, nprecision) == oldsupplyamount);
GenerateBlocks(5, node);
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetinfo " + guid));
BOOST_CHECK(itostr(find_value(r.get_obj(), "asset_guid").get_int()) == guid);
BOOST_CHECK(find_value(r.get_obj(), "address").get_str() == oldaddress);
totalsupply = find_value(r.get_obj(), "total_supply");
BOOST_CHECK(AssetAmountFromValue(totalsupply, nprecision) == newamount);
BOOST_CHECK_NO_THROW(r = CallRPC(node, "listassetindexassets " + oldaddress ));
BOOST_CHECK(FindAssetGUIDFromAssetIndexResults(r, guid));
GenerateBlocks(6, node);
if (!otherNode1.empty())
{
BOOST_CHECK_NO_THROW(r = CallRPC(otherNode1, "assetinfo " + guid ));
BOOST_CHECK(itostr(find_value(r.get_obj(), "asset_guid").get_int()) == guid);
BOOST_CHECK(find_value(r.get_obj(), "address").get_str() == oldaddress);
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "public_value").get_str(), newpubdata);
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "update_flags").get_int(), newflags);
totalsupply = find_value(r.get_obj(), "total_supply");
BOOST_CHECK(AssetAmountFromValue(totalsupply, nprecision) == newamount);
BOOST_CHECK_NO_THROW(r = CallRPC(otherNode1, "listassetindexassets " + oldaddress ));
BOOST_CHECK(FindAssetGUIDFromAssetIndexResults(r, guid));
}
if (!otherNode2.empty())
{
BOOST_CHECK_NO_THROW(r = CallRPC(otherNode2, "assetinfo " + guid));
BOOST_CHECK(itostr(find_value(r.get_obj(), "asset_guid").get_int()) == guid);
BOOST_CHECK(find_value(r.get_obj(), "address").get_str() == oldaddress);
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "public_value").get_str(), newpubdata);
totalsupply = find_value(r.get_obj(), "total_supply");
BOOST_CHECK(AssetAmountFromValue(totalsupply, nprecision) == newamount);
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "update_flags").get_int(), newflags);
BOOST_CHECK_NO_THROW(r = CallRPC(otherNode2, "listassetindexassets " + oldaddress ));
BOOST_CHECK(FindAssetGUIDFromAssetIndexResults(r, guid));
}
}
void AssetTransfer(const string& node, const string &tonode, const string& guid, const string& toaddress, const string& witness, bool bRegtest)
{
UniValue r;
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetinfo " + guid , bRegtest));
string oldaddress = find_value(r.get_obj(), "address").get_str();
// "assettransfer [asset] [address] [witness]\n"
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assettransfer " + guid + " " + toaddress + " " + witness, bRegtest));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "signrawtransactionwithwallet " + find_value(r.get_obj(), "hex").get_str(), bRegtest));
string hex_str = find_value(r.get_obj(), "hex").get_str();
BOOST_CHECK_NO_THROW(r = CallRPC(node, "sendrawtransaction " + hex_str, bRegtest, false));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "decoderawtransaction " + hex_str + " true", bRegtest));
GenerateBlocks(1, node, bRegtest);
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetinfo " + guid, bRegtest));
BOOST_CHECK(itostr(find_value(r.get_obj(), "asset_guid").get_int()) == guid);
if(bRegtest){
BOOST_CHECK_NO_THROW(r = CallRPC(tonode, "assetinfo " + guid, bRegtest));
BOOST_CHECK(find_value(r.get_obj(), "address").get_str() == toaddress);
}
BOOST_CHECK_NO_THROW(r = CallRPC(node, "listassetindexassets " + toaddress , bRegtest));
BOOST_CHECK(FindAssetGUIDFromAssetIndexResults(r, guid));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "listassetindexassets " + oldaddress , bRegtest));
BOOST_CHECK(!FindAssetGUIDFromAssetIndexResults(r, guid));
}
string AssetAllocationTransfer(const bool usezdag, const string& node, const string& guid, const string& fromaddress, const string& inputs, const string& witness) {
UniValue r;
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetinfo " + guid));
int nprecision = find_value(r.get_obj(), "precision").get_int();
CAssetAllocation theAssetAllocation;
UniValue valueTo;
string inputsTmp = inputs;
boost::replace_all(inputsTmp, "\\\"", "\"");
boost::replace_all(inputsTmp, "\"[", "[");
boost::replace_all(inputsTmp, "]\"", "]");
BOOST_CHECK(valueTo.read(inputsTmp));
BOOST_CHECK(valueTo.isArray());
UniValue receivers = valueTo.get_array();
CAmount inputamount = 0;
BOOST_CHECK(receivers.size() > 0);
for (unsigned int idx = 0; idx < receivers.size(); idx++) {
const UniValue& receiver = receivers[idx];
BOOST_CHECK(receiver.isObject());
UniValue receiverObj = receiver.get_obj();
const CTxDestination &dest = DecodeDestination(find_value(receiverObj, "address").get_str());
UniValue detail = DescribeAddress(dest);
string witnessProgramHex = find_value(detail.get_obj(), "witness_program").get_str();
unsigned char witnessVersion = (unsigned char)find_value(detail.get_obj(), "witness_version").get_int();
UniValue amountObj = find_value(receiverObj, "amount");
if (amountObj.isNum()) {
const CAmount &amount = AssetAmountFromValue(amountObj, nprecision);
inputamount += amount;
BOOST_CHECK(amount > 0);
theAssetAllocation.listSendingAllocationAmounts.push_back(make_pair(CWitnessAddress(witnessVersion, ParseHex(witnessProgramHex)), amount));
}
}
string otherNode1, otherNode2;
GetOtherNodes(node, otherNode1, otherNode2);
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetallocationinfo " + guid + " " + fromaddress));
UniValue balance;
if(usezdag)
balance = find_value(r.get_obj(), "balance_zdag");
else
balance = find_value(r.get_obj(), "balance");
CAmount newfromamount;
try{
newfromamount = AssetAmountFromValue(balance, nprecision) - inputamount;
}
catch(...){
newfromamount = 0;
}
// "assetallocationsendmany [asset] [addressfrom] ( [{\"address\":\"address\",\"amount\":amount},...] [witness]\n"
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetallocationsendmany " + guid + " " + fromaddress + " " + inputs + " " + witness));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "signrawtransactionwithwallet " + find_value(r.get_obj(), "hex").get_str()));
string hex_str = find_value(r.get_obj(), "hex").get_str();
BOOST_CHECK_NO_THROW(r = CallRPC(node, "sendrawtransaction " + hex_str, true, false));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "syscoindecoderawtransaction " + hex_str));
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "txtype").get_str(), "assetallocationsend");
if (!theAssetAllocation.listSendingAllocationAmounts.empty())
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "allocations").get_array().size(), theAssetAllocation.listSendingAllocationAmounts.size());
BOOST_CHECK_NO_THROW(r = CallRPC(node, "decoderawtransaction " + hex_str + " true"));
string txid = find_value(r.get_obj(), "txid").get_str();
if (usezdag) {
MilliSleep(100);
}
else
GenerateBlocks(1, node);
if (newfromamount > 0 || usezdag)
{
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetallocationinfo " + guid + " " + fromaddress));
if(usezdag)
balance = find_value(r.get_obj(), "balance_zdag");
else
balance = find_value(r.get_obj(), "balance");
if(newfromamount <= 0)
BOOST_CHECK_EQUAL(0, newfromamount);
else
BOOST_CHECK_EQUAL(AssetAmountFromValue(balance, nprecision), newfromamount);
}
else if(!usezdag){
BOOST_CHECK_THROW(r = CallRPC(node, "assetallocationinfo " + guid + " " + fromaddress), runtime_error);
for (unsigned int idx = 0; idx < receivers.size(); idx++) {
const UniValue& receiver = receivers[idx];
BOOST_CHECK(receiver.isObject());
UniValue receiverObj = receiver.get_obj();
string strAddress = find_value(receiverObj, "address").get_str();
BOOST_CHECK_NO_THROW(r = CallRPC(node, "listassetindexallocations " + strAddress ));
BOOST_CHECK(FindAssetGUIDFromAssetIndexResults(r, guid));
}
if(newfromamount > 0){
BOOST_CHECK_NO_THROW(r = CallRPC(node, "listassetindexallocations " + fromaddress ));
BOOST_CHECK(FindAssetGUIDFromAssetIndexResults(r, guid));
}
}
return txid;
}
void BurnAssetAllocation(const string& node, const string &guid, const string &address,const string &amount, bool confirm){
UniValue r;
try{
r = CallRPC(node, "assetallocationinfo " + guid + " burn");
}
catch(runtime_error&err){
}
CAmount beforeBalance = 0;
if(r.isObject()){
UniValue balanceB = find_value(r.get_obj(), "balance");
beforeBalance = AssetAmountFromValue(balanceB, 8);
}
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetallocationburn " + guid + " " + address + " " + amount + " 0x931D387731bBbC988B312206c74F77D004D6B84b"));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "signrawtransactionwithwallet " + find_value(r.get_obj(), "hex").get_str()));
string hexStr = find_value(r.get_obj(), "hex").get_str();
BOOST_CHECK_NO_THROW(r = CallRPC(node, "sendrawtransaction " + hexStr, true, false));
if(confirm){
GenerateBlocks(5, "node1");
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetallocationinfo " + guid + " burn"));
UniValue balance = find_value(r.get_obj(), "balance");
BOOST_CHECK_EQUAL(AssetAmountFromValue(balance, 8), beforeBalance+(0.5 * COIN));
}
}
void LockAssetAllocation(const string& node, const string &guid, const string &address,const string &txid, const string &index){
UniValue r;
string outpointStr = txid+"-"+index;
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetallocationlock " + guid + " " + address + " " + txid + " " + index + " ''"));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "signrawtransactionwithwallet " + find_value(r.get_obj(), "hex").get_str()));
string hexStr = find_value(r.get_obj(), "hex").get_str();
BOOST_CHECK_NO_THROW(r = CallRPC(node, "sendrawtransaction " + hexStr, true, false));
BOOST_CHECK_NO_THROW(r = CallRPC(node, "syscoindecoderawtransaction " + hexStr));
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "txtype").get_str(), "assetallocationlock");
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "locked_outpoint").get_str() , outpointStr);
GenerateBlocks(5, "node1");
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetallocationinfo " + guid + " " + address));
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "locked_outpoint").get_str() , outpointStr);
}
string AssetSend(const string& node, const string& guid, const string& inputs, const string& witness, bool completetx, bool bRegtest)
{
UniValue r;
BOOST_CHECK_NO_THROW(r = CallRPC(node, "assetinfo " + guid, bRegtest));