Truffle preparation
This commit is contained in:
parent
e8693aea67
commit
3e41a2189a
|
@ -1,2 +1,2 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
*.log
|
build/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
pragma solidity ^0.4.8;
|
pragma solidity ^0.4.8;
|
||||||
|
|
||||||
import "./StatusContribution.sol"
|
import "./StatusContribution.sol";
|
||||||
|
|
||||||
// @dev Contract to hold sale raised funds during the sale period.
|
// @dev Contract to hold sale raised funds during the sale period.
|
||||||
// Prevents attack in which the Aragon Multisig sends raised ether
|
// Prevents attack in which the Aragon Multisig sends raised ether
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
pragma solidity ^0.4.4;
|
||||||
|
|
||||||
|
contract Migrations {
|
||||||
|
address public owner;
|
||||||
|
uint public last_completed_migration;
|
||||||
|
|
||||||
|
modifier restricted() {
|
||||||
|
if (msg.sender == owner) _;
|
||||||
|
}
|
||||||
|
|
||||||
|
function Migrations() {
|
||||||
|
owner = msg.sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCompleted(uint completed) restricted {
|
||||||
|
last_completed_migration = completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
function upgrade(address new_address) restricted {
|
||||||
|
Migrations upgraded = Migrations(new_address);
|
||||||
|
upgraded.setCompleted(last_completed_migration);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
pragma solidity 0.4.8;
|
pragma solidity ^0.4.8;
|
||||||
|
|
||||||
|
|
||||||
/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
|
/// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
|
||||||
|
|
|
@ -9,7 +9,7 @@ import "./MiniMeToken.sol";
|
||||||
*/
|
*/
|
||||||
|
|
||||||
contract SGT is MiniMeToken {
|
contract SGT is MiniMeToken {
|
||||||
uint constant D160 = 0x10000000000000000000000000000000000000000;
|
uint constant D160 = 0x0010000000000000000000000000000000000000000;
|
||||||
|
|
||||||
function SGT(
|
function SGT(
|
||||||
address _tokenFactory
|
address _tokenFactory
|
||||||
|
|
|
@ -12,7 +12,7 @@ contract SNT is MiniMeToken {
|
||||||
// @dev SNT constructor just parametrizes the MiniMeIrrevocableVestedToken constructor
|
// @dev SNT constructor just parametrizes the MiniMeIrrevocableVestedToken constructor
|
||||||
function SNT(
|
function SNT(
|
||||||
address _tokenFactory
|
address _tokenFactory
|
||||||
) MiniMeIrrevocableVestedToken(
|
) MiniMeToken(
|
||||||
_tokenFactory,
|
_tokenFactory,
|
||||||
0x0, // no parent token
|
0x0, // no parent token
|
||||||
0, // no snapshot block number from parent
|
0, // no snapshot block number from parent
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
pragma solidity ^0.4.8;
|
pragma solidity ^0.4.8;
|
||||||
|
|
||||||
import "./MiniMeToken.sol";
|
import "./MiniMeToken.sol";
|
||||||
import "./Controller.sol";
|
import "./StatusContribution.sol";
|
||||||
import "./StatusContribution";
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -18,7 +17,7 @@ import "./StatusContribution";
|
||||||
asks it to do so.
|
asks it to do so.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
contract SNTPlaceHolder is Controller {
|
contract SNTPlaceHolder is TokenController {
|
||||||
address public owner;
|
address public owner;
|
||||||
MiniMeToken public snt;
|
MiniMeToken public snt;
|
||||||
StatusContribution public contribution;
|
StatusContribution public contribution;
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
var Migrations = artifacts.require("./Migrations.sol");
|
||||||
|
|
||||||
|
module.exports = function(deployer) {
|
||||||
|
deployer.deploy(Migrations);
|
||||||
|
};
|
|
@ -0,0 +1,8 @@
|
||||||
|
var ConvertLib = artifacts.require("./ConvertLib.sol");
|
||||||
|
var MetaCoin = artifacts.require("./MetaCoin.sol");
|
||||||
|
|
||||||
|
module.exports = function(deployer) {
|
||||||
|
deployer.deploy(ConvertLib);
|
||||||
|
deployer.link(ConvertLib, MetaCoin);
|
||||||
|
deployer.deploy(MetaCoin);
|
||||||
|
};
|
|
@ -16,8 +16,6 @@
|
||||||
"babel-preset-stage-2": "^6.18.0",
|
"babel-preset-stage-2": "^6.18.0",
|
||||||
"babel-preset-stage-3": "^6.17.0",
|
"babel-preset-stage-3": "^6.17.0",
|
||||||
"babel-register": "^6.23.0",
|
"babel-register": "^6.23.0",
|
||||||
"ethereumjs-testrpc": "^3.0.2",
|
|
||||||
"truffle": "git+https://github.com/ConsenSys/truffle.git#3.1.9"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "^2.4.0",
|
"async": "^2.4.0",
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
pragma solidity ^0.4.2;
|
||||||
|
|
||||||
|
import "truffle/Assert.sol";
|
||||||
|
import "truffle/DeployedAddresses.sol";
|
||||||
|
import "../contracts/MetaCoin.sol";
|
||||||
|
|
||||||
|
contract TestMetacoin {
|
||||||
|
|
||||||
|
function testInitialBalanceUsingDeployedContract() {
|
||||||
|
MetaCoin meta = MetaCoin(DeployedAddresses.MetaCoin());
|
||||||
|
|
||||||
|
uint expected = 10000;
|
||||||
|
|
||||||
|
Assert.equal(meta.getBalance(tx.origin), expected, "Owner should have 10000 MetaCoin initially");
|
||||||
|
}
|
||||||
|
|
||||||
|
function testInitialBalanceWithNewMetaCoin() {
|
||||||
|
MetaCoin meta = new MetaCoin();
|
||||||
|
|
||||||
|
uint expected = 10000;
|
||||||
|
|
||||||
|
Assert.equal(meta.getBalance(tx.origin), expected, "Owner should have 10000 MetaCoin initially");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
var MetaCoin = artifacts.require("./MetaCoin.sol");
|
||||||
|
|
||||||
|
contract('MetaCoin', function(accounts) {
|
||||||
|
it("should put 10000 MetaCoin in the first account", function() {
|
||||||
|
return MetaCoin.deployed().then(function(instance) {
|
||||||
|
return instance.getBalance.call(accounts[0]);
|
||||||
|
}).then(function(balance) {
|
||||||
|
assert.equal(balance.valueOf(), 10000, "10000 wasn't in the first account");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("should call a function that depends on a linked library", function() {
|
||||||
|
var meta;
|
||||||
|
var metaCoinBalance;
|
||||||
|
var metaCoinEthBalance;
|
||||||
|
|
||||||
|
return MetaCoin.deployed().then(function(instance) {
|
||||||
|
meta = instance;
|
||||||
|
return meta.getBalance.call(accounts[0]);
|
||||||
|
}).then(function(outCoinBalance) {
|
||||||
|
metaCoinBalance = outCoinBalance.toNumber();
|
||||||
|
return meta.getBalanceInEth.call(accounts[0]);
|
||||||
|
}).then(function(outCoinBalanceEth) {
|
||||||
|
metaCoinEthBalance = outCoinBalanceEth.toNumber();
|
||||||
|
}).then(function() {
|
||||||
|
assert.equal(metaCoinEthBalance, 2 * metaCoinBalance, "Library function returned unexpected function, linkage may be broken");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("should send coin correctly", function() {
|
||||||
|
var meta;
|
||||||
|
|
||||||
|
// Get initial balances of first and second account.
|
||||||
|
var account_one = accounts[0];
|
||||||
|
var account_two = accounts[1];
|
||||||
|
|
||||||
|
var account_one_starting_balance;
|
||||||
|
var account_two_starting_balance;
|
||||||
|
var account_one_ending_balance;
|
||||||
|
var account_two_ending_balance;
|
||||||
|
|
||||||
|
var amount = 10;
|
||||||
|
|
||||||
|
return MetaCoin.deployed().then(function(instance) {
|
||||||
|
meta = instance;
|
||||||
|
return meta.getBalance.call(account_one);
|
||||||
|
}).then(function(balance) {
|
||||||
|
account_one_starting_balance = balance.toNumber();
|
||||||
|
return meta.getBalance.call(account_two);
|
||||||
|
}).then(function(balance) {
|
||||||
|
account_two_starting_balance = balance.toNumber();
|
||||||
|
return meta.sendCoin(account_two, amount, {from: account_one});
|
||||||
|
}).then(function() {
|
||||||
|
return meta.getBalance.call(account_one);
|
||||||
|
}).then(function(balance) {
|
||||||
|
account_one_ending_balance = balance.toNumber();
|
||||||
|
return meta.getBalance.call(account_two);
|
||||||
|
}).then(function(balance) {
|
||||||
|
account_two_ending_balance = balance.toNumber();
|
||||||
|
|
||||||
|
assert.equal(account_one_ending_balance, account_one_starting_balance - amount, "Amount wasn't correctly taken from the sender");
|
||||||
|
assert.equal(account_two_ending_balance, account_two_starting_balance + amount, "Amount wasn't correctly sent to the receiver");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,9 @@
|
||||||
|
module.exports = {
|
||||||
|
networks: {
|
||||||
|
development: {
|
||||||
|
host: "localhost",
|
||||||
|
port: 8545,
|
||||||
|
network_id: "*" // Match any network id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue