예제 #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 TestProposalBuilderWithMetaInf()
        {
            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.ChaincodeMetaInfLocation("fixture/meta-infs/test1".Locate());
            installProposalBuilder.ChaincodeVersion("1");

            Channel channel = hfclient.NewChannel("testProposalBuilderWithMetaInf");

            TestUtils.TestUtils.MockUser mockUser           = TestUtils.TestUtils.GetMockUser("rick", "rickORG");
            TransactionContext           transactionContext = new TransactionContext(channel, mockUser, 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> {
                "META-INF/statedb/couchdb/indexes/MockFakeIndex.json", "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 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.
        }
예제 #4
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.
        }