(testCase TestCase, contract common.Address, testConext *TestContext)
| 89 | } |
| 90 | |
| 91 | func GenWasmTransaction(testCase TestCase, contract common.Address, testConext *TestContext) (*types.Transaction, error) { |
| 92 | params, err := utils2.ParseParams(testCase.Param) |
| 93 | if err != nil { |
| 94 | return nil, err |
| 95 | } |
| 96 | allParam := append([]interface{}{}, testCase.Method) |
| 97 | allParam = append(allParam, params...) |
| 98 | tx, err := utils.NewWasmVMInvokeTransaction(0, 100000000, contract, allParam) |
| 99 | if err != nil { |
| 100 | return nil, err |
| 101 | } |
| 102 | |
| 103 | if testCase.NeedContext { |
| 104 | source := common.NewZeroCopySource(tx.Payload.(*payload.InvokeCode).Code) |
| 105 | contract := &states.WasmContractParam{} |
| 106 | err := contract.Deserialization(source) |
| 107 | if err != nil { |
| 108 | return nil, err |
| 109 | } |
| 110 | contextParam := buildTestConext(testConext) |
| 111 | contract.Args = append(contract.Args, contextParam...) |
| 112 | |
| 113 | tx.Payload.(*payload.InvokeCode).Code = common.SerializeToBytes(contract) |
| 114 | } |
| 115 | |
| 116 | imt, err := tx.IntoImmutable() |
| 117 | if err != nil { |
| 118 | return nil, err |
| 119 | } |
| 120 | |
| 121 | imt.SignedAddr = append(imt.SignedAddr, testCase.Env.Witness...) |
| 122 | imt.SignedAddr = append(imt.SignedAddr, testConext.Admin) |
| 123 | |
| 124 | return imt, nil |
| 125 | } |
| 126 | |
| 127 | // when need pass testConext to neovm contract, must write contract as def Main(operation, args) api. and args need be a list. |
| 128 | func buildTestConextForNeo(testConext *TestContext) []byte { |
nothing calls this directly
no test coverage detected