github.com/sixexorg/magnetic-ring@v0.0.0-20191119090307-31705a21e419/mock/main_mock.go (about) 1 package mock 2 3 import ( 4 "math/big" 5 6 "os" 7 8 "github.com/sixexorg/magnetic-ring/common" 9 "github.com/sixexorg/magnetic-ring/core/mainchain/types" 10 ) 11 12 var ( 13 Mock_Tx_CreateLeague *types.Transaction 14 15 Mock_Tx *types.Transaction 16 Mock_TxData *types.TxData 17 Mock_Address_1 common.Address 18 Mock_Address_2 common.Address 19 20 MockHash common.Hash 21 ) 22 23 func CatchPanic(dbdir string) { 24 if err := recover(); err != nil { 25 goto REMOVE 26 } 27 REMOVE: 28 os.RemoveAll(dbdir) 29 } 30 31 func init() { 32 33 nodeId, _ := common.ToAddress("ct1qK96vAkK6E8S7JgYUY3YY28Qhj6cmaaa") 34 35 Mock_Tx_CreateLeague = &types.Transaction{ 36 Version: 0x01, 37 TxType: types.CreateLeague, 38 TxData: &types.TxData{ 39 From: Address_1, 40 Nonce: 1, 41 Fee: big.NewInt(20), 42 Rate: 20, 43 MinBox: 10, 44 MetaBox: big.NewInt(200), 45 NodeId: nodeId, 46 Private: false, 47 }, 48 } 49 50 //address, _ := common.ToAddress("ct1qK96vAkK6E8S7JgYUY3YY28Qhj6cmfdx") 51 Mock_Address_1, _ = common.ToAddress("ct1qK96vAkK6E8S7JgYUY3YY28Qhj6cmfdy") 52 Mock_Address_2, _ = common.ToAddress("ct1qK96vAkK6E8S7JgYUY3YY28Qhj6cmfdz") 53 MockHash = common.Hash{1, 'a', 'd', 3} 54 froms := &common.TxIns{} 55 froms.Tis = append(froms.Tis, 56 &common.TxIn{ 57 Address: Mock_Address_1, 58 Nonce: 100, 59 Amount: big.NewInt(200), 60 }, 61 &common.TxIn{ 62 Address: Mock_Address_2, 63 Nonce: 200, 64 Amount: big.NewInt(300), 65 }, 66 ) 67 tos := &common.TxOuts{} 68 tos.Tos = append(tos.Tos, 69 &common.TxOut{ 70 Address: Mock_Address_1, 71 Amount: big.NewInt(200), 72 }, 73 &common.TxOut{ 74 Address: Mock_Address_2, 75 Amount: big.NewInt(300), 76 }, 77 ) 78 Mock_TxData = &types.TxData{ 79 Froms: froms, 80 Tos: tos, 81 Fee: big.NewInt(100), 82 } 83 84 Mock_Tx = &types.Transaction{ 85 Version: 0x01, 86 TxType: types.TransferBox, 87 TxData: Mock_TxData, 88 } 89 90 }