From 26335e669e0a0aedb30e542aae530a95c3f219af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Carvalho?= Date: Wed, 22 Feb 2017 16:28:01 -0300 Subject: [PATCH] Added a contactable contract and some tests for it --- contracts/ownership/Contactable.sol | 16 +++++++++++++++ test/Contactable.js | 30 +++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 contracts/ownership/Contactable.sol create mode 100644 test/Contactable.js diff --git a/contracts/ownership/Contactable.sol b/contracts/ownership/Contactable.sol new file mode 100644 index 000000000..4c32b749d --- /dev/null +++ b/contracts/ownership/Contactable.sol @@ -0,0 +1,16 @@ +pragma solidity ^0.4.0; + +import './Ownable.sol'; +/* + * Contactable token + * Basic version of a contactable contract + */ +contract Contactable is Ownable{ + + string public contactInformation; + + function setContactInformation(string info) onlyOwner{ + contactInformation = info; + } + +} diff --git a/test/Contactable.js b/test/Contactable.js new file mode 100644 index 000000000..9779ed626 --- /dev/null +++ b/test/Contactable.js @@ -0,0 +1,30 @@ +'use strict'; +const assertJump = require('./helpers/assertJump'); + +var Contactable = artifacts.require('../contracts/ownership/Contactable.sol'); + +contract('Contactable', function(accounts) { + let contactable; + + beforeEach(async function() { + contactable = await Contactable.new(); + }); + + it('should have an empty contact info', async function() { + let info = await contactable.contactInformation(); + assert.isTrue(info == ""); + }); + + describe('after setting the contact information', function () { + let contactInfo = "contact information" + + beforeEach(async function () { + await contactable.setContactInformation(contactInfo); + }); + + it('should return the setted contact information', async function() { + let info = await contactable.contactInformation(); + assert.isTrue(info === contactInfo); + }); + }); +});