@@ -481,9 +481,14 @@ func TestServiceGetTx(t *testing.T) {
481
481
482
482
reply := api.GetTxReply {}
483
483
require .NoError (env .service .GetTx (nil , & api.GetTxArgs {
484
- TxID : txID ,
484
+ TxID : txID ,
485
+ Encoding : formatting .Hex ,
485
486
}, & reply ))
486
- txBytes , err := formatting .Decode (reply .Encoding , reply .Tx .(string ))
487
+
488
+ var txStr string
489
+ require .NoError (stdjson .Unmarshal (reply .Tx , & txStr ))
490
+
491
+ txBytes , err := formatting .Decode (reply .Encoding , txStr )
487
492
require .NoError (err )
488
493
require .Equal (env .genesisTx .Bytes (), txBytes )
489
494
}
@@ -507,9 +512,7 @@ func TestServiceGetTxJSON_BaseTx(t *testing.T) {
507
512
}, & reply ))
508
513
509
514
require .Equal (reply .Encoding , formatting .JSON )
510
- jsonTxBytes , err := stdjson .Marshal (reply .Tx )
511
- require .NoError (err )
512
- jsonString := string (jsonTxBytes )
515
+ jsonString := string (reply .Tx )
513
516
require .Contains (jsonString , `"memo":"0x0102030405060708"` )
514
517
require .Contains (jsonString , `"inputs":[{"txID":"2XGxUr7VF7j1iwUp2aiGe4b6Ue2yyNghNS1SuNTNmZ77dPpXFZ","outputIndex":2,"assetID":"2XGxUr7VF7j1iwUp2aiGe4b6Ue2yyNghNS1SuNTNmZ77dPpXFZ","fxID":"spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ","input":{"amount":50000,"signatureIndices":[0]}}]` )
515
518
require .Contains (jsonString , `"outputs":[{"assetID":"2XGxUr7VF7j1iwUp2aiGe4b6Ue2yyNghNS1SuNTNmZ77dPpXFZ","fxID":"spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ","output":{"addresses":["X-testing1lnk637g0edwnqc2tn8tel39652fswa3xk4r65e"],"amount":49000,"locktime":0,"threshold":1}}]` )
@@ -534,9 +537,7 @@ func TestServiceGetTxJSON_ExportTx(t *testing.T) {
534
537
}, & reply ))
535
538
536
539
require .Equal (reply .Encoding , formatting .JSON )
537
- jsonTxBytes , err := stdjson .Marshal (reply .Tx )
538
- require .NoError (err )
539
- jsonString := string (jsonTxBytes )
540
+ jsonString := string (reply .Tx )
540
541
require .Contains (jsonString , `"inputs":[{"txID":"2XGxUr7VF7j1iwUp2aiGe4b6Ue2yyNghNS1SuNTNmZ77dPpXFZ","outputIndex":2,"assetID":"2XGxUr7VF7j1iwUp2aiGe4b6Ue2yyNghNS1SuNTNmZ77dPpXFZ","fxID":"spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ","input":{"amount":50000,"signatureIndices":[0]}}]` )
541
542
require .Contains (jsonString , `"exportedOutputs":[{"assetID":"2XGxUr7VF7j1iwUp2aiGe4b6Ue2yyNghNS1SuNTNmZ77dPpXFZ","fxID":"spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ","output":{"addresses":["X-testing1lnk637g0edwnqc2tn8tel39652fswa3xk4r65e"],"amount":49000,"locktime":0,"threshold":1}}]}` )
542
543
}
@@ -566,9 +567,7 @@ func TestServiceGetTxJSON_CreateAssetTx(t *testing.T) {
566
567
}, & reply ))
567
568
568
569
require .Equal (reply .Encoding , formatting .JSON )
569
- jsonTxBytes , err := stdjson .Marshal (reply .Tx )
570
- require .NoError (err )
571
- jsonString := string (jsonTxBytes )
570
+ jsonString := string (reply .Tx )
572
571
573
572
// contains the address in the right format
574
573
require .Contains (jsonString , `"outputs":[{"addresses":["X-testing1lnk637g0edwnqc2tn8tel39652fswa3xk4r65e"],"groupID":1,"locktime":0,"threshold":1},{"addresses":["X-testing1lnk637g0edwnqc2tn8tel39652fswa3xk4r65e"],"groupID":2,"locktime":0,"threshold":1}]}` )
@@ -605,9 +604,7 @@ func TestServiceGetTxJSON_OperationTxWithNftxMintOp(t *testing.T) {
605
604
}, & reply ))
606
605
607
606
require .Equal (reply .Encoding , formatting .JSON )
608
- jsonTxBytes , err := stdjson .Marshal (reply .Tx )
609
- require .NoError (err )
610
- jsonString := string (jsonTxBytes )
607
+ jsonString := string (reply .Tx )
611
608
// assert memo and payload are in hex
612
609
require .Contains (jsonString , `"memo":"0x"` )
613
610
require .Contains (jsonString , `"payload":"0x68656c6c6f"` )
@@ -651,9 +648,7 @@ func TestServiceGetTxJSON_OperationTxWithMultipleNftxMintOp(t *testing.T) {
651
648
}, & reply ))
652
649
653
650
require .Equal (reply .Encoding , formatting .JSON )
654
- jsonTxBytes , err := stdjson .Marshal (reply .Tx )
655
- require .NoError (err )
656
- jsonString := string (jsonTxBytes )
651
+ jsonString := string (reply .Tx )
657
652
658
653
// contains the address in the right format
659
654
require .Contains (jsonString , `"outputs":[{"addresses":["X-testing1lnk637g0edwnqc2tn8tel39652fswa3xk4r65e"]` )
@@ -693,9 +688,7 @@ func TestServiceGetTxJSON_OperationTxWithSecpMintOp(t *testing.T) {
693
688
}, & reply ))
694
689
695
690
require .Equal (reply .Encoding , formatting .JSON )
696
- jsonTxBytes , err := stdjson .Marshal (reply .Tx )
697
- require .NoError (err )
698
- jsonString := string (jsonTxBytes )
691
+ jsonString := string (reply .Tx )
699
692
700
693
// ensure memo is in hex
701
694
require .Contains (jsonString , `"memo":"0x"` )
@@ -741,9 +734,7 @@ func TestServiceGetTxJSON_OperationTxWithMultipleSecpMintOp(t *testing.T) {
741
734
}, & reply ))
742
735
743
736
require .Equal (reply .Encoding , formatting .JSON )
744
- jsonTxBytes , err := stdjson .Marshal (reply .Tx )
745
- require .NoError (err )
746
- jsonString := string (jsonTxBytes )
737
+ jsonString := string (reply .Tx )
747
738
748
739
// contains the address in the right format
749
740
require .Contains (jsonString , `"mintOutput":{"addresses":["X-testing1lnk637g0edwnqc2tn8tel39652fswa3xk4r65e"]` )
@@ -784,9 +775,7 @@ func TestServiceGetTxJSON_OperationTxWithPropertyFxMintOp(t *testing.T) {
784
775
}, & reply ))
785
776
786
777
require .Equal (reply .Encoding , formatting .JSON )
787
- jsonTxBytes , err := stdjson .Marshal (reply .Tx )
788
- require .NoError (err )
789
- jsonString := string (jsonTxBytes )
778
+ jsonString := string (reply .Tx )
790
779
791
780
// ensure memo is in hex
792
781
require .Contains (jsonString , `"memo":"0x"` )
@@ -831,9 +820,7 @@ func TestServiceGetTxJSON_OperationTxWithPropertyFxMintOpMultiple(t *testing.T)
831
820
}, & reply ))
832
821
833
822
require .Equal (reply .Encoding , formatting .JSON )
834
- jsonTxBytes , err := stdjson .Marshal (reply .Tx )
835
- require .NoError (err )
836
- jsonString := string (jsonTxBytes )
823
+ jsonString := string (reply .Tx )
837
824
838
825
// contains the address in the right format
839
826
require .Contains (jsonString , `"mintOutput":{"addresses":["X-testing1lnk637g0edwnqc2tn8tel39652fswa3xk4r65e"]` )
@@ -2111,7 +2098,11 @@ func TestServiceGetBlock(t *testing.T) {
2111
2098
return
2112
2099
}
2113
2100
require .Equal (tt .encoding , reply .Encoding )
2114
- require .Equal (expected , reply .Block )
2101
+
2102
+ expectedJSON , err := stdjson .Marshal (expected )
2103
+ require .NoError (err )
2104
+
2105
+ require .Equal (stdjson .RawMessage (expectedJSON ), reply .Block )
2115
2106
})
2116
2107
}
2117
2108
}
@@ -2313,7 +2304,11 @@ func TestServiceGetBlockByHeight(t *testing.T) {
2313
2304
return
2314
2305
}
2315
2306
require .Equal (tt .encoding , reply .Encoding )
2316
- require .Equal (expected , reply .Block )
2307
+
2308
+ expectedJSON , err := stdjson .Marshal (expected )
2309
+ require .NoError (err )
2310
+
2311
+ require .Equal (stdjson .RawMessage (expectedJSON ), reply .Block )
2317
2312
})
2318
2313
}
2319
2314
}
0 commit comments