github.com/sixexorg/magnetic-ring@v0.0.0-20191119090307-31705a21e419/http/router/orgchain_build_test.go (about) 1 package router_test 2 3 import ( 4 "math/big" 5 6 "github.com/sixexorg/magnetic-ring/common" 7 orgtypes "github.com/sixexorg/magnetic-ring/core/orgchain/types" 8 ) 9 10 func orgTransactionBuild(nonce uint64, from, to string, tp orgtypes.TransactionType, txhash string, reply orgtypes.VoteAttitude) *orgtypes.Transaction { 11 fromAddr, _ := common.ToAddress(from) 12 toAddr, _ := common.ToAddress(to) 13 switch tp { 14 case orgtypes.TransferUT: 15 txins := &common.TxIns{} 16 txin := common.TxIn{ 17 Address: fromAddr, 18 Amount: big.NewInt(100), 19 Nonce: nonce, 20 } 21 txins.Tis = append(txins.Tis, &txin) 22 23 totxins := &common.TxOuts{} 24 totxin := common.TxOut{ 25 Address: toAddr, 26 Amount: big.NewInt(100), 27 } 28 totxins.Tos = append(totxins.Tos, &totxin) 29 txdata := &orgtypes.TxData{ 30 From: fromAddr, 31 Froms: txins, 32 Tos: totxins, 33 Fee: big.NewInt(10000000), 34 Nonce:nonce, 35 } 36 tx := &orgtypes.Transaction{ 37 Version: orgtypes.TxVersion, 38 TxType: tp, 39 TxData: txdata, 40 } 41 return tx 42 case orgtypes.GetBonus: 43 44 tx := &orgtypes.Transaction{ 45 Version: orgtypes.TxVersion, 46 TxType: tp, 47 TxData: &orgtypes.TxData{ 48 From: fromAddr, 49 Fee: big.NewInt(1), 50 Nonce: nonce, 51 }, 52 } 53 return tx 54 case orgtypes.VoteIncreaseUT: 55 tx := &orgtypes.Transaction{ 56 Version: orgtypes.TxVersion, 57 TxType: tp, 58 TxData: &orgtypes.TxData{ 59 From: fromAddr, 60 Fee: big.NewInt(1), 61 Nonce: nonce, 62 LeagueId: leagueIdAddress, 63 MetaBox: big.NewInt(20), 64 Start: 3, 65 End: 5, 66 }, 67 } 68 return tx 69 case orgtypes.ReplyVote: 70 th, _ := common.StringToHash(txhash) 71 tx := &orgtypes.Transaction{ 72 Version: orgtypes.TxVersion, 73 TxType: tp, 74 TxData: &orgtypes.TxData{ 75 From: fromAddr, 76 Fee: big.NewInt(1), 77 Nonce: nonce, 78 TxHash: th, 79 VoteReply: uint8(reply), 80 }, 81 } 82 return tx 83 } 84 return nil 85 }