From 3304c1a738b59a819ad7704ef7fdfa46517c463f Mon Sep 17 00:00:00 2001 From: MrDev023 Date: Thu, 1 Feb 2018 11:52:53 +0100 Subject: [PATCH] Add Unit Test --- .gitignore | 4 +++- Test.eth | 13 ------------- contracts/HelloEthSalon.sol | 13 +++++++++++++ migrations/1_initial_migration.js | 5 +++++ test/hello_eth_salon.js | 9 +++++++++ truffle-config.js | 4 ++++ truffle.js | 10 ++++++++++ 7 files changed, 44 insertions(+), 14 deletions(-) delete mode 100644 Test.eth create mode 100644 contracts/HelloEthSalon.sol create mode 100644 migrations/1_initial_migration.js create mode 100644 test/hello_eth_salon.js create mode 100644 truffle-config.js create mode 100644 truffle.js diff --git a/.gitignore b/.gitignore index 75c6a09..0692de6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ data/* node_modules/* -*.json \ No newline at end of file +*.json +bin/* +build/* \ No newline at end of file diff --git a/Test.eth b/Test.eth deleted file mode 100644 index 08e9d1c..0000000 --- a/Test.eth +++ /dev/null @@ -1,13 +0,0 @@ -pragma solidity ^0.4.18; - -contract Test { - int256 a = 0; - - function set(int256 n) public { - a += n; - } - - function get() public constant returns(int256) { - return a; - } -} \ No newline at end of file diff --git a/contracts/HelloEthSalon.sol b/contracts/HelloEthSalon.sol new file mode 100644 index 0000000..8292d63 --- /dev/null +++ b/contracts/HelloEthSalon.sol @@ -0,0 +1,13 @@ +pragma solidity ^0.4.4; + +contract HelloEthSalon { + string message = "I know smart contract testing!!"; + + function HelloEthSalon() { + // constructor + } + + function GetMessage() returns (string) { + return message; + } +} \ No newline at end of file diff --git a/migrations/1_initial_migration.js b/migrations/1_initial_migration.js new file mode 100644 index 0000000..b9de090 --- /dev/null +++ b/migrations/1_initial_migration.js @@ -0,0 +1,5 @@ +var HelloEthSalon = artifacts.require('./HelloEthSalon.sol'); + +module.exports = function(deployer) { + deployer.deploy(HelloEthSalon); +}; \ No newline at end of file diff --git a/test/hello_eth_salon.js b/test/hello_eth_salon.js new file mode 100644 index 0000000..2549e34 --- /dev/null +++ b/test/hello_eth_salon.js @@ -0,0 +1,9 @@ +var HelloEthSalon = artifacts.require("./HelloEthSalon.sol"); + +contract("HelloEthSalon:GetMessage", function (accounts) { + it("should return a correct string", async function () { + const contract = await HelloEthSalon.deployed(); + const result = await contract.GetMessage.call(); + assert.isTrue(result === "I know smart contract testing!!"); + }); +}); \ No newline at end of file diff --git a/truffle-config.js b/truffle-config.js new file mode 100644 index 0000000..175a1d0 --- /dev/null +++ b/truffle-config.js @@ -0,0 +1,4 @@ +module.exports = { + // See + // to customize your Truffle configuration! +}; \ No newline at end of file diff --git a/truffle.js b/truffle.js new file mode 100644 index 0000000..63ad944 --- /dev/null +++ b/truffle.js @@ -0,0 +1,10 @@ +module.exports = { + networks: { + development: { + host: "localhost", + port: 8545, + network_id: "*", // Match any network id + gas: 4700000 + } + } +}; \ No newline at end of file