コード例 #1
0
ファイル: txtestutils.go プロジェクト: hyperledger/fabric
// ConstructUnsingedTxEnv creates a Transaction envelope from given inputs
func ConstructUnsingedTxEnv(txid string, chainID string, ccName string, simulationResults []byte, events []byte, visibility []byte) (*common.Envelope, error) {
	if mspLcl == nil {
		mspLcl = msp.NewNoopMsp()
		sigId, _ = mspLcl.GetDefaultSigningIdentity()
	}

	return ConstructSingedTxEnv(txid, chainID, ccName, simulationResults, events, visibility, sigId)
}
コード例 #2
0
ファイル: fullflow_test.go プロジェクト: hyperledger/fabric
func TestBadProp(t *testing.T) {
	// get a toy proposal
	prop, err := getProposal()
	if err != nil {
		t.Fatalf("getProposal failed, err %s", err)
		return
	}

	// sign it
	sProp, err := utils.GetSignedProposal(prop, signer)
	if err != nil {
		t.Fatalf("GetSignedProposal failed, err %s", err)
		return
	}

	// mess with the signature
	corrupt(sProp.Signature)

	// validate it - it should fail
	_, _, _, err = ValidateProposalMessage(sProp)
	if err == nil {
		t.Fatalf("ValidateProposalMessage should have failed")
		return
	}

	// sign it again
	sProp, err = utils.GetSignedProposal(prop, signer)
	if err != nil {
		t.Fatalf("GetSignedProposal failed, err %s", err)
		return
	}

	// mess with the message
	corrupt(sProp.ProposalBytes)

	// validate it - it should fail
	_, _, _, err = ValidateProposalMessage(sProp)
	if err == nil {
		t.Fatalf("ValidateProposalMessage should have failed")
		return
	}

	// get a bad signing identity
	badSigner, err := msp.NewNoopMsp().GetDefaultSigningIdentity()
	if err != nil {
		t.Fatalf("Couldn't get noop signer")
		return
	}

	// sign it again with the bad signer
	sProp, err = utils.GetSignedProposal(prop, badSigner)
	if err != nil {
		t.Fatalf("GetSignedProposal failed, err %s", err)
		return
	}

	// validate it - it should fail
	_, _, _, err = ValidateProposalMessage(sProp)
	if err == nil {
		t.Fatalf("ValidateProposalMessage should have failed")
		return
	}
}