``` const CalcHistory = artifacts.require("CalcHistory"); contract("CalcHistory", accounts => { it("sum 1 + 2 == 3", async () => { let instance = await CalcHistory.deployed(); let result = await instance.sum.call(1, 2); assert.equal(result.valueOf(), 3, "1 + 2 == 3"); }); }); ``` ``` const CalcHistory = artifacts.require("CalcHistory"); module.exports = function (deployer) { deployer.deploy(CalcHistory); }; ``` ``` pragma solidity >=0.4.25 <0.6.0; import "truffle/Assert.sol"; import "truffle/DeployedAddresses.sol"; import "../contracts/CalcHistory.sol"; contract TestCalcHistory { function test1plus2() public { CalcHistory calc = CalcHistory(DeployedAddresses.CalcHistory()); uint expected = 3; Assert.equal(calc.sum(1, 2), expected, "1 + 2 == 3"); } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up