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

Function GenNeoTextCaseTransaction

wasmtest/wasm-test.go:91–123  ·  view source on GitHub ↗
(contract common.Address, database *ledger.Ledger)

Source from the content-addressed store, hash-verified

89}
90
91func GenNeoTextCaseTransaction(contract common.Address, database *ledger.Ledger) [][]common3.TestCase {
92 params := make([]interface{}, 0)
93 method := string("testcase")
94 // neovm entry api is def Main(method, args). and testcase method api need no other args, so pass a random args to entry api.
95 operation := 1
96 params = append(params, method)
97 params = append(params, operation)
98 tx, err := common2.NewNeovmInvokeTransaction(0, 100000000, contract, params)
99 imt, err := tx.IntoImmutable()
100 if err != nil {
101 panic(err)
102 }
103 res, err := database.PreExecuteContract(imt)
104 if err != nil {
105 panic(err)
106 }
107
108 ret := res.Result.(string)
109 jsonCase, err := common.HexToBytes(ret)
110
111 if err != nil {
112 panic(err)
113 }
114 if len(jsonCase) == 0 {
115 panic("failed to get testcase data from contract")
116 }
117 var testCase [][]common3.TestCase
118 err = json.Unmarshal([]byte(jsonCase), &testCase)
119 if err != nil {
120 panic("failed Unmarshal")
121 }
122 return testCase
123}
124
125func ExactTestCase(code []byte) [][]common3.TestCase {
126 m, err := wasm.ReadModule(bytes.NewReader(code), func(name string) (*wasm.Module, error) {

Callers 1

mainFunction · 0.85

Calls 2

IntoImmutableMethod · 0.80
PreExecuteContractMethod · 0.65

Tested by

no test coverage detected