Ejemplo n.º 1
0
        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.
        }
Ejemplo n.º 2
0
        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. ");
        }
Ejemplo n.º 3
0
        public void TestBuildChaincodePathJavaStream()
        {
            InstallProposalBuilder builder = CreateTestBuilder();

            builder.ChaincodeLanguage(TransactionRequest.Type.JAVA);
            builder.SetChaincodeInputStream(new MemoryStream("test string".ToBytes()));
            builder.ChaincodePath("null or empty string");

            builder.Build();
        }
Ejemplo n.º 4
0
        public void TestBuildChaincodePathJavaFile()
        {
            InstallProposalBuilder builder = CreateTestBuilder();

            builder.ChaincodeLanguage(TransactionRequest.Type.JAVA);
            builder.ChaincodeSource("some/dir");
            builder.ChaincodePath("null or empty string");

            builder.Build();
        }
Ejemplo n.º 5
0
        public void TestBuildChaincodePathGolangStream()
        {
            InstallProposalBuilder builder = CreateTestBuilder();

            builder.ChaincodeLanguage(TransactionRequest.Type.GO_LANG);
            builder.SetChaincodeInputStream(new MemoryStream("test string".ToBytes()));
            builder.ChaincodePath(null);

            builder.Build();
        }
Ejemplo n.º 6
0
        public void TestBuildChaincodePathGolangFile()
        {
            InstallProposalBuilder builder = CreateTestBuilder();

            builder.ChaincodeLanguage(TransactionRequest.Type.GO_LANG);
            builder.ChaincodeSource("some/dir");
            builder.ChaincodePath(null);

            builder.Build();
        }
Ejemplo n.º 7
0
        public void TestBuildChaincodePathNodeStream()
        {
            InstallProposalBuilder builder = CreateTestBuilder();

            builder.ChaincodeLanguage(TransactionRequest.Type.NODE);
            builder.SetChaincodeInputStream(new MemoryStream("test string".ToBytes()));
            builder.ChaincodePath("src");

            builder.Build();
        }
Ejemplo n.º 8
0
        public void TestBuildChaincodePathNodeFile()
        {
            InstallProposalBuilder builder = CreateTestBuilder();

            builder.ChaincodeLanguage(TransactionRequest.Type.NODE);
            builder.ChaincodeSource("some/dir");
            builder.ChaincodePath("src");

            builder.Build();
        }
Ejemplo n.º 9
0
        public void TestBuildSourceNotExistGolang()
        {
            InstallProposalBuilder builder = CreateTestBuilder();

            builder.ChaincodeLanguage(TransactionRequest.Type.JAVA);
            builder.ChaincodePath(null);
            builder.ChaincodeSource("some/dir");

            builder.Build();
        }
Ejemplo n.º 10
0
        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.
        }
Ejemplo n.º 11
0
        public void TestBuildSourceNotDirectory()
        {
            InstallProposalBuilder builder = CreateTestBuilder();
            string folderpath = Path.Combine(tempFolder, "src");

            // create an empty src directory
            Directory.CreateDirectory(folderpath);
            // Create a dummy file in the chaincode directory
            string dummyFileName = "myapp";
            string filepath      = Path.Combine(folderpath, dummyFileName);

            File.WriteAllText(filepath, string.Empty);

            builder.ChaincodePath(dummyFileName);
            builder.ChaincodeSource(folderpath);

            builder.Build();
        }
Ejemplo n.º 12
0
        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.
        }