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

Function GenNeoVMTransaction

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

Source from the content-addressed store, hash-verified

165}
166
167func GenNeoVMTransaction(testCase TestCase, contract common.Address, testConext *TestContext) (*types.Transaction, error) {
168 params, err := utils2.ParseParams(testCase.Param)
169 if err != nil {
170 return nil, err
171 }
172 allParam := append([]interface{}{}, testCase.Method)
173 allParam = append(allParam, params...)
174 tx, err := common2.NewNeovmInvokeTransaction(0, 100000000, contract, allParam)
175 if err != nil {
176 return nil, err
177 }
178
179 if testCase.NeedContext {
180 args := buildTestConextForNeo(testConext)
181 codelen := uint32(len(tx.Payload.(*payload.InvokeCode).Code))
182 tx.Payload.(*payload.InvokeCode).Code = append(tx.Payload.(*payload.InvokeCode).Code[:codelen-(common.ADDR_LEN+1)], args...)
183 tx.Payload.(*payload.InvokeCode).Code = append(tx.Payload.(*payload.InvokeCode).Code, 0x67)
184 tx.Payload.(*payload.InvokeCode).Code = append(tx.Payload.(*payload.InvokeCode).Code, contract[:]...)
185 //neovms.Dumpcode(tx.Payload.(*payload.InvokeCode).Code[:], "")
186 }
187
188 imt, err := tx.IntoImmutable()
189 if err != nil {
190 return nil, err
191 }
192
193 imt.SignedAddr = append(imt.SignedAddr, testCase.Env.Witness...)
194 imt.SignedAddr = append(imt.SignedAddr, testConext.Admin)
195
196 return imt, nil
197}
198
199func buildTestConext(testConext *TestContext) []byte {
200 bf := common.NewZeroCopySink(nil)

Callers

nothing calls this directly

Calls 2

buildTestConextForNeoFunction · 0.85
IntoImmutableMethod · 0.80

Tested by

no test coverage detected