Commit a8348b3e by Manuel Aráoz Committed by GitHub

Merge pull request #20 from adklempner/sol-testing

Recreate tests for Ownable in Solidity
parents 4fc0d99b e012a270
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/Ownable.sol";
contract TestOwnable {
Ownable ownable = new Ownable();
function testHasOwner() {
Assert.isNotZero(ownable.owner(), "Ownable should have an owner upon creation.");
}
function testChangesOwner() {
address originalOwner = ownable.owner();
ownable.transfer(0x0);
Assert.notEqual(originalOwner, ownable.owner(), "Ownable should change owners after transfer.");
}
function testOnlyOwnerCanChangeOwner() {
Ownable deployedOwnable = Ownable(DeployedAddresses.Ownable());
address originalOwner = deployedOwnable.owner();
deployedOwnable.transfer(0x0);
Assert.equal(originalOwner, deployedOwnable.owner(), "Ownable should prevent non-owners from transfering");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment