MCPcopy Create free account
hub / github.com/DNAProject/DNA / GenWasmTransaction

Function GenWasmTransaction

wasmtest/common/common.go:91–125  ·  view source on GitHub ↗
(testCase TestCase, contract common.Address, testConext *TestContext)

Source from the content-addressed store, hash-verified

89}
90
91func 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.
128func buildTestConextForNeo(testConext *TestContext) []byte {

Callers

nothing calls this directly

Calls 6

DeserializationMethod · 0.95
NewZeroCopySourceFunction · 0.92
SerializeToBytesFunction · 0.92
buildTestConextFunction · 0.85
IntoImmutableMethod · 0.80

Tested by

no test coverage detected