git ssb

0+

dangerousbeans / Entropy_contracts



Commit be59af3f6ee21c7ed8efecaa9e4a6fd406639da1

working tests

Joran committed on 12/8/2016, 2:37:49 AM
Parent: 03738da27a3168eab56fe13eac4f0c8be67cff78

Files changed

contracts/Entropy.solchanged
test/Entropy_token.jschanged
contracts/Entropy.solView
@@ -49,19 +49,21 @@
4949 }
5050
5151
5252 /**
53- * Creates Entropy tokens
53 + * Creates Entropy tokens for whoever called this method
5454 */
5555 function buyTokens() payable returns (bool success) {
5656 var value = msg.value;
5757 var buyer = msg.sender;
5858 if (value == 0) throw;
5959
6060 // safety cap
61- //if (getTotalValue() + value > SAFETY_LIMIT) throw;
61 + // if (getTotalValue() + value > SAFETY_LIMIT) throw;
6262
6363 // 1 Ether === 1 Entropy Token
64 + // Solidity will floor this by default, so sending 1.9 eth will result in
65 + // 1 token
6466 uint tokens = value / 1 ether;
6567
6668 totalSupply += tokens;
6769 balances[buyer] += tokens;
@@ -110,8 +112,5 @@
110112 */
111113
112114 // A new guardian has been elected
113115 event NewGuardian(address indexed _guardian, address indexed _creator);
114-
115- // Entropy Token transer
116- event Transfer(address indexed _from, address indexed _to, uint256 _value);
117116 }
test/Entropy_token.jsView
@@ -14,22 +14,24 @@
1414 })
1515 })
1616 });
1717
18- describe("Buying tokens", () => {
19- it("Lets you buy tokens", function(done) {
18 + describe("Buying Entropy tokens", () => {
19 + it("Lets you buy Entropy tokens", function(done) {
2020 helpers.deployEntropyContract()
2121 .then((entropy) => {
2222 // Buy with 2 Eth worth of value
23- entropy.buyTokens({ from: accounts[1], value: 2e16 })
24- .then((tx) => {
25- return entropy.balanceOf(accounts[1])
23 + entropy.buyTokens({ from: accounts[1], value: 2e18 })
24 + .then(() => {
25 + entropy.balanceOf.call(accounts[1])
26 + .then((balance) => {
27 + console.log("BALANCE:::::")
28 + console.log(balance)
29 +
30 + assert.equal(balance.valueOf(), 2);
31 + done();
32 + })
2633 })
27- .then((balance) => {
28- // Should now hold tokens!
29- assert.equal(balance.valueOf(), 2);
30- done();
31- })
3234 })
3335 })
3436 })
3537 })

Built with git-ssb-web