Пример #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.
        }
Пример #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. ");
        }
Пример #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();
        }
Пример #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();
        }
Пример #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();
        }
Пример #6
0
        public void TestBuildChaincodePathGolangFile()
        {
            InstallProposalBuilder builder = CreateTestBuilder();

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

            builder.Build();
        }
Пример #7
0
        // ==========================================================================================
        // 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);
        }
Пример #8
0
        public void TestBuildChaincodePathNodeStream()
        {
            InstallProposalBuilder builder = CreateTestBuilder();

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

            builder.Build();
        }
Пример #9
0
        public void TestBuildChaincodePathNodeFile()
        {
            InstallProposalBuilder builder = CreateTestBuilder();

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

            builder.Build();
        }
Пример #10
0
        public void TestBuildSourceNotExistGolang()
        {
            InstallProposalBuilder builder = CreateTestBuilder();

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

            builder.Build();
        }
Пример #11
0
        public void TestBuildInvalidSource()
        {
            // A mock InputStream that throws an IOException


            InstallProposalBuilder builder = CreateTestBuilder();

            builder.ChaincodeLanguage(TransactionRequest.Type.JAVA);
            builder.SetChaincodeInputStream(new MockInputStream());

            builder.Build();
        }
Пример #12
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.
        }
Пример #13
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.
        }