Exemplo n.º 1
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. ");
        }
Exemplo n.º 2
0
        public void TestBadUserNameNull()
        {
            HFClient client = HFClient.Create();

            client.CryptoSuite = Factory.Instance.GetCryptoSuite();

            TestUtils.TestUtils.MockUser mockUser = TestUtils.TestUtils.GetMockUser(null, USER_MSP_ID);

            client.UserContext = mockUser;
        }
Exemplo n.º 3
0
        public void TestBadEnrollmentNull()
        {
            HFClient client = HFClient.Create();

            client.CryptoSuite = Factory.Instance.GetCryptoSuite();


            TestUtils.TestUtils.MockUser mockUser = TestUtils.TestUtils.GetMockUser(USER_NAME, USER_MSP_ID);
            mockUser.Enrollment = null;
            client.UserContext  = mockUser;
        }
Exemplo n.º 4
0
        public void TestBadUserMSPIDNull()
        {
            HFClient client = HFClient.Create();

            client.CryptoSuite = Factory.Instance.GetCryptoSuite();


            TestUtils.TestUtils.MockUser mockUser = TestUtils.TestUtils.GetMockUser(USER_NAME, null);

            client.UserContext = mockUser;
        }
Exemplo n.º 5
0
        public void TestBadEnrollmentBadKey()
        {
            HFClient client = HFClient.Create();

            client.CryptoSuite = Factory.Instance.GetCryptoSuite();



            TestUtils.TestUtils.MockUser mockUser = TestUtils.TestUtils.GetMockUser(USER_NAME, USER_MSP_ID);

            IEnrollment mockEnrollment = TestUtils.TestUtils.GetMockEnrollment(null, "mockCert");

            mockUser.Enrollment = mockEnrollment;
            client.UserContext  = mockUser;
        }
Exemplo n.º 6
0
        public void TestCryptoFactory()
        {
            TestUtils.TestUtils.ResetConfig();
            Assert.IsNotNull(Config.Instance.GetDefaultCryptoSuiteFactory());

            HFClient client = HFClient.Create();

            client.CryptoSuite = Factory.Instance.GetCryptoSuite();


            TestUtils.TestUtils.MockUser mockUser = TestUtils.TestUtils.GetMockUser(USER_NAME, USER_MSP_ID);

            IEnrollment mockEnrollment = TestUtils.TestUtils.GetMockEnrollment(null, "mockCert");

            mockUser.Enrollment = mockEnrollment;
            client.UserContext  = mockUser;
        }