func checkInit(t *testing.T, stub *shim.MockStub, args [][]byte) { _, err := stub.MockInit("1", args) if err != nil { fmt.Println("Init failed", err) t.FailNow() } }
func checkInit(t *testing.T, scc *SimpleChaincode, stub *shim.MockStub, args []string) { _, err := stub.MockInit("1", "init", args) if err != nil { fmt.Println("Init failed", err) t.FailNow() } }
func checkInit(t *testing.T, stub *shim.MockStub, args [][]byte, retval []byte) { result, err := stub.MockInit("1", args) if err != nil { fmt.Println("Init failed", err) t.FailNow() } if retval != nil { if result == nil { fmt.Printf("Init returned nil, expected %s", string(retval)) t.FailNow() } if string(result) != string(retval) { fmt.Printf("Init returned %s, expected %s", string(result), string(retval)) t.FailNow() } } }
func checkQuery(t *testing.T, scc *SimpleChaincode, stub *shim.MockStub, args [][]byte) { _, err := stub.MockInit("1", args) bytes, err := scc.Invoke(stub) if err != nil { // expected failure fmt.Println("Query below is expected to fail") fmt.Println("Query failed", err) fmt.Println("Query above is expected to fail") if err.Error() != "{\"Error\":\"Cannot put state within chaincode query\"}" { fmt.Println("Failure was not the expected \"Cannot put state within chaincode query\" : ", err) t.FailNow() } } else { fmt.Println("Query did not fail as expected (PutState within Query)!", bytes, err) t.FailNow() } }