DOC: improved code comments

This commit is contained in:
Frederic Fortier
2018-01-11 14:08:02 -05:00
parent 50ded59c3c
commit 9361570895
2 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ pragma solidity ^0.4.17;
contract Marketplace {
address[16] public subscribers;
// Adopting a pet
// Subscribing to a data source
function subscribe(uint dataSourceId) public returns (uint) {
require(dataSourceId >= 0 && dataSourceId <= 15);
+8 -8
View File
@@ -7,7 +7,7 @@ import "../contracts/Marketplace.sol";
contract TestMarketplace {
Marketplace marketplace = Marketplace(DeployedAddresses.Marketplace());
// Testing the adopt() function
// Testing the subscribe() function
function testUserCanSubscribe() public {
uint returnedId = marketplace.subscribe(2);
@@ -16,24 +16,24 @@ contract TestMarketplace {
Assert.equal(returnedId, expected, "Adoption of pet ID 8 should be recorded.");
}
// Testing retrieval of a single pet's owner
// Testing retrieval of a single subscriber
function testGetSubscriberAddressByDataSourceId() public {
// Expected owner is this contract
address expected = this;
address adopter = marketplace.subscribers(2);
address subscriber = marketplace.subscribers(2);
Assert.equal(adopter, expected, "Owner of data source ID 0 should be recorded.");
Assert.equal(subscriber, expected, "Owner of data source ID 0 should be recorded.");
}
// Testing retrieval of all pet owners
// Testing retrieval of all subscribers
function testGetSubscriberAddressByDataSourceIdInArray() public {
// Expected owner is this contract
// Expected subscriber is this contract
address expected = this;
// Store adopters in memory rather than contract's storage
// Store subscribers in memory rather than contract's storage
address[16] memory subscribers = marketplace.getSubscribers();
Assert.equal(subscribers[2], expected, "Owner of pet ID 2 should be recorded.");
Assert.equal(subscribers[2], expected, "Subscriber of data source 2 should be recorded.");
}
}