Skip to content

Commit

Permalink
Purchases enabled defaulted to false
Browse files Browse the repository at this point in the history
  • Loading branch information
stanacton committed Jan 17, 2018
1 parent ab65056 commit fd5dec1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/dapp/public/address.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"PreICO":{"address":"0x8f353619bf309b6a1f3f8ad189f994398ec2232a"}}
{"PreICO":{"address":"0x02dbbadcb21c86b271a39b55fa99bfc0662e9ca7"}}
10 changes: 4 additions & 6 deletions src/truffle/contracts/PreICO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,22 @@ contract PreICO is DelegateableOwnerToken {
mapping(address => uint) public customerPrice;

function PreICO(uint256 initialSupply, uint256 price) {
totalSupply = initialSupply * (10 ** uint256(decimals));

totalSupply = initialSupply * (10 ** uint256(decimals));
owner = msg.sender;
balances[owner] = totalSupply;
_price = price;

purchasesEnabled = true;
purchasesEnabled = false;
}

function() payable {
buyTokens();
}

function claimOwnership() onlyPendingOwner public {
// TODO: Check ORDER!!!!
uint256 ownerBalance = balances[owner];
require(pendingOwner != owner);
balances[pendingOwner] = balances[owner];
balances[owner] = 0;
balances[pendingOwner] = ownerBalance;
super.claimOwnership();
}

Expand Down
6 changes: 6 additions & 0 deletions src/truffle/test/PreICO.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
var PreICO = artifacts.require("../contracts/PreICO.sol");

contract("PreICO", function(accounts) {
beforeEach(async function() {
var ico = await PreICO.deployed();
await ico.enablePurchases(true);
})

it("should compile and deploy!!", function(){
var ownerBalance = 0;
var owner;
Expand Down Expand Up @@ -629,6 +634,7 @@ contract("PreICO", function(accounts) {

it("should return unused eth", async function() {
var testICO = await PreICO.new(1, toWei(1));
await testICO.enablePurchases(true);
var totalSupply = await testICO.totalSupply.call();
var price = await testICO.pricePerETH.call();
var user = accounts[8];
Expand Down
8 changes: 4 additions & 4 deletions src/truffle/test/PreICOPausable.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ contract("PreICO when paused", function(accounts) {
it("should disable and enable purchaseEnabled", async function() {
var ico = await PreICO.deployed();
var enabled = await ico.purchasesEnabled();
assert.isTrue(enabled, "purchaseEnabled should be true");

await ico.enablePurchases(false);
enabled = await ico.purchasesEnabled();
assert.isFalse(enabled, "purchaseEnabled should be false");

await ico.enablePurchases(true);
enabled = await ico.purchasesEnabled();
assert.isTrue(enabled, "purchaseEnabled should be true");

await ico.enablePurchases(false);
enabled = await ico.purchasesEnabled();
assert.isFalse(enabled, "purchaseEnabled should be false");
});

it("should stop buyTokens when purchase disabled", async function() {
Expand Down

0 comments on commit fd5dec1

Please sign in to comment.