func checkInvoke(t *testing.T, stub *shim.MockStub, args [][]byte) {
	_, err := stub.MockInvoke("1", args)
	if err != nil {
		fmt.Println("Invoke", args, "failed", err)
		t.FailNow()
	}
}
Exemplo n.º 2
0
func checkInvoke(t *testing.T, scc *SimpleChaincode, stub *shim.MockStub, args []string) {
	_, err := stub.MockInvoke("1", "query", args)
	if err != nil {
		fmt.Println("Invoke", args, "failed", err)
		t.FailNow()
	}
}
Exemplo n.º 3
0
func register(stub *shim.MockStub, ccname string) error {
	args := [][]byte{[]byte("register"), []byte(ccname)}
	if _, err := stub.MockInvoke("1", args); err != nil {
		return err
	}
	return nil
}
func checkQuery(t *testing.T, stub *shim.MockStub, args [][]byte, expect string) {
	bytes, err := stub.MockInvoke("1", args)
	if err != nil {
		fmt.Println("Query", args, "failed", err)
		t.FailNow()
	}
	if bytes == nil {
		fmt.Println("Query", args, "failed to get result")
		t.FailNow()
	}
	if string(bytes) != expect {
		fmt.Println("Query result ", string(bytes), "was not", expect, "as expected")
		t.FailNow()
	}
}
func checkQuery(t *testing.T, stub *shim.MockStub, name string, value string) {
	bytes, err := stub.MockInvoke("1", [][]byte{[]byte("query"), []byte(name)})
	if err != nil {
		fmt.Println("Query", name, "failed", err)
		t.FailNow()
	}
	if bytes == nil {
		fmt.Println("Query", name, "failed to get value")
		t.FailNow()
	}
	if string(bytes) != value {
		fmt.Println("Query value", name, "was not", value, "as expected")
		t.FailNow()
	}
}
Exemplo n.º 6
0
func checkInvoke(t *testing.T, stub *shim.MockStub, args [][]byte, retval []byte) {
	result, err := stub.MockInvoke("1", args)
	if err != nil {
		fmt.Println("Invoke", args, "failed", err)
		t.FailNow()
	}

	if retval != nil {
		if result == nil {
			fmt.Printf("Invoke returned nil, expected %s", string(retval))
			t.FailNow()
		}
		if string(result) != string(retval) {
			fmt.Printf("Invoke returned %s, expected %s", string(result), string(retval))
			t.FailNow()
		}
	}
}