@@ -17,7 +17,7 @@ import (
1717)
1818
1919func init () {
20- owtp .Debug = false
20+ owtp .Debug = true
2121}
2222
2323func testNewAPINode () * APINode {
@@ -220,7 +220,7 @@ func TestAPINode_CreateAccount(t *testing.T) {
220220func TestAPINode_FindAccountByWalletID (t * testing.T ) {
221221 walletID := "W1iymivnBrjxtQdbm9esyheuy3mLeJWHto"
222222 api := testNewAPINode ()
223- api .FindAccountByWalletID ("ETH " , walletID , 0 , 0 , true ,
223+ api .FindAccountByWalletID ("" , walletID , 0 , 0 , true ,
224224 func (status uint64 , msg string , accounts []* Account ) {
225225
226226 if status != owtp .StatusSuccess {
@@ -814,78 +814,85 @@ func TestAPINode_FollowSmartContractRecepit(t *testing.T) {
814814func TestAPINode_CreateSmartContractTrade (t * testing.T ) {
815815
816816 var (
817- retRawTx * SmartContractRawTransaction
818- retTx []* SmartContractReceipt
819- retFailed []* FailureSmartContractLog
820- err error
821- key * hdkeystore.HDKey
822- accountID = "5kTzFGuAH9UkB9yhZdmXtF8hGPh6iPt4hf8Q3DVy3Xo3 "
817+ retRawTx * SmartContractRawTransaction
818+ // retTx []*SmartContractReceipt
819+ // retFailed []*FailureSmartContractLog
820+ err error
821+ // key *hdkeystore.HDKey
822+ accountID = "Eh2ALZguch6DS2JaoFz97ZspvBvv56FjB79CVVkqc1aA "
823823 sid = uuid .New ().String ()
824824 coin = Coin {
825- Symbol : "QUORUM " ,
825+ Symbol : "MATIC " ,
826826 IsContract : true ,
827- ContractID : "dl8WD7bM7xk4ZxRybuHCo3JDDtZn2ugPusapoKnQEWA=" ,
827+ ContractID : openwallet . GenContractID ( "MATIC" , "0x9866c45224667061f8c9e66db38d9316a8d68951" ) ,
828828 }
829- abiParam = []string {"transfer" , "0x19a4b5d6ea319a5d5ad1d4cc00a5e2e28cac5ec3" , "123" }
829+ //abiParam = []string{"transfer", "0x19a4b5d6ea319a5d5ad1d4cc00a5e2e28cac5ec3", "123"}
830+ raw = "{\" gas\" :\" 0x11118\" ,\" from\" :\" 0x282425dd54156902ead4a99ec7e80a21213d878d\" ,\" to\" :\" 0x9faef544a1c9a3ccab003174bb62a32e3aaab719\" ,\" data\" :\" 0xa22cb4650000000000000000000000000c58c1170f1ded633862a1166f52107490a9c5940000000000000000000000000000000000000000000000000000000000000001\" }"
830831 )
831832
832833 api := testNewAPINode ()
833- api .CreateSmartContractTrade (sid , accountID , coin , abiParam , "" , 0 , "" , "1 " , true ,
834+ err = api .CreateSmartContractTrade (sid , accountID , coin , nil , raw , openwallet . TxRawTypeJSON , "" , "0 " , true ,
834835 func (status uint64 , msg string , rawTx * SmartContractRawTransaction ) {
835836 if status != owtp .StatusSuccess {
836837 err = fmt .Errorf (msg )
837838 return
838839 }
839840 retRawTx = rawTx
840841 })
841- log .Infof ("rawTx: %+v" , retRawTx )
842-
843- key , err = testGetLocalKey ()
844842 if err != nil {
845- t .Logf ("GetKey error: %v\n " , err )
843+ t .Logf ("CreateSmartContractTrade error: %v\n " , err )
846844 return
847845 }
846+ log .Infof ("rawTx: %+v" , retRawTx )
848847
849- //签名交易单
850- signatures , signErr := SignTxHash (retRawTx .Signatures , key )
851- if signErr != nil {
852- t .Logf ("SignRawTransaction unexpected error: %v\n " , signErr )
853- return
854- }
855-
856- retRawTx .Signatures = signatures
857- retRawTx .AwaitResult = true
858-
859- log .Infof ("signed rawTx: %+v" , retRawTx )
848+ /*
849+ key, err = testGetLocalKey()
850+ if err != nil {
851+ t.Logf("GetKey error: %v\n", err)
852+ return
853+ }
860854
861- api . SubmitSmartContractTrade ([] * SmartContractRawTransaction { retRawTx }, true ,
862- func ( status uint64 , msg string , successTx [] * SmartContractReceipt , failedRawTxs [] * FailureSmartContractLog ) {
863- if status != owtp . StatusSuccess {
864- err = fmt . Errorf ( msg )
855+ //签名交易单
856+ signatures, signErr := SignTxHash(retRawTx.Signatures, key)
857+ if signErr != nil {
858+ t.Logf("SignRawTransaction unexpected error: %v\n", signErr )
865859 return
866860 }
867861
868- retTx = successTx
869- retFailed = failedRawTxs
870- })
862+ retRawTx.Signatures = signatures
863+ retRawTx.AwaitResult = true
871864
872- log .Info ( "============== success ==============" )
865+ log.Infof("signed rawTx: %+v", retRawTx )
873866
874- for _ , tx := range retTx {
875- log .Infof ("tx: %+v" , tx )
867+ api.SubmitSmartContractTrade([]*SmartContractRawTransaction{retRawTx}, true,
868+ func(status uint64, msg string, successTx []*SmartContractReceipt, failedRawTxs []*FailureSmartContractLog) {
869+ if status != owtp.StatusSuccess {
870+ err = fmt.Errorf(msg)
871+ return
872+ }
876873
877- for i , event := range tx .Events {
878- log .Std .Notice ("events[%d]: %+v" , i , event )
879- }
880- }
874+ retTx = successTx
875+ retFailed = failedRawTxs
876+ })
881877
882- log .Info ("" )
878+ log.Info("============== success ============== ")
883879
884- log .Info ("============== fail ==============" )
880+ for _, tx := range retTx {
881+ log.Infof("tx: %+v", tx)
885882
886- for _ , tx := range retFailed {
887- log .Infof ("tx: %+v" , tx .Reason )
888- }
883+ for i, event := range tx.Events {
884+ log.Std.Notice("events[%d]: %+v", i, event)
885+ }
886+ }
887+
888+ log.Info("")
889+
890+ log.Info("============== fail ==============")
891+
892+ for _, tx := range retFailed {
893+ log.Infof("tx: %+v", tx.Reason)
894+ }
895+ */
889896}
890897
891898func TestAPINode_FindSmartContractReceiptByParams (t * testing.T ) {
0 commit comments