March 2019
Intermediate to advanced
636 pages
27h 50m
English
First, we need to define the function needed to invoke the Init method. The function will receive references to MockStub, as well as to an array of arguments to pass to the Init method. In line 2 of the following code, the chaincode function Init is invoked with the received arguments, which is then verified in line 3.
The following snippet illustrates the invocation of the Init method:
func checkInit(t *testing.T, stub *shim.MockStub, args [][]byte) {
res := stub.MockInit("1", args)
if res.Status != shim.OK {
fmt.Println("Init failed", string(res.Message))
t.FailNow()
}
}
We will now define the function needed to prepare a default array of values of the Init function arguments, shown as follows:
func getInitArguments() ...
Read now
Unlock full access