Selaa lähdekoodia

Added a contactable contract and some tests for it

João Gabriel Carvalho 8 vuotta sitten
vanhempi
sitoutus
26335e669e
2 muutettua tiedostoa jossa 46 lisäystä ja 0 poistoa
  1. 16 0
      contracts/ownership/Contactable.sol
  2. 30 0
      test/Contactable.js

+ 16 - 0
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;
+     }
+
+}

+ 30 - 0
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);
+   });
+  });
+});