func TestExtractTxid(t *testing.T) {
	txid := "txID"
	txEnv, txid, _ := testutil.ConstructTransaction(t, testutil.ConstructRandomBytes(t, 50), false)
	txEnvBytes, _ := putils.GetBytesEnvelope(txEnv)
	extractedTxid, err := extractTxID(txEnvBytes)
	testutil.AssertNoError(t, err, "")
	testutil.AssertEquals(t, extractedTxid, txid)
}
func endTxSimulation(chainID string, txsim ledger.TxSimulator, payload []byte, commit bool, prop *pb.Proposal) error {
	txsim.Done()
	if lgr := peer.GetLedger(chainID); lgr != nil {
		if commit {
			var txSimulationResults []byte
			var err error

			//get simulation results
			if txSimulationResults, err = txsim.GetTxSimulationResults(); err != nil {
				return err
			}

			// assemble a (signed) proposal response message
			resp, err := putils.CreateProposalResponse(prop.Header, prop.Payload, txSimulationResults, nil, nil, signer)
			if err != nil {
				return err
			}

			// get the envelope
			env, err := putils.CreateSignedTx(prop, signer, resp)
			if err != nil {
				return err
			}

			envBytes, err := putils.GetBytesEnvelope(env)
			if err != nil {
				return err
			}

			//create the block with 1 transaction
			block := common.NewBlock(1, []byte{})
			block.Data.Data = [][]byte{envBytes}
			//commit the block
			if err := lgr.Commit(block); err != nil {
				return err
			}
		}
	}

	return nil
}
func TestInvoke(t *testing.T) {
	v := new(ValidatorOneValidSignature)
	stub := shim.NewMockStub("validatoronevalidsignature", v)

	// Failed path: Invalid arguments
	args := [][]byte{[]byte("dv")}
	if _, err := stub.MockInvoke("1", args); err == nil {
		t.Fatalf("vscc invoke should have failed")
		return
	}

	args = [][]byte{[]byte("dv"), []byte("tx")}
	args[1] = nil
	if _, err := stub.MockInvoke("1", args); err == nil {
		t.Fatalf("vscc invoke should have failed")
		return
	}

	tx, err := createTx()
	if err != nil {
		t.Fatalf("createTx returned err %s", err)
		return
	}

	envBytes, err := utils.GetBytesEnvelope(tx)
	if err != nil {
		t.Fatalf("GetBytesEnvelope returned err %s", err)
		return
	}

	args = [][]byte{[]byte("dv"), envBytes}
	if _, err := stub.MockInvoke("1", args); err != nil {
		t.Fatalf("vscc invoke returned err %s", err)
		return
	}
}