use of org.hyperledger.fabric.sdk.Channel in project fabric-sdk-java by hyperledger.
the class TransactionContextTest method createTestContext.
// ==========================================================================================
// Helper methods
// ==========================================================================================
private TransactionContext createTestContext() {
Channel channel = createTestChannel("channel1");
User user = hfclient.getUserContext();
CryptoSuite cryptoSuite = hfclient.getCryptoSuite();
return new TransactionContext(channel, user, cryptoSuite);
}
use of org.hyperledger.fabric.sdk.Channel in project fabric-sdk-java by hyperledger.
the class End2endAndBackAgainIT method runFabricTest.
public void runFabricTest(final SampleStore sampleStore) throws Exception {
// //////////////////////////
// Setup client
// Create instance of client.
HFClient client = HFClient.createNewInstance();
client.setCryptoSuite(CryptoSuite.Factory.getCryptoSuite());
// //////////////////////////
// Reconstruct and run the channels
SampleOrg sampleOrg = testConfig.getIntegrationTestsSampleOrg("peerOrg1");
Channel fooChannel = reconstructChannel(FOO_CHANNEL_NAME, client, sampleOrg);
runChannel(client, fooChannel, sampleOrg, 0);
assertFalse(fooChannel.isShutdown());
assertTrue(fooChannel.isInitialized());
// clean up resources no longer needed.
fooChannel.shutdown(true);
assertTrue(fooChannel.isShutdown());
out("\n");
sampleOrg = testConfig.getIntegrationTestsSampleOrg("peerOrg2");
Channel barChannel = reconstructChannel(BAR_CHANNEL_NAME, client, sampleOrg);
// run a newly constructed foo channel with different b value!
runChannel(client, barChannel, sampleOrg, 100);
assertFalse(barChannel.isShutdown());
assertTrue(barChannel.isInitialized());
if (!testConfig.isRunningAgainstFabric10()) {
// Peer eventing service support started with v1.1
// Now test replay feature of V1.1 peer eventing services.
byte[] replayChannelBytes = barChannel.serializeChannel();
barChannel.shutdown(true);
Channel replayChannel = client.deSerializeChannel(replayChannelBytes);
out("doing testPeerServiceEventingReplay,0,-1,false");
testPeerServiceEventingReplay(client, replayChannel, 0L, -1L, false);
replayChannel = client.deSerializeChannel(replayChannelBytes);
// block 0 is import to test
out("doing testPeerServiceEventingReplay,0,-1,true");
testPeerServiceEventingReplay(client, replayChannel, 0L, -1L, true);
// Now do it again starting at block 1
replayChannel = client.deSerializeChannel(replayChannelBytes);
out("doing testPeerServiceEventingReplay,1,-1,false");
testPeerServiceEventingReplay(client, replayChannel, 1L, -1L, false);
// Now do it again starting at block 2 to 3
replayChannel = client.deSerializeChannel(replayChannelBytes);
out("doing testPeerServiceEventingReplay,2,3,false");
testPeerServiceEventingReplay(client, replayChannel, 2L, 3L, false);
}
out("That's all folks!");
}
use of org.hyperledger.fabric.sdk.Channel in project fabric-sdk-java by hyperledger.
the class End2endAndBackAgainIT method reconstructChannel.
private Channel reconstructChannel(String name, HFClient client, SampleOrg sampleOrg) throws Exception {
out("Reconstructing %s channel", name);
client.setUserContext(sampleOrg.getUser(TESTUSER_1_NAME));
Channel newChannel;
if (BAR_CHANNEL_NAME.equals(name)) {
// bar channel was stored in samplestore in End2endIT testcase.
/**
* sampleStore.getChannel uses {@link HFClient#deSerializeChannel(byte[])}
*/
newChannel = sampleStore.getChannel(client, name);
if (!IS_FABRIC_V10) {
// Make sure there is one of each type peer at the very least. see End2end for how peers were constructed.
assertFalse(newChannel.getPeers(EnumSet.of(PeerRole.EVENT_SOURCE)).isEmpty());
assertFalse(newChannel.getPeers(PeerRole.NO_EVENT_SOURCE).isEmpty());
}
assertEquals(2, newChannel.getEventHubs().size());
out("Retrieved channel %s from sample store.", name);
} else {
// foo channel do manual reconstruction.
Properties clientTLSProperties = new Properties();
final String clientPEMTLSCertificate = sampleStore.getClientPEMTLSCertificate(sampleOrg);
if (clientPEMTLSCertificate != null) {
clientTLSProperties.put("clientCertBytes", clientPEMTLSCertificate.getBytes(UTF_8));
}
final String clientPEMTLSKey = sampleStore.getClientPEMTLSKey(sampleOrg);
if (clientPEMTLSKey != null) {
clientTLSProperties.put("clientKeyBytes", clientPEMTLSKey.getBytes(UTF_8));
}
newChannel = client.newChannel(name);
for (String ordererName : sampleOrg.getOrdererNames()) {
Properties ordererProperties = (Properties) clientTLSProperties.clone();
ordererProperties.putAll(testConfig.getOrdererProperties(ordererName));
newChannel.addOrderer(client.newOrderer(ordererName, sampleOrg.getOrdererLocation(ordererName), ordererProperties));
}
boolean everyOther = false;
for (String peerName : sampleOrg.getPeerNames()) {
String peerLocation = sampleOrg.getPeerLocation(peerName);
Properties peerProperties = testConfig.getPeerProperties(peerName);
peerProperties.putAll(clientTLSProperties);
Peer peer = client.newPeer(peerName, peerLocation, peerProperties);
final // we have two peers on one use block on other use filtered
PeerOptions peerEventingOptions = everyOther ? createPeerOptions().registerEventsForBlocks() : createPeerOptions().registerEventsForFilteredBlocks();
newChannel.addPeer(peer, IS_FABRIC_V10 ? createPeerOptions().setPeerRoles(PeerRole.NO_EVENT_SOURCE) : peerEventingOptions);
everyOther = !everyOther;
}
// For testing mix it up. For v1.1 use just peer eventing service for foo channel.
if (IS_FABRIC_V10) {
// Should have no peers with event sources.
assertTrue(newChannel.getPeers(EnumSet.of(PeerRole.EVENT_SOURCE)).isEmpty());
// Should have two peers with all roles but event source.
assertEquals(2, newChannel.getPeers(PeerRole.NO_EVENT_SOURCE).size());
for (String eventHubName : sampleOrg.getEventHubNames()) {
Properties eventhubProperties = (Properties) clientTLSProperties.clone();
eventhubProperties.putAll(testConfig.getEventHubProperties(eventHubName));
EventHub eventHub = client.newEventHub(eventHubName, sampleOrg.getEventHubLocation(eventHubName), eventhubProperties);
newChannel.addEventHub(eventHub);
}
} else {
// Peers should have all roles. Do some sanity checks that they do.
// Should have two peers with event sources.
assertEquals(2, newChannel.getPeers(EnumSet.of(PeerRole.EVENT_SOURCE)).size());
// Check some other roles too..
assertEquals(2, newChannel.getPeers(EnumSet.of(PeerRole.CHAINCODE_QUERY, PeerRole.LEDGER_QUERY)).size());
// really same as newChannel.getPeers()
assertEquals(2, newChannel.getPeers(PeerRole.ALL).size());
}
assertEquals(IS_FABRIC_V10 ? sampleOrg.getEventHubNames().size() : 0, newChannel.getEventHubs().size());
}
// Just some sanity check tests
assertTrue(newChannel == client.getChannel(name));
assertTrue(client == TestUtils.getField(newChannel, "client"));
assertEquals(name, newChannel.getName());
assertEquals(2, newChannel.getPeers().size());
assertEquals(1, newChannel.getOrderers().size());
assertFalse(newChannel.isShutdown());
assertFalse(newChannel.isInitialized());
byte[] serializedChannelBytes = newChannel.serializeChannel();
// Just checks if channel can be serialized and deserialized .. otherwise this is just a waste :)
// Get channel back.
newChannel.shutdown(true);
newChannel = client.deSerializeChannel(serializedChannelBytes);
assertEquals(2, newChannel.getPeers().size());
assertEquals(1, newChannel.getOrderers().size());
assertNotNull(client.getChannel(name));
assertEquals(newChannel, client.getChannel(name));
assertFalse(newChannel.isInitialized());
assertFalse(newChannel.isShutdown());
assertEquals(TESTUSER_1_NAME, client.getUserContext().getName());
newChannel.initialize();
assertTrue(newChannel.isInitialized());
assertFalse(newChannel.isShutdown());
// Query the actual peer for which channels it belongs to and check it belongs to this channel
for (Peer peer : newChannel.getPeers()) {
Set<String> channels = client.queryChannels(peer);
if (!channels.contains(name)) {
throw new AssertionError(format("Peer %s does not appear to belong to channel %s", peer.getName(), name));
}
}
// Just see if we can get channelConfiguration. Not required for the rest of scenario but should work.
final byte[] channelConfigurationBytes = newChannel.getChannelConfigurationBytes();
Configtx.Config channelConfig = Configtx.Config.parseFrom(channelConfigurationBytes);
assertNotNull(channelConfig);
Configtx.ConfigGroup channelGroup = channelConfig.getChannelGroup();
assertNotNull(channelGroup);
Map<String, Configtx.ConfigGroup> groupsMap = channelGroup.getGroupsMap();
assertNotNull(groupsMap.get("Orderer"));
assertNotNull(groupsMap.get("Application"));
// Before return lets see if we have the chaincode on the peers that we expect from End2endIT
// And if they were instantiated too. this requires peer admin user
client.setUserContext(sampleOrg.getPeerAdmin());
for (Peer peer : newChannel.getPeers()) {
if (!checkInstalledChaincode(client, peer, CHAIN_CODE_NAME, CHAIN_CODE_PATH, CHAIN_CODE_VERSION)) {
throw new AssertionError(format("Peer %s is missing chaincode name: %s, path:%s, version: %s", peer.getName(), CHAIN_CODE_NAME, CHAIN_CODE_PATH, CHAIN_CODE_PATH));
}
if (!checkInstantiatedChaincode(newChannel, peer, CHAIN_CODE_NAME, CHAIN_CODE_PATH, CHAIN_CODE_VERSION)) {
throw new AssertionError(format("Peer %s is missing instantiated chaincode name: %s, path:%s, version: %s", peer.getName(), CHAIN_CODE_NAME, CHAIN_CODE_PATH, CHAIN_CODE_PATH));
}
}
client.setUserContext(sampleOrg.getUser(TESTUSER_1_NAME));
assertTrue(newChannel.isInitialized());
assertFalse(newChannel.isShutdown());
out("Finished reconstructing channel %s.", name);
return newChannel;
}
use of org.hyperledger.fabric.sdk.Channel in project fabric-sdk-java by hyperledger.
the class UpdateChannelIT method setup.
@Test
public void setup() {
try {
// //////////////////////////
// Setup client
// Create instance of client.
HFClient client = HFClient.createNewInstance();
client.setCryptoSuite(CryptoSuite.Factory.getCryptoSuite());
// //////////////////////////
// Set up USERS
// Persistence is not part of SDK. Sample file store is for demonstration purposes only!
// MUST be replaced with more robust application implementation (Database, LDAP)
File sampleStoreFile = new File(System.getProperty("java.io.tmpdir") + "/HFCSampletest.properties");
sampleStoreFile.deleteOnExit();
final SampleStore sampleStore = new SampleStore(sampleStoreFile);
for (SampleOrg sampleOrg : testSampleOrgs) {
final String orgName = sampleOrg.getName();
sampleOrg.setPeerAdmin(sampleStore.getMember(orgName + "Admin", orgName));
}
// //////////////////////////
// Reconstruct and run the channels
SampleOrg sampleOrg = testConfig.getIntegrationTestsSampleOrg("peerOrg1");
Channel fooChannel = reconstructChannel(FOO_CHANNEL_NAME, client, sampleOrg);
// Getting foo channels current configuration bytes.
final byte[] channelConfigurationBytes = fooChannel.getChannelConfigurationBytes();
HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(CONFIGTXLATOR_LOCATION + "/protolator/decode/common.Config");
httppost.setEntity(new ByteArrayEntity(channelConfigurationBytes));
HttpResponse response = httpclient.execute(httppost);
int statuscode = response.getStatusLine().getStatusCode();
out("Got %s status for decoding current channel config bytes", statuscode);
assertEquals(200, statuscode);
String responseAsString = EntityUtils.toString(response.getEntity());
if (!responseAsString.contains(ORIGINAL_BATCH_TIMEOUT)) {
fail(format("Did not find expected batch timeout '%s', in:%s", ORIGINAL_BATCH_TIMEOUT, responseAsString));
}
// Now modify the batch timeout
String updateString = responseAsString.replace(ORIGINAL_BATCH_TIMEOUT, UPDATED_BATCH_TIMEOUT);
httppost = new HttpPost(CONFIGTXLATOR_LOCATION + "/protolator/encode/common.Config");
httppost.setEntity(new StringEntity(updateString));
response = httpclient.execute(httppost);
statuscode = response.getStatusLine().getStatusCode();
out("Got %s status for encoding the new desired channel config bytes", statuscode);
assertEquals(200, statuscode);
byte[] newConfigBytes = EntityUtils.toByteArray(response.getEntity());
// Now send to configtxlator multipart form post with original config bytes, updated config bytes and channel name.
httppost = new HttpPost(CONFIGTXLATOR_LOCATION + "/configtxlator/compute/update-from-configs");
HttpEntity multipartEntity = MultipartEntityBuilder.create().setMode(HttpMultipartMode.BROWSER_COMPATIBLE).addBinaryBody("original", channelConfigurationBytes, ContentType.APPLICATION_OCTET_STREAM, "originalFakeFilename").addBinaryBody("updated", newConfigBytes, ContentType.APPLICATION_OCTET_STREAM, "updatedFakeFilename").addBinaryBody("channel", fooChannel.getName().getBytes()).build();
httppost.setEntity(multipartEntity);
response = httpclient.execute(httppost);
statuscode = response.getStatusLine().getStatusCode();
out("Got %s status for updated config bytes needed for updateChannelConfiguration ", statuscode);
assertEquals(200, statuscode);
byte[] updateBytes = EntityUtils.toByteArray(response.getEntity());
UpdateChannelConfiguration updateChannelConfiguration = new UpdateChannelConfiguration(updateBytes);
// To change the channel we need to sign with orderer admin certs which crypto gen stores:
// private key: src/test/fixture/sdkintegration/e2e-2Orgs/channel/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/keystore/f1a9a940f57419a18a83a852884790d59b378281347dd3d4a88c2b820a0f70c9_sk
// certificate: src/test/fixture/sdkintegration/e2e-2Orgs/channel/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/signcerts/Admin@example.com-cert.pem
final String sampleOrgName = sampleOrg.getName();
final SampleUser ordererAdmin = sampleStore.getMember(sampleOrgName + "OrderAdmin", sampleOrgName, "OrdererMSP", Util.findFileSk(Paths.get("src/test/fixture/sdkintegration/e2e-2Orgs/" + TestConfig.FAB_CONFIG_GEN_VERS + "/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/keystore/").toFile()), Paths.get("src/test/fixture/sdkintegration/e2e-2Orgs/" + TestConfig.FAB_CONFIG_GEN_VERS + "/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp/signcerts/Admin@example.com-cert.pem").toFile());
client.setUserContext(ordererAdmin);
// Ok now do actual channel update.
fooChannel.updateChannelConfiguration(updateChannelConfiguration, client.getUpdateChannelConfigurationSignature(updateChannelConfiguration, ordererAdmin));
// Let's add some additional verification...
client.setUserContext(sampleOrg.getPeerAdmin());
final byte[] modChannelBytes = fooChannel.getChannelConfigurationBytes();
// Now decode the new channel config bytes to json...
httppost = new HttpPost(CONFIGTXLATOR_LOCATION + "/protolator/decode/common.Config");
httppost.setEntity(new ByteArrayEntity(modChannelBytes));
response = httpclient.execute(httppost);
statuscode = response.getStatusLine().getStatusCode();
assertEquals(200, statuscode);
responseAsString = EntityUtils.toString(response.getEntity());
if (!responseAsString.contains(UPDATED_BATCH_TIMEOUT)) {
// If it doesn't have the updated time out it failed.
fail(format("Did not find updated expected batch timeout '%s', in:%s", UPDATED_BATCH_TIMEOUT, responseAsString));
}
if (responseAsString.contains(ORIGINAL_BATCH_TIMEOUT)) {
// Should not have been there anymore!
fail(format("Found original batch timeout '%s', when it was not expected in:%s", ORIGINAL_BATCH_TIMEOUT, responseAsString));
}
out("\n");
out("That's all folks!");
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.hyperledger.fabric.sdk.Channel in project fabric-sdk-java by hyperledger.
the class End2endAndBackAgainIT method runChannel.
// Disable MethodLength as this method is for instructional purposes and hence
// we don't want to split it into smaller pieces
// CHECKSTYLE:OFF: MethodLength
void runChannel(HFClient client, Channel channel, SampleOrg sampleOrg, final int delta) {
final String channelName = channel.getName();
try {
client.setUserContext(sampleOrg.getUser(TESTUSER_1_NAME));
// final boolean changeContext = false; // BAR_CHANNEL_NAME.equals(channel.getName()) ? true : false;
final boolean changeContext = BAR_CHANNEL_NAME.equals(channel.getName());
out("Running Channel %s with a delta %d", channelName, delta);
out("ChaincodeID: ", chaincodeID);
// //////////////////////////
// Send Query Proposal to all peers see if it's what we expect from end of End2endIT
//
queryChaincodeForExpectedValue(client, channel, "" + (300 + delta), chaincodeID);
// Set user context on client but use explicit user contest on each call.
if (changeContext) {
client.setUserContext(sampleOrg.getUser(TESTUSER_1_NAME));
}
// exercise v1 of chaincode
moveAmount(client, channel, chaincodeID, "25", changeContext ? sampleOrg.getPeerAdmin() : null).thenApply((BlockEvent.TransactionEvent transactionEvent) -> {
try {
waitOnFabric();
client.setUserContext(sampleOrg.getUser(TESTUSER_1_NAME));
queryChaincodeForExpectedValue(client, channel, "" + (325 + delta), chaincodeID);
// ////////////////
// Start of upgrade first must install it.
client.setUserContext(sampleOrg.getPeerAdmin());
// /////////////
// //
InstallProposalRequest installProposalRequest = client.newInstallProposalRequest();
installProposalRequest.setChaincodeID(chaincodeID);
// //For GO language and serving just a single user, chaincodeSource is mostly likely the users GOPATH
installProposalRequest.setChaincodeSourceLocation(Paths.get(TEST_FIXTURES_PATH, CHAIN_CODE_FILEPATH).toFile());
installProposalRequest.setChaincodeVersion(CHAIN_CODE_VERSION_11);
installProposalRequest.setProposalWaitTime(testConfig.getProposalWaitTime());
installProposalRequest.setChaincodeLanguage(CHAIN_CODE_LANG);
if (changeContext) {
installProposalRequest.setUserContext(sampleOrg.getPeerAdmin());
}
out("Sending install proposal for channel: %s", channel.getName());
// //////////////////////////
// only a client from the same org as the peer can issue an install request
int numInstallProposal = 0;
Collection<ProposalResponse> responses;
final Collection<ProposalResponse> successful = new LinkedList<>();
final Collection<ProposalResponse> failed = new LinkedList<>();
Collection<Peer> peersFromOrg = channel.getPeers();
numInstallProposal = numInstallProposal + peersFromOrg.size();
responses = client.sendInstallProposal(installProposalRequest, peersFromOrg);
for (ProposalResponse response : responses) {
if (response.getStatus() == Status.SUCCESS) {
out("Successful install proposal response Txid: %s from peer %s", response.getTransactionID(), response.getPeer().getName());
successful.add(response);
} else {
failed.add(response);
}
}
out("Received %d install proposal responses. Successful+verified: %d . Failed: %d", numInstallProposal, successful.size(), failed.size());
if (failed.size() > 0) {
ProposalResponse first = failed.iterator().next();
fail("Not enough endorsers for install :" + successful.size() + ". " + first.getMessage());
}
if (changeContext) {
installProposalRequest.setUserContext(sampleOrg.getPeerAdmin());
}
UpgradeProposalRequest upgradeProposalRequest = client.newUpgradeProposalRequest();
upgradeProposalRequest.setChaincodeID(chaincodeID_11);
upgradeProposalRequest.setProposalWaitTime(testConfig.getProposalWaitTime());
upgradeProposalRequest.setFcn("init");
// no arguments don't change the ledger see chaincode.
upgradeProposalRequest.setArgs(new String[] {});
ChaincodeEndorsementPolicy chaincodeEndorsementPolicy;
chaincodeEndorsementPolicy = new ChaincodeEndorsementPolicy();
chaincodeEndorsementPolicy.fromYamlFile(new File(TEST_FIXTURES_PATH + "/sdkintegration/chaincodeendorsementpolicy.yaml"));
upgradeProposalRequest.setChaincodeEndorsementPolicy(chaincodeEndorsementPolicy);
Map<String, byte[]> tmap = new HashMap<>();
tmap.put("test", "data".getBytes());
upgradeProposalRequest.setTransientMap(tmap);
if (changeContext) {
upgradeProposalRequest.setUserContext(sampleOrg.getPeerAdmin());
}
out("Sending upgrade proposal");
Collection<ProposalResponse> responses2;
responses2 = channel.sendUpgradeProposal(upgradeProposalRequest);
successful.clear();
failed.clear();
for (ProposalResponse response : responses2) {
if (response.getStatus() == Status.SUCCESS) {
out("Successful upgrade proposal response Txid: %s from peer %s", response.getTransactionID(), response.getPeer().getName());
successful.add(response);
} else {
failed.add(response);
}
}
out("Received %d upgrade proposal responses. Successful+verified: %d . Failed: %d", channel.getPeers().size(), successful.size(), failed.size());
if (failed.size() > 0) {
ProposalResponse first = failed.iterator().next();
throw new AssertionError("Not enough endorsers for upgrade :" + successful.size() + ". " + first.getMessage());
}
if (changeContext) {
return channel.sendTransaction(successful, sampleOrg.getPeerAdmin()).get(testConfig.getTransactionWaitTime(), TimeUnit.SECONDS);
} else {
return channel.sendTransaction(successful).get(testConfig.getTransactionWaitTime(), TimeUnit.SECONDS);
}
} catch (CompletionException e) {
throw e;
} catch (Exception e) {
throw new CompletionException(e);
}
}).thenApply(transactionEvent -> {
try {
waitOnFabric(10000);
out("Chaincode has been upgraded to version %s", CHAIN_CODE_VERSION_11);
// Check to see if peers have new chaincode and old chaincode is gone.
client.setUserContext(sampleOrg.getPeerAdmin());
for (Peer peer : channel.getPeers()) {
if (!checkInstalledChaincode(client, peer, CHAIN_CODE_NAME, CHAIN_CODE_PATH, CHAIN_CODE_VERSION_11)) {
throw new AssertionError(format("Peer %s is missing chaincode name:%s, path:%s, version: %s", peer.getName(), CHAIN_CODE_NAME, CHAIN_CODE_PATH, CHAIN_CODE_PATH));
}
// should be instantiated too..
if (!checkInstantiatedChaincode(channel, peer, CHAIN_CODE_NAME, CHAIN_CODE_PATH, CHAIN_CODE_VERSION_11)) {
throw new AssertionError(format("Peer %s is missing instantiated chaincode name:%s, path:%s, version: %s", peer.getName(), CHAIN_CODE_NAME, CHAIN_CODE_PATH, CHAIN_CODE_PATH));
}
if (checkInstantiatedChaincode(channel, peer, CHAIN_CODE_NAME, CHAIN_CODE_PATH, CHAIN_CODE_VERSION)) {
throw new AssertionError(format("Peer %s still has old instantiated chaincode name:%s, path:%s, version: %s", peer.getName(), CHAIN_CODE_NAME, CHAIN_CODE_PATH, CHAIN_CODE_PATH));
}
}
client.setUserContext(sampleOrg.getUser(TESTUSER_1_NAME));
// /Check if we still get the same value on the ledger
out("delta is %s", delta);
queryChaincodeForExpectedValue(client, channel, "" + (325 + delta), chaincodeID);
// Now lets run the new chaincode which should *double* the results we asked to move.
return moveAmount(client, channel, chaincodeID_11, "50", changeContext ? sampleOrg.getPeerAdmin() : null).get(testConfig.getTransactionWaitTime(), // really move 100
TimeUnit.SECONDS);
} catch (CompletionException e) {
throw e;
} catch (Exception e) {
throw new CompletionException(e);
}
}).thenApply(transactionEvent -> {
waitOnFabric(10000);
queryChaincodeForExpectedValue(client, channel, "" + (425 + delta), chaincodeID_11);
return null;
}).exceptionally(e -> {
if (e instanceof CompletionException && e.getCause() != null) {
e = e.getCause();
}
if (e instanceof TransactionEventException) {
BlockEvent.TransactionEvent te = ((TransactionEventException) e).getTransactionEvent();
if (te != null) {
e.printStackTrace(System.err);
fail(format("Transaction with txid %s failed. %s", te.getTransactionID(), e.getMessage()));
}
}
e.printStackTrace(System.err);
fail(format("Test failed with %s exception %s", e.getClass().getName(), e.getMessage()));
return null;
}).get(testConfig.getTransactionWaitTime(), TimeUnit.SECONDS);
} catch (Exception e) {
throw new RuntimeException(e);
}
out("Running for Channel %s done", channelName);
}
Aggregations