Skip to content

Commit 4825f74

Browse files
authored
Merge pull request #14 from SpringRole/truffle-test-cases
added test cases using truffle suite
2 parents bcf8329 + 242fecb commit 4825f74

14 files changed

+3774
-22
lines changed

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
19+
# node-waf configuration
20+
.lock-wscript
21+
22+
# Compiled binary addons (http://nodejs.org/api/addons.html)
23+
build/Release
24+
25+
# Dependency directory
26+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27+
node_modules

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
# SpringRole Smart Contracts
3+
4+
=================================================
5+
6+
Steps to Run Tests
7+
8+
1. npm install -g ethereumjs-testrpc
9+
2. npm install
10+
3. testrpc -l 6721975
11+
4. npm test

AirDrop.sol renamed to contracts/AirDrop.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity ^0.4.19;
1+
pragma solidity ^0.4.18;
22

33
/**
44
* @title Token
@@ -63,7 +63,7 @@ contract AirDrop is Ownable {
6363
Airdrop function which take up a array of address and amount and call the
6464
transfer function to send the token
6565
*/
66-
function doAirDrop(address[] _address, uint256 _amount) onlyOwner public returns (bool success) {
66+
function doAirDrop(address[] _address, uint256 _amount) onlyOwner public returns (bool) {
6767
uint256 count = _address.length;
6868
for (uint256 i = 0; i < count; i++)
6969
{

contracts/Migrations.sol

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
pragma solidity ^0.4.4;
2+
3+
contract Migrations {
4+
address public owner;
5+
uint public last_completed_migration;
6+
7+
modifier restricted() {
8+
if (msg.sender == owner) _;
9+
}
10+
11+
function Migrations() {
12+
owner = msg.sender;
13+
}
14+
15+
function setCompleted(uint completed) restricted {
16+
last_completed_migration = completed;
17+
}
18+
19+
function upgrade(address new_address) restricted {
20+
Migrations upgraded = Migrations(new_address);
21+
upgraded.setCompleted(last_completed_migration);
22+
}
23+
}

PreMint.sol renamed to contracts/SRTToken.sol

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity ^0.4.19;
1+
pragma solidity ^0.4.18;
22

33
/**
44
* @title ERC20Basic
@@ -176,9 +176,11 @@ contract SRTToken is Ownable,StandardToken,WhiteListedContracts {
176176
return true;
177177
}
178178

179-
/*
180-
mint function will allow to mint tokens and assign to owner
181-
*/
179+
/**
180+
* @dev Function to mint tokens
181+
* @param _amount The amount of tokens to mint.
182+
* @return A boolean that indicates if the operation was successful.
183+
*/
182184
function mint(uint256 _amount) onlyOwner public returns (bool) {
183185
require(maxSupply>(totalSupply.add(_amount)));
184186
totalSupply = totalSupply.add(_amount);

Vanity.sol renamed to contracts/VanityURL.sol

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
pragma solidity ^0.4.19;
1+
pragma solidity ^0.4.18;
22

3-
/**
4-
* @title Token
5-
* @dev Simpler version of ERC20 interface
6-
*/
7-
contract Token {
8-
function transfer(address to, uint256 value) public returns (bool);
9-
event Transfer(address indexed from, address indexed to, uint256 value);
10-
}
113

12-
contract SRTToken is Token{
4+
contract Token{
135

146
function doTransfer(address _from, address _to, uint256 _value) public returns (bool);
157

@@ -113,7 +105,7 @@ contract Pausable is Ownable {
113105
contract VanityURL is Ownable,Pausable {
114106

115107
// This declares a state variable that would store the contract address
116-
SRTToken public tokenAddress;
108+
Token public tokenAddress;
117109
// This declares a state variable that would store mapping for reserved _keyword
118110
mapping (string => uint) reservedKeywords;
119111
// This declares a state variable that mapping for vanityURL to address
@@ -129,7 +121,7 @@ contract VanityURL is Ownable,Pausable {
129121
constructor function to set token address & Pricing for reserving and token transfer address
130122
*/
131123
function VanityURL(address _tokenAddress, uint256 _reservePricing, address _transferTokenTo){
132-
tokenAddress = SRTToken(_tokenAddress);
124+
tokenAddress = Token(_tokenAddress);
133125
reservePricing = _reservePricing;
134126
transferTokenTo = _transferTokenTo;
135127
}
@@ -140,7 +132,7 @@ contract VanityURL is Ownable,Pausable {
140132

141133
/* function to update Token address */
142134
function updateTokenAddress (address _tokenAddress) onlyOwner public {
143-
tokenAddress = SRTToken(_tokenAddress);
135+
tokenAddress = Token(_tokenAddress);
144136
}
145137

146138
/* function to update transferTokenTo */
@@ -154,8 +146,8 @@ contract VanityURL is Ownable,Pausable {
154146
}
155147

156148

157-
/*
158-
function to remove reserved keyword
149+
/*
150+
function to remove reserved keyword
159151
*/
160152
function removeReservedKeyword (string _keyword) onlyOwner public {
161153
delete(reservedKeywords[_keyword]);
@@ -310,7 +302,7 @@ contract VanityURL is Ownable,Pausable {
310302
*/
311303

312304
function kill() onlyOwner {
313-
suicide(owner);
305+
selfdestruct(owner);
314306
}
315307

316308
/*

migrations/1_initial_migration.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var Migrations = artifacts.require("./Migrations.sol");
2+
3+
module.exports = function(deployer) {
4+
deployer.deploy(Migrations);
5+
};

migrations/2_deploy_contracts.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var SRTToken = artifacts.require("./SRTToken.sol");
2+
var VanityURL = artifacts.require("./VanityURL.sol");
3+
var AirDrop = artifacts.require("./AirDrop.sol");
4+
5+
module.exports = function(deployer,network,accounts) {
6+
deployer.deploy(SRTToken,1000000).then(function() {
7+
return deployer.deploy(AirDrop, SRTToken.address);
8+
}).then(function() {
9+
return deployer.deploy(VanityURL, SRTToken.address,1,accounts[2]);
10+
});
11+
};

0 commit comments

Comments
 (0)