public void TestProposalBuilderWithMetaInfEmpty() { string emptyINF = "fixture/meta-infs/emptyMetaInf/META-INF".Locate(); // make it cause git won't check in empty directory if (!Directory.Exists(emptyINF)) { Directory.CreateDirectory(emptyINF); } InstallProposalBuilder installProposalBuilder = InstallProposalBuilder.Create(); installProposalBuilder.ChaincodeLanguage(TransactionRequest.Type.GO_LANG); installProposalBuilder.ChaincodePath("github.com/example_cc"); installProposalBuilder.ChaincodeSource(SAMPLE_GO_CC.Locate()); installProposalBuilder.ChaincodeName("example_cc.go"); installProposalBuilder.ChaincodeVersion("1"); installProposalBuilder.ChaincodeMetaInfLocation("fixture/meta-infs/emptyMetaInf".Locate()); // points into which is not what's expected. Channel channel = hfclient.NewChannel("testProposalBuilderWithMetaInfEmpty"); TransactionContext transactionContext = new TransactionContext(channel, TestUtils.TestUtils.GetMockUser("rick", "rickORG"), Factory.Instance.GetCryptoSuite()); installProposalBuilder.Context(transactionContext); installProposalBuilder.Build(); // Build it get the proposal. Then unpack it to see if it's what we epect. }
public void TestProposalBuilderWithOutMetaInf() { InstallProposalBuilder installProposalBuilder = InstallProposalBuilder.Create(); installProposalBuilder.ChaincodeLanguage(TransactionRequest.Type.GO_LANG); installProposalBuilder.ChaincodePath("github.com/example_cc"); installProposalBuilder.ChaincodeSource(SAMPLE_GO_CC.Locate()); installProposalBuilder.ChaincodeName("example_cc.go"); installProposalBuilder.ChaincodeVersion("1"); Channel channel = hfclient.NewChannel("testProposalBuilderWithOutMetaInf"); TransactionContext transactionContext = new TransactionContext(channel, TestUtils.TestUtils.GetMockUser("rick", "rickORG"), Factory.Instance.GetCryptoSuite()); installProposalBuilder.Context(transactionContext); Proposal proposal = installProposalBuilder.Build(); // Build it get the proposal. Then unpack it to see if it's what we expect. ChaincodeProposalPayload chaincodeProposalPayload = ChaincodeProposalPayload.Parser.ParseFrom(proposal.Payload); ChaincodeInvocationSpec chaincodeInvocationSpec = ChaincodeInvocationSpec.Parser.ParseFrom(chaincodeProposalPayload.Input); ChaincodeSpec chaincodeSpec = chaincodeInvocationSpec.ChaincodeSpec; ChaincodeInput input = chaincodeSpec.Input; ChaincodeDeploymentSpec chaincodeDeploymentSpec = ChaincodeDeploymentSpec.Parser.ParseFrom(input.Args[1]); ByteString codePackage = chaincodeDeploymentSpec.CodePackage; List <string> tarBytesToEntryArrayList = TestUtils.TestUtils.TarBytesToEntryArrayList(codePackage.ToByteArray()); List <string> expect = new List <string>() { "src/github.com/example_cc/example_cc.go" }; CollectionAssert.AreEquivalent(expect, tarBytesToEntryArrayList, "Tar in Install Proposal's codePackage does not have expected entries. "); }
// ========================================================================================== // Helper methods // ========================================================================================== // Instantiates a basic InstallProposalBuilder with no chaincode source specified private InstallProposalBuilder CreateTestBuilder() { InstallProposalBuilder builder = InstallProposalBuilder.Create(); builder.ChaincodeName("mycc"); builder.ChaincodeVersion("1.0"); builder.ChaincodeLanguage(TransactionRequest.Type.GO_LANG); return(builder); }
public void TestProposalBuilderWithMetaInfExistsNOT() { InstallProposalBuilder installProposalBuilder = InstallProposalBuilder.Create(); installProposalBuilder.ChaincodeLanguage(TransactionRequest.Type.GO_LANG); installProposalBuilder.ChaincodePath("github.com/example_cc"); installProposalBuilder.ChaincodeSource(SAMPLE_GO_CC.Locate()); installProposalBuilder.ChaincodeName("example_cc.go"); installProposalBuilder.ChaincodeVersion("1"); installProposalBuilder.ChaincodeMetaInfLocation("/tmp/fdsjfksfj/fjksfjskd/fjskfjdsk/should never exist"); // points into which is not what's expected. Channel channel = hfclient.NewChannel("testProposalBuilderWithMetaInfExistsNOT"); TransactionContext transactionContext = new TransactionContext(channel, TestUtils.TestUtils.GetMockUser("rick", "rickORG"), Factory.Instance.GetCryptoSuite()); installProposalBuilder.Context(transactionContext); installProposalBuilder.Build(); // Build it get the proposal. Then unpack it to see if it's what we epect. }
public void TestProposalBuilderWithNoMetaInfDir() { InstallProposalBuilder installProposalBuilder = InstallProposalBuilder.Create(); installProposalBuilder.ChaincodeLanguage(TransactionRequest.Type.GO_LANG); installProposalBuilder.ChaincodePath("github.com/example_cc"); installProposalBuilder.ChaincodeSource(SAMPLE_GO_CC.Locate()); installProposalBuilder.ChaincodeName("example_cc.go"); installProposalBuilder.ChaincodeVersion("1"); installProposalBuilder.ChaincodeMetaInfLocation("fixture/meta-infs/test1/META-INF".Locate()); // points into which is not what's expected. Channel channel = hfclient.NewChannel("testProposalBuilderWithNoMetaInfDir"); TransactionContext transactionContext = new TransactionContext(channel, TestUtils.TestUtils.GetMockUser("rick", "rickORG"), Factory.Instance.GetCryptoSuite()); installProposalBuilder.Context(transactionContext); installProposalBuilder.Build(); // Build it get the proposal. Then unpack it to see if it's what we epect. }