This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// contracts/Funding.sol | |
pragma solidity ^0.4.17; | |
contract Funding { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// contracts/FundingTest.sol | |
pragma solidity ^0.4.17; | |
import "truffle/Assert.sol"; | |
import "../contracts/Funding.sol"; | |
contract FundingTest { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./node_modules/.bin/truffle test | |
Compiling ./contracts/Funding.sol... | |
Compiling ./contracts/Migrations.sol... | |
Compiling ./test/FundingTest.sol... | |
Compiling truffle/Assert.sol... | |
0 passing (0ms) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract FundingTest { | |
function testSettingAnOwnerDuringCreation() public { | |
Funding funding = new Funding(); | |
Assert.equal(funding.owner(), this); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract Funding { | |
address public owner; | |
function Funding() public { | |
owner = msg.sender; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FundingTest | |
✓ testSettingAnOwnerDuringCreation (64ms) | |
1 passing (408ms) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// test/FundingTest.js | |
const Funding = artifacts.require("Funding"); | |
contract("Funding", accounts => { | |
const [firstAccount] = accounts; | |
it("sets an owner", async () => { | |
const funding = await Funding.new(); | |
assert.equal(await funding.owner.call(), firstAccount); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FundingTest | |
✓ testSettingAnOwnerDuringCreation (66ms) | |
Contract: Funding | |
✓ sets an owner (68ms) | |
2 passing (551ms) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "truffle/DeployedAddresses.sol"; | |
contract FundingTest { | |
function testSettingAnOwnerOfDeployedContract() public { | |
Funding funding = Funding(DeployedAddresses.Funding()); | |
Assert.equal(funding.owner(), msg.sender); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// migrations/2_funding.js | |
const Funding = artifacts.require("./Funding.sol"); | |
module.exports = function(deployer) { | |
deployer.deploy(Funding); | |
}; |
OlderNewer