Skip to content

Latest commit

 

History

History
59 lines (47 loc) · 1.21 KB

README.md

File metadata and controls

59 lines (47 loc) · 1.21 KB

testcoders-blockchain-meetup

Build status master

Getting started

Make sure you have truffle and testrpc installed

npm install -g truffle ethereumjs-testrpc

cd into the repository directory and run the following command to create build artifacts for the smart contract:

truffle deploy

after that, you can run the tests using the following command:

truffle test

Create smart contract

truffle create contract HelloWorld

Example contract

pragma solidity ^0.4.4;

contract HelloWorld {
    string message = "Hello World!!";

    function HelloWorld() {
        // constructor
    }

    function GetMessage() returns (string) {
        return message;
    }
}

Creating tests

truffle create test HelloWorld

Example test

const HelloWorld = artifacts.require('./HelloWorld.sol');

contract('HelloWorld:GetMessage', (accounts) => {
  it('Should return a correct string', async () => {
    const contract = await HelloWorld.deployed();
    const result = await contract.GetMessage.call();
    assert.isTrue(result === 'Hello World!!');
  });
});