Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterlong committed Sep 13, 2017
1 parent 8287452 commit 2965996
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 27 deletions.
Binary file added .DS_Store
Binary file not shown.
14 changes: 10 additions & 4 deletions contracts/Sale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ contract Sale {
configSet = true;
}

function closeSale() external {
require(msg.sender==creator);
isFunding = false;
}

// CONTRIBUTE FUNCTION
// converts ETH to TOKEN and sends new TOKEN to the sender
function contribute() external payable {
Expand Down Expand Up @@ -101,14 +106,15 @@ contract Sale {
// only ran 1 time on initialization
function createHeldCoins() internal {
// TOTAL SUPPLY = 5,000,000
createHoldToken(0x4f70Dc5Da5aCf5e71905c3a8473a6D8a7E7Ba4c5, 100000000000000000000000); // hunter
createHoldToken(0x393c82c7Ae55B48775f4eCcd2523450d291f2418, 100000000000000000000000); // steve
createHoldToken(msg.sender, 1000);
createHoldToken(0x4f70Dc5Da5aCf5e71905c3a8473a6D8a7E7Ba4c5, 100000000000000000000000);
createHoldToken(0x393c82c7Ae55B48775f4eCcd2523450d291f2418, 100000000000000000000000);
}

// function to create held tokens for developer
function createHoldToken(address _to, uint256 amount) internal {
heldTokens[_to] = amount;
heldTimeline[_to] = block.number + 200000;
heldTimeline[_to] = block.number + 0;
heldTotal += amount;
totalMinted += heldTotal;
}
Expand All @@ -127,4 +133,4 @@ contract Sale {
}


}
}
2 changes: 1 addition & 1 deletion contracts/Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ contract Token is StandardToken {
require(_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData));
return true;
}
}
}
1 change: 1 addition & 0 deletions node_modules/original-require/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions node_modules/original-require/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

137 changes: 115 additions & 22 deletions test/sale_erc20.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,12 @@ var tokenAddress;
var Tokenint;


contract('Token', function(accounts) {
contract('Sale', function(accounts) {

account_one = accounts[0];
account_two = accounts[1];
account_three = accounts[2];

tokenAddress = Token.address;
saleAddress = Sale.address;

it("should confirm the Sale address", function() {
return Token.deployed().then(function(instance) {
Tokenint = instance;
return instance.mintableAddress.call()
}).then(function(address) {
assert.equal(address, saleAddress, "Sale account is the same");
});
});


});



contract('Sale', function(accounts) {

var cn;

it("should setup the wallet", function() {
Expand All @@ -58,9 +39,121 @@ contract('Sale', function(accounts) {
return Sale.deployed().then(function(instance) {
return instance.contribute({from: account_one, value: 20000000000})
}).then(function(tx) {
console.log(tx.logs.event);
assert.equal(tx, "0xf04d145dd24e05e6ac9149302b62970769795fba", "Transfer ETH to confirmed");
assert.equal(tx.logs[0].event, "Contribution", "Transfer ETH to confirmed");
})
});


it("should have TOKENs in wallet", function() {
return Token.deployed().then(function(instance) {
Tokenint = instance;
return instance.balanceOf.call(account_one)
}).then(function(balance) {
assert.equal(balance.valueOf(), 12000000000000, "Purchaser has the new Tokens");
})
});


it("should transfer Tokens to someone else", function() {
return Token.deployed().then(function(instance) {
return instance.transfer(account_two, 100000000, {from: account_one})
}).then(function(tx) {
assert.equal(tx.logs[0].event, "Transfer", "Transfer Tokens confirmed");
})
});


it("second address has TOKENs in wallet", function() {
return Token.deployed().then(function(instance) {
return instance.balanceOf.call(account_two)
}).then(function(balance) {
assert.equal(balance.valueOf(), 100000000, "Second wallet has some Tokens");
})
});

it("should change TOKEN/ETH rate", function() {
return Sale.deployed().then(function(instance) {
return instance.updateRate(750, {from: account_one})
}).then(function() {
return cn.exchangeRate.call()
}).then(function(rate) {
assert.equal(rate, 750, "Rate was changed");
})
});


it("should change creator", function() {
return Sale.deployed().then(function(instance) {
cn = instance;
return instance.changeCreator(account_two, {from: account_one})
}).then(function() {
return cn.creator.call()
}).then(function(creator) {
assert.equal(creator.valueOf(), account_two, "Creator was changed");
})
});


it("should change Transfer status to OFF", function() {
return Sale.deployed().then(function(instance) {
return instance.changeTransferStats(false, {from: account_two})
}).then(function() {
return Tokenint.allowTransfer.call()
}).then(function(allow) {
assert.equal(allow, false, "Tokens cannot be transferred");
})
});


it("should change Transfer status to ON", function() {
return Sale.deployed().then(function(instance) {
return instance.changeTransferStats(true, {from: account_two})
}).then(function() {
return Tokenint.allowTransfer.call()
}).then(function(allow) {
assert.equal(allow, true, "Tokens can be transferred");
})
});


it("should turn off token sale", function() {
return Sale.deployed().then(function(instance) {
return instance.closeSale({from: account_two})
}).then(function() {
return cn.isFunding.call()
}).then(function(allow) {
assert.equal(allow, false, "Tokens Sale has ended");
})
});


it("should release held tokens to founders", function() {
return Sale.deployed().then(function(instance) {
return instance.releaseHeldCoins({from: account_one})
}).then(function() {
return Tokenint.balanceOf.call(account_one)
}).then(function(balance) {
assert.equal(balance.valueOf(), 11999900001000, "Tokens were released to founder");
})
});

});


contract('Token', function(accounts) {

tokenAddress = Token.address;
saleAddress = Sale.address;

it("should confirm the Sale address", function() {
return Token.deployed().then(function(instance) {
Tokenint = instance;
return instance.mintableAddress.call()
}).then(function(address) {
assert.equal(address, saleAddress, "Sale account is the same");
});
});



});

0 comments on commit 2965996

Please sign in to comment.