use of org.hyperledger.fabric.sdk.transaction.InstallProposalBuilder in project fabric-sdk-java by hyperledger.
the class ChannelTest method testProposalBuilderWithOutMetaInf.
@Test
public void testProposalBuilderWithOutMetaInf() throws Exception {
InstallProposalBuilder installProposalBuilder = InstallProposalBuilder.newBuilder();
installProposalBuilder.setChaincodeLanguage(TransactionRequest.Type.GO_LANG);
installProposalBuilder.chaincodePath("github.com/example_cc");
installProposalBuilder.setChaincodeSource(new File(SAMPLE_GO_CC));
installProposalBuilder.chaincodeName("example_cc.go");
installProposalBuilder.chaincodeVersion("1");
Channel channel = hfclient.newChannel("testProposalBuilderWithOutMetaInf");
TransactionContext transactionContext = new TransactionContext(channel, getMockUser("rick", "rickORG"), CryptoSuite.Factory.getCryptoSuite());
installProposalBuilder.context(transactionContext);
// Build it get the proposal. Then unpack it to see if it's what we expect.
FabricProposal.Proposal proposal = installProposalBuilder.build();
FabricProposal.ChaincodeProposalPayload chaincodeProposalPayload = FabricProposal.ChaincodeProposalPayload.parseFrom(proposal.getPayload());
Chaincode.ChaincodeInvocationSpec chaincodeInvocationSpec = Chaincode.ChaincodeInvocationSpec.parseFrom(chaincodeProposalPayload.getInput());
Chaincode.ChaincodeSpec chaincodeSpec = chaincodeInvocationSpec.getChaincodeSpec();
Chaincode.ChaincodeInput input = chaincodeSpec.getInput();
Chaincode.ChaincodeDeploymentSpec chaincodeDeploymentSpec = Chaincode.ChaincodeDeploymentSpec.parseFrom(input.getArgs(1));
ByteString codePackage = chaincodeDeploymentSpec.getCodePackage();
ArrayList tarBytesToEntryArrayList = tarBytesToEntryArrayList(codePackage.toByteArray());
ArrayList<String> expect = new ArrayList(Arrays.asList(new String[] { "src/github.com/example_cc/example_cc.go" }));
assertArrayListEquals("Tar in Install Proposal's codePackage does not have expected entries. ", expect, tarBytesToEntryArrayList);
}
use of org.hyperledger.fabric.sdk.transaction.InstallProposalBuilder in project fabric-sdk-java by hyperledger.
the class ChannelTest method testProposalBuilderWithMetaInf.
@Test
public void testProposalBuilderWithMetaInf() throws Exception {
InstallProposalBuilder installProposalBuilder = InstallProposalBuilder.newBuilder();
installProposalBuilder.setChaincodeLanguage(TransactionRequest.Type.GO_LANG);
installProposalBuilder.chaincodePath("github.com/example_cc");
installProposalBuilder.setChaincodeSource(new File(SAMPLE_GO_CC));
installProposalBuilder.chaincodeName("example_cc.go");
installProposalBuilder.setChaincodeMetaInfLocation(new File("src/test/fixture/meta-infs/test1"));
installProposalBuilder.chaincodeVersion("1");
Channel channel = hfclient.newChannel("testProposalBuilderWithMetaInf");
TestUtils.MockUser mockUser = getMockUser("rick", "rickORG");
TransactionContext transactionContext = new TransactionContext(channel, mockUser, CryptoSuite.Factory.getCryptoSuite());
installProposalBuilder.context(transactionContext);
// Build it get the proposal. Then unpack it to see if it's what we expect.
FabricProposal.Proposal proposal = installProposalBuilder.build();
FabricProposal.ChaincodeProposalPayload chaincodeProposalPayload = FabricProposal.ChaincodeProposalPayload.parseFrom(proposal.getPayload());
Chaincode.ChaincodeInvocationSpec chaincodeInvocationSpec = Chaincode.ChaincodeInvocationSpec.parseFrom(chaincodeProposalPayload.getInput());
Chaincode.ChaincodeSpec chaincodeSpec = chaincodeInvocationSpec.getChaincodeSpec();
Chaincode.ChaincodeInput input = chaincodeSpec.getInput();
Chaincode.ChaincodeDeploymentSpec chaincodeDeploymentSpec = Chaincode.ChaincodeDeploymentSpec.parseFrom(input.getArgs(1));
ByteString codePackage = chaincodeDeploymentSpec.getCodePackage();
ArrayList tarBytesToEntryArrayList = tarBytesToEntryArrayList(codePackage.toByteArray());
ArrayList<String> expect = new ArrayList(Arrays.asList(new String[] { "META-INF/statedb/couchdb/indexes/MockFakeIndex.json", "src/github.com/example_cc/example_cc.go" }));
assertArrayListEquals("Tar in Install Proposal's codePackage does not have expected entries. ", expect, tarBytesToEntryArrayList);
}
use of org.hyperledger.fabric.sdk.transaction.InstallProposalBuilder in project fabric-sdk-java by hyperledger.
the class ChannelTest method testProposalBuilderWithMetaInfEmpty.
@Test
public void testProposalBuilderWithMetaInfEmpty() throws Exception {
thrown.expect(java.lang.IllegalArgumentException.class);
thrown.expectMessage(matchesRegex("The META-INF directory.*src.test.fixture.meta-infs.emptyMetaInf.META-INF is empty\\."));
// make it cause git won't check in empty directory
File emptyINF = new File("src/test/fixture/meta-infs/emptyMetaInf/META-INF");
if (!emptyINF.exists()) {
emptyINF.mkdirs();
emptyINF.deleteOnExit();
}
InstallProposalBuilder installProposalBuilder = InstallProposalBuilder.newBuilder();
installProposalBuilder.setChaincodeLanguage(TransactionRequest.Type.GO_LANG);
installProposalBuilder.chaincodePath("github.com/example_cc");
installProposalBuilder.setChaincodeSource(new File(SAMPLE_GO_CC));
installProposalBuilder.chaincodeName("example_cc.go");
installProposalBuilder.chaincodeVersion("1");
// points into which is not what's expected.
installProposalBuilder.setChaincodeMetaInfLocation(new File("src/test/fixture/meta-infs/emptyMetaInf"));
Channel channel = hfclient.newChannel("testProposalBuilderWithMetaInfEmpty");
TransactionContext transactionContext = new TransactionContext(channel, getMockUser("rick", "rickORG"), CryptoSuite.Factory.getCryptoSuite());
installProposalBuilder.context(transactionContext);
// Build it get the proposal. Then unpack it to see if it's what we epect.
FabricProposal.Proposal proposal = installProposalBuilder.build();
}
use of org.hyperledger.fabric.sdk.transaction.InstallProposalBuilder in project fabric-sdk-java by hyperledger.
the class ChannelTest method testProposalBuilderWithMetaInfExistsNOT.
@Test
public void testProposalBuilderWithMetaInfExistsNOT() throws Exception {
thrown.expect(java.lang.IllegalArgumentException.class);
thrown.expectMessage(matchesRegex("Directory to find chaincode META-INF.*tmp.fdsjfksfj.fjksfjskd.fjskfjdsk.should never exist does not exist"));
InstallProposalBuilder installProposalBuilder = InstallProposalBuilder.newBuilder();
installProposalBuilder.setChaincodeLanguage(TransactionRequest.Type.GO_LANG);
installProposalBuilder.chaincodePath("github.com/example_cc");
installProposalBuilder.setChaincodeSource(new File(SAMPLE_GO_CC));
installProposalBuilder.chaincodeName("example_cc.go");
installProposalBuilder.chaincodeVersion("1");
// points into which is not what's expected.
installProposalBuilder.setChaincodeMetaInfLocation(new File("/tmp/fdsjfksfj/fjksfjskd/fjskfjdsk/should never exist"));
Channel channel = hfclient.newChannel("testProposalBuilderWithMetaInfExistsNOT");
TransactionContext transactionContext = new TransactionContext(channel, getMockUser("rick", "rickORG"), CryptoSuite.Factory.getCryptoSuite());
installProposalBuilder.context(transactionContext);
// Build it get the proposal. Then unpack it to see if it's what we epect.
installProposalBuilder.build();
}
use of org.hyperledger.fabric.sdk.transaction.InstallProposalBuilder in project fabric-sdk-java by hyperledger.
the class ChannelTest method testProposalBuilderWithNoMetaInfDir.
@Test
public void testProposalBuilderWithNoMetaInfDir() throws Exception {
thrown.expect(java.lang.IllegalArgumentException.class);
thrown.expectMessage(matchesRegex("The META-INF directory does not exist in.*src.test.fixture.meta-infs.test1.META-INF"));
InstallProposalBuilder installProposalBuilder = InstallProposalBuilder.newBuilder();
installProposalBuilder.setChaincodeLanguage(TransactionRequest.Type.GO_LANG);
installProposalBuilder.chaincodePath("github.com/example_cc");
installProposalBuilder.setChaincodeSource(new File(SAMPLE_GO_CC));
installProposalBuilder.chaincodeName("example_cc.go");
installProposalBuilder.chaincodeVersion("1");
// points into which is not what's expected.
installProposalBuilder.setChaincodeMetaInfLocation(new File("src/test/fixture/meta-infs/test1/META-INF"));
Channel channel = hfclient.newChannel("testProposalBuilderWithNoMetaInfDir");
TransactionContext transactionContext = new TransactionContext(channel, getMockUser("rick", "rickORG"), CryptoSuite.Factory.getCryptoSuite());
installProposalBuilder.context(transactionContext);
// Build it get the proposal. Then unpack it to see if it's what we epect.
installProposalBuilder.build();
}
Aggregations