Skip to content

Commit

Permalink
Tidy up business network unit test example code (hyperledger-archives…
Browse files Browse the repository at this point in the history
…#2084)

Signed-off-by: Mark S. Lewis <[email protected]>
  • Loading branch information
bestbeforetoday authored Sep 7, 2017
1 parent 41dfa2a commit 02ff3fb
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions packages/composer-website/jekylldocs/tutorials/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,33 +309,31 @@ describe('Commodity Trading', () => {
commodity.owner.$identifier.should.equal(dan.$identifier);

// Get the asset registry.
let commodityRegistry;
return businessNetworkConnection.getAssetRegistry(NS + '.Commodity')
.then((assetRegistry) => {

commodityRegistry = assetRegistry;
// add the commodity to the asset registry.
return assetRegistry.add(commodity)
.then(() => {
return businessNetworkConnection.getParticipantRegistry(NS + '.Trader');
})
.then((participantRegistry) => {
// add the traders
return participantRegistry.addAll([dan, simon]);
})
.then(() => {
// submit the transaction
return businessNetworkConnection.submitTransaction(trade);
})
.then(() => {
return businessNetworkConnection.getAssetRegistry(NS + '.Commodity');
})
.then((assetRegistry) => {
// re-get the commodity
return assetRegistry.get(commodity.$identifier);
})
.then((newCommodity) => {
// the owner of the commodity should not be simon
newCommodity.owner.$identifier.should.equal(simon.$identifier);
});
return commodityRegistry.add(commodity);
})
.then(() => {
return businessNetworkConnection.getParticipantRegistry(NS + '.Trader');
})
.then((participantRegistry) => {
// add the traders
return participantRegistry.addAll([dan, simon]);
})
.then(() => {
// submit the transaction
return businessNetworkConnection.submitTransaction(trade);
})
.then(() => {
// re-get the commodity
return commodityRegistry.get(commodity.$identifier);
})
.then((newCommodity) => {
// the owner of the commodity should now be simon
newCommodity.owner.$identifier.should.equal(simon.$identifier);
});
});
});
Expand Down

0 comments on commit 02ff3fb

Please sign in to comment.