Skip to content

Commit dd6a9f9

Browse files
authored
Merge pull request #302 from AugustoL/add-LifTokenTest
Add Lif token contract with faucet for testnet
2 parents 1114f7c + aca488d commit dd6a9f9

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

contracts/LifTokenTest.sol

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
pragma solidity ^0.4.15;
2+
3+
import "./SmartToken.sol";
4+
import "zeppelin-solidity/contracts/token/BurnableToken.sol";
5+
import "zeppelin-solidity/contracts/token/PausableToken.sol";
6+
7+
/**
8+
@title Líf, the Winding Tree token
9+
10+
Implementation of Líf, the ERC20 token for Winding Tree, with extra methods
11+
to transfer value and data to execute a call on transfer.
12+
This version of the token is used in test networks, it allows anyone to claim
13+
tokens.
14+
Uses OpenZeppelin Pausable.
15+
*/
16+
contract LifTokenTest is SmartToken, BurnableToken, PausableToken {
17+
// Token Name
18+
string public constant NAME = "Líf";
19+
20+
// Token Symbol
21+
string public constant SYMBOL = "LIF";
22+
23+
// Token decimals
24+
uint public constant DECIMALS = 18;
25+
26+
// Max Lif faucet (50 tokens)
27+
uint256 public constant MAX_LIF_FAUCET = 50000000000000000000;
28+
29+
function approveData(address spender, uint256 value, bytes data) public whenNotPaused returns (bool) {
30+
return super.approveData(spender, value, data);
31+
}
32+
33+
function transferData(address to, uint256 value, bytes data) public whenNotPaused returns (bool) {
34+
return super.transferData(to, value, data);
35+
}
36+
37+
function transferDataFrom(address from, address to, uint256 value, bytes data) public whenNotPaused returns (bool) {
38+
return super.transferDataFrom(from, to, value, data);
39+
}
40+
41+
/**
42+
@dev Burns a specific amount of tokens.
43+
44+
@param _value The amount of tokens to be burned.
45+
*/
46+
function burn(uint256 _value) public whenNotPaused {
47+
super.burn(_value);
48+
49+
// a Transfer event to 0x0 can be useful for observers to keep track of
50+
// all the Lif by just looking at those events
51+
Transfer(msg.sender, address(0), _value);
52+
}
53+
54+
/**
55+
* @dev Function to create tokens, it will issue tokens to the tx sender
56+
*/
57+
function faucetLif() public {
58+
uint256 amount = MAX_LIF_FAUCET.sub(balances[msg.sender]);
59+
totalSupply = totalSupply.add(amount);
60+
balances[msg.sender] = balances[msg.sender].add(amount);
61+
Transfer(0x0, msg.sender, amount);
62+
}
63+
64+
}

test/LifTokenTest.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
var BigNumber = web3.BigNumber;
3+
4+
require('chai')
5+
.use(require('chai-bignumber')(BigNumber))
6+
.should();
7+
8+
var LifTokenTest = artifacts.require('./LifTokenTest.sol');
9+
10+
const LOG_EVENTS = true;
11+
12+
contract('LifTokenTest', function(accounts) {
13+
14+
var token;
15+
var eventsWatcher;
16+
17+
beforeEach(async function() {
18+
token = await LifTokenTest.new();
19+
eventsWatcher = token.allEvents();
20+
eventsWatcher.watch(function(error, log){
21+
if (LOG_EVENTS)
22+
console.log('Event:', log.event, ':',log.args);
23+
});
24+
});
25+
26+
afterEach(function(done) {
27+
eventsWatcher.stopWatching();
28+
done();
29+
});
30+
31+
it('has name, symbol and decimals', async function() {
32+
new BigNumber(50000000000000000000).
33+
should.be.bignumber.equal(await token.MAX_LIF_FAUCET.call());
34+
});
35+
36+
it('should return the correct balance amount after claiming tokens', async function() {
37+
await token.faucetLif();
38+
new BigNumber(50000000000000000000).
39+
should.be.bignumber.equal(await token.balanceOf(accounts[0]));
40+
});
41+
42+
});

0 commit comments

Comments
 (0)