Add first of new zeppelin tests

pull/319/head
Alex 6 years ago
parent 69fb99b7af
commit 8adfa317db
  1. 3
      .gitmodules
  2. 2
      bin/exec.js
  3. 1
      lib/app.js
  4. 1
      test/sources/zeppelin
  5. 58
      test/sources/zeppelin/Bounty.sol
  6. 30
      test/sources/zeppelin/Claimable.sol
  7. 73
      test/sources/zeppelin/DayLimit.sol
  8. 15
      test/sources/zeppelin/Killable.sol
  9. 18
      test/sources/zeppelin/LimitBalance.sol
  10. 15
      test/sources/zeppelin/Migrations.sol
  11. 29
      test/sources/zeppelin/Multisig.sol
  12. 102
      test/sources/zeppelin/MultisigWallet.sol
  13. 26
      test/sources/zeppelin/Ownable.sol
  14. 30
      test/sources/zeppelin/PullPayment.sol
  15. 29
      test/sources/zeppelin/SafeMath.sol
  16. 165
      test/sources/zeppelin/Shareable.sol
  17. 28
      test/sources/zeppelin/Stoppable.sol
  18. 29
      test/sources/zeppelin/token/BasicToken.sol
  19. 38
      test/sources/zeppelin/token/CrowdsaleToken.sol
  20. 18
      test/sources/zeppelin/token/ERC20.sol
  21. 14
      test/sources/zeppelin/token/ERC20Basic.sol
  22. 26
      test/sources/zeppelin/token/SimpleToken.sol
  23. 49
      test/sources/zeppelin/token/StandardToken.sol
  24. 274
      test/zeppelin.js

3
.gitmodules vendored

@ -0,0 +1,3 @@
[submodule "test/sources/openzeppelin-solidity"]
path = test/sources/zeppelin
url = https://github.com/OpenZeppelin/openzeppelin-solidity

@ -11,9 +11,7 @@ const app = new App(config);
death((signal, err) => app.cleanUp(err));
app.generateCoverageEnvironment();
console.log('generated')
app.instrumentTarget();
console.log('instrumented')
app.launchTestrpc()
.then(() => {
app.runTestCommand();

@ -271,7 +271,6 @@ class App {
try {
const defaultCommand = `truffle compile ${this.network} ${this.silence}`;
const command = this.compileCommand || defaultCommand;
console.log(command, this.coverageDir);
this.log(`Running: ${command}\n(this can take a few seconds)...`);
shell.cd(this.coverageDir);

@ -0,0 +1 @@
Subproject commit 0dded493a03623c93845c2d58634c229862ab54a

@ -1,58 +0,0 @@
pragma solidity ^0.5.0;
import './PullPayment.sol';
import './Killable.sol';
/*
* Bounty
*
* This bounty will pay out to a researcher if they break invariant logic of the contract.
*/
contract Bounty is PullPayment, Killable {
Target target;
bool public claimed;
mapping(address => address) public researchers;
event TargetCreated(address createdAddress);
function() payable {
if (claimed) throw;
}
function createTarget() returns(Target) {
target = Target(deployContract());
researchers[target] = msg.sender;
TargetCreated(target);
return target;
}
function deployContract() internal returns(address);
function checkInvariant() returns(bool){
return target.checkInvariant();
}
function claim(Target target) {
address researcher = researchers[target];
if (researcher == 0) throw;
// Check Target contract invariants
if (target.checkInvariant()) {
throw;
}
asyncSend(researcher, this.balance);
claimed = true;
}
}
/*
* Target
*
* Your main contract should inherit from this class and implement the checkInvariant method. This is a function that should check everything your contract assumes to be true all the time. If this function returns false, it means your contract was broken in some way and is in an inconsistent state. This is what security researchers will try to acomplish when trying to get the bounty.
*/
contract Target {
function checkInvariant() returns(bool);
}

@ -1,30 +0,0 @@
pragma solidity ^0.5.0;
import './Ownable.sol';
/*
* Claimable
*
* Extension for the Ownable contract, where the ownership needs to be claimed. This allows the new owner to accept the transfer.
*/
contract Claimable is Ownable {
address public pendingOwner;
modifier onlyPendingOwner() {
if (msg.sender == pendingOwner)
_;
}
function transfer(address newOwner) onlyOwner {
pendingOwner = newOwner;
}
function claimOwnership() onlyPendingOwner {
owner = pendingOwner;
pendingOwner = 0x0;
}
}

@ -1,73 +0,0 @@
pragma solidity ^0.5.0;
import './Shareable.sol';
/*
* DayLimit
*
* inheritable "property" contract that enables methods to be protected by placing a linear limit (specifiable)
* on a particular resource per calendar day. is multiowned to allow the limit to be altered. resource that method
* uses is specified in the modifier.
*/
contract DayLimit is Shareable {
// FIELDS
uint public dailyLimit;
uint public spentToday;
uint public lastDay;
// MODIFIERS
// simple modifier for daily limit.
modifier limitedDaily(uint _value) {
if (underLimit(_value))
_;
}
// CONSTRUCTOR
// stores initial daily limit and records the present day's index.
function DayLimit(uint _limit) {
dailyLimit = _limit;
lastDay = today();
}
// METHODS
// (re)sets the daily limit. needs many of the owners to confirm. doesn't alter the amount already spent today.
function setDailyLimit(uint _newLimit) onlymanyowners(sha3(msg.data)) external {
dailyLimit = _newLimit;
}
// resets the amount already spent today. needs many of the owners to confirm
function resetSpentToday() onlymanyowners(sha3(msg.data)) external {
spentToday = 0;
}
// INTERNAL METHODS
// checks to see if there is at least `_value` left from the daily limit today. if there is, subtracts it and
// returns true. otherwise just returns false.
function underLimit(uint _value) internal onlyOwner returns (bool) {
// reset the spend limit if we're on a different day to last time.
if (today() > lastDay) {
spentToday = 0;
lastDay = today();
}
// check to see if there's enough left - if so, subtract and return true.
// overflow protection // dailyLimit check
if (spentToday + _value >= spentToday && spentToday + _value <= dailyLimit) {
spentToday += _value;
return true;
}
return false;
}
// determines today's index.
function today() private constant returns (uint) {
return now / 1 days;
}
}

@ -1,15 +0,0 @@
pragma solidity ^0.5.0;
import "./Ownable.sol";
/*
* Killable
* Base contract that can be killed by owner. All funds in contract will be sent to the owner.
*/
contract Killable is Ownable {
function kill() onlyOwner {
selfdestruct(owner);
}
}

@ -1,18 +0,0 @@
pragma solidity ^0.5.0;
contract LimitBalance {
uint public limit;
function LimitBalance(uint _limit) {
limit = _limit;
}
modifier limitedPayable() {
if (this.balance > limit) {
throw;
}
_;
}
}

@ -1,15 +0,0 @@
pragma solidity ^0.5.0;
import './Ownable.sol';
contract Migrations is Ownable {
uint public lastCompletedMigration;
function setCompleted(uint completed) onlyOwner {
lastCompletedMigration = completed;
}
function upgrade(address newAddress) onlyOwner {
Migrations upgraded = Migrations(newAddress);
upgraded.setCompleted(lastCompletedMigration);
}
}

@ -1,29 +0,0 @@
pragma solidity ^0.5.0;
/*
* Multisig
* Interface contract for multisig proxy contracts; see below for docs.
*/
contract Multisig {
// EVENTS
// logged events:
// Funds has arrived into the wallet (record how much).
event Deposit(address _from, uint value);
// Single transaction going out of the wallet (record who signed for it, how much, and to whom it's going).
event SingleTransact(address owner, uint value, address to, bytes data);
// Multi-sig transaction going out of the wallet (record who signed for it last, the operation hash, how much, and to whom it's going).
event MultiTransact(address owner, bytes32 operation, uint value, address to, bytes data);
// Confirmation still needed for a transaction.
event ConfirmationNeeded(bytes32 operation, address initiator, uint value, address to, bytes data);
// FUNCTIONS
// TODO: document
function changeOwner(address _from, address _to) external;
function execute(address _to, uint _value, bytes _data) external returns (bytes32);
function confirm(bytes32 _h) returns (bool);
}

@ -1,102 +0,0 @@
pragma solidity ^0.5.0;
import "./Multisig.sol";
import "./Shareable.sol";
import "./DayLimit.sol";
/*
* MultisigWallet
* usage:
* bytes32 h = Wallet(w).from(oneOwner).execute(to, value, data);
* Wallet(w).from(anotherOwner).confirm(h);
*/
contract MultisigWallet is Multisig, Shareable, DayLimit {
// TYPES
// Transaction structure to remember details of transaction lest it need be saved for a later call.
struct Transaction {
address to;
uint value;
bytes data;
}
// CONSTRUCTOR
// just pass on the owner array to the multiowned and
// the limit to daylimit
function MultisigWallet(address[] _owners, uint _required, uint _daylimit)
Shareable(_owners, _required)
DayLimit(_daylimit) { }
// METHODS
// kills the contract sending everything to `_to`.
function kill(address _to) onlymanyowners(sha3(msg.data)) external {
suicide(_to);
}
// gets called when no other function matches
function() payable {
// just being sent some cash?
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
// Outside-visible transact entry point. Executes transaction immediately if below daily spend limit.
// If not, goes into multisig process. We provide a hash on return to allow the sender to provide
// shortcuts for the other confirmations (allowing them to avoid replicating the _to, _value
// and _data arguments). They still get the option of using them if they want, anyways.
function execute(address _to, uint _value, bytes _data) external onlyOwner returns (bytes32 _r) {
// first, take the opportunity to check that we're under the daily limit.
if (underLimit(_value)) {
SingleTransact(msg.sender, _value, _to, _data);
// yes - just execute the call.
if (!_to.call.value(_value)(_data)) {
throw;
}
return 0;
}
// determine our operation hash.
_r = sha3(msg.data, block.number);
if (!confirm(_r) && txs[_r].to == 0) {
txs[_r].to = _to;
txs[_r].value = _value;
txs[_r].data = _data;
ConfirmationNeeded(_r, msg.sender, _value, _to, _data);
}
}
// confirm a transaction through just the hash. we use the previous transactions map, txs, in order
// to determine the body of the transaction from the hash provided.
function confirm(bytes32 _h) onlymanyowners(_h) returns (bool) {
if (txs[_h].to != 0) {
if (!txs[_h].to.call.value(txs[_h].value)(txs[_h].data)) {
throw;
}
MultiTransact(msg.sender, _h, txs[_h].value, txs[_h].to, txs[_h].data);
delete txs[_h];
return true;
}
}
// INTERNAL METHODS
function clearPending() internal {
uint length = pendingsIndex.length;
for (uint i = 0; i < length; ++i) {
delete txs[pendingsIndex[i]];
}
super.clearPending();
}
// FIELDS
// pending transactions we have at present.
mapping (bytes32 => Transaction) txs;
}

@ -1,26 +0,0 @@
pragma solidity ^0.5.0;
/*
* Ownable
*
* Base contract with an owner.
* Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
*/
contract Ownable {
address public owner;
function Ownable() {
owner = msg.sender;
}
modifier onlyOwner() {
if (msg.sender == owner)
_;
}
function transfer(address newOwner) onlyOwner {
if (newOwner != address(0)) owner = newOwner;
}
}

@ -1,30 +0,0 @@
pragma solidity ^0.5.0;
/*
* PullPayment
* Base contract supporting async send for pull payments.
* Inherit from this contract and use asyncSend instead of send.
*/
contract PullPayment {
mapping(address => uint) public payments;
// store sent amount as credit to be pulled, called by payer
function asyncSend(address dest, uint amount) internal {
payments[dest] += amount;
}
// withdraw accumulated balance, called by payee
function withdrawPayments() {
address payee = msg.sender;
uint payment = payments[payee];
if (payment == 0) throw;
if (this.balance < payment) throw;
payments[payee] = 0;
if (!payee.send(payment)) {
throw;
}
}
}

@ -1,29 +0,0 @@
pragma solidity ^0.5.0;
/**
* Math operations with safety checks
*/
contract SafeMath {
function safeMul(uint a, uint b) internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function safeSub(uint a, uint b) internal returns (uint) {
assert(b <= a);
return a - b;
}
function safeAdd(uint a, uint b) internal returns (uint) {
uint c = a + b;
assert(c>=a && c>=b);
return c;
}
function assert(bool assertion) internal {
if (!assertion) throw;
}
}

@ -1,165 +0,0 @@
pragma solidity ^0.5.0;
/*
* Shareable
*
* Based on https://github.com/ethereum/dapp-bin/blob/master/wallet/wallet.sol
*
* inheritable "property" contract that enables methods to be protected by requiring the acquiescence of either a single, or, crucially, each of a number of, designated owners.
*
* usage:
* use modifiers onlyowner (just own owned) or onlymanyowners(hash), whereby the same hash must be provided by some number (specified in constructor) of the set of owners (specified in the constructor) before the interior is executed.
*/
contract Shareable {
// TYPES
// struct for the status of a pending operation.
struct PendingState {
uint yetNeeded;
uint ownersDone;
uint index;
}
// FIELDS
// the number of owners that must confirm the same operation before it is run.
uint public required;
// list of owners
uint[256] owners;
uint constant c_maxOwners = 250;
// index on the list of owners to allow reverse lookup
mapping(uint => uint) ownerIndex;
// the ongoing operations.
mapping(bytes32 => PendingState) pendings;
bytes32[] pendingsIndex;
// EVENTS
// this contract only has six types of events: it can accept a confirmation, in which case
// we record owner and operation (hash) alongside it.
event Confirmation(address owner, bytes32 operation);
event Revoke(address owner, bytes32 operation);
// MODIFIERS
// simple single-sig function modifier.
modifier onlyOwner {
if (isOwner(msg.sender))
_;
}
// multi-sig function modifier: the operation must have an intrinsic hash in order
// that later attempts can be realised as the same underlying operation and
// thus count as confirmations.
modifier onlymanyowners(bytes32 _operation) {
if (confirmAndCheck(_operation))
_;
}
// CONSTRUCTOR
// constructor is given number of sigs required to do protected "onlymanyowners" transactions
// as well as the selection of addresses capable of confirming them.
function Shareable(address[] _owners, uint _required) {
owners[1] = uint(msg.sender);
ownerIndex[uint(msg.sender)] = 1;
for (uint i = 0; i < _owners.length; ++i) {
owners[2 + i] = uint(_owners[i]);
ownerIndex[uint(_owners[i])] = 2 + i;
}
required = _required;
}
// METHODS
// Revokes a prior confirmation of the given operation
function revoke(bytes32 _operation) external {
uint index = ownerIndex[uint(msg.sender)];
// make sure they're an owner
if (index == 0) return;
uint ownerIndexBit = 2**index;
var pending = pendings[_operation];
if (pending.ownersDone & ownerIndexBit > 0) {
pending.yetNeeded++;
pending.ownersDone -= ownerIndexBit;
Revoke(msg.sender, _operation);
}
}
// Gets an owner by 0-indexed position (using numOwners as the count)
function getOwner(uint ownerIndex) external constant returns (address) {
return address(owners[ownerIndex + 1]);
}
function isOwner(address _addr) returns (bool) {
return ownerIndex[uint(_addr)] > 0;
}
function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool) {
var pending = pendings[_operation];
uint index = ownerIndex[uint(_owner)];
// make sure they're an owner
if (index == 0) return false;
// determine the bit to set for this owner.
uint ownerIndexBit = 2**index;
return !(pending.ownersDone & ownerIndexBit == 0);
}
// INTERNAL METHODS
function confirmAndCheck(bytes32 _operation) internal returns (bool) {
// determine what index the present sender is:
uint index = ownerIndex[uint(msg.sender)];
// make sure they're an owner
if (index == 0) return;
var pending = pendings[_operation];
// if we're not yet working on this operation, switch over and reset the confirmation status.
if (pending.yetNeeded == 0) {
// reset count of confirmations needed.
pending.yetNeeded = required;
// reset which owners have confirmed (none) - set our bitmap to 0.
pending.ownersDone = 0;
pending.index = pendingsIndex.length++;
pendingsIndex[pending.index] = _operation;
}
// determine the bit to set for this owner.
uint ownerIndexBit = 2**index;
// make sure we (the message sender) haven't confirmed this operation previously.
if (pending.ownersDone & ownerIndexBit == 0) {
Confirmation(msg.sender, _operation);
// ok - check if count is enough to go ahead.
if (pending.yetNeeded <= 1) {
// enough confirmations: reset and run interior.
delete pendingsIndex[pendings[_operation].index];
delete pendings[_operation];
return true;
}
else
{
// not enough: record that this owner in particular confirmed.
pending.yetNeeded--;
pending.ownersDone |= ownerIndexBit;
}
}
}
function clearPending() internal {
uint length = pendingsIndex.length;
for (uint i = 0; i < length; ++i)
if (pendingsIndex[i] != 0)
delete pendings[pendingsIndex[i]];
delete pendingsIndex;
}
}

@ -1,28 +0,0 @@
pragma solidity ^0.5.0;
import "./Ownable.sol";
/*
* Stoppable
* Abstract contract that allows children to implement an
* emergency stop mechanism.
*/
contract Stoppable is Ownable {
bool public stopped;
modifier stopInEmergency { if (!stopped) _; }
modifier onlyInEmergency { if (stopped) _; }
// called by the owner on emergency, triggers stopped state
function emergencyStop() external onlyOwner {
stopped = true;
}
// called by the owner on end of emergency, returns to normal state
function release() external onlyOwner onlyInEmergency {
stopped = false;
}
}

@ -1,29 +0,0 @@
pragma solidity ^0.5.0;
import './ERC20Basic.sol';
import '../SafeMath.sol';
/*
* Basic token
* Basic version of StandardToken, with no allowances
*/
contract BasicToken is ERC20Basic, SafeMath {
mapping(address => uint) balances;
function transfer(address _to, uint _value) {
if (balances[msg.sender] < _value) {
throw;
}
balances[msg.sender] = safeSub(balances[msg.sender], _value);
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
}
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
}

@ -1,38 +0,0 @@
pragma solidity ^0.5.0;
import "./StandardToken.sol";
/*
* CrowdsaleToken
*
* Simple ERC20 Token example, with crowdsale token creation
*/
contract CrowdsaleToken is StandardToken {
string public name = "CrowdsaleToken";
string public symbol = "CRW";
uint public decimals = 18;
// 1 ether = 500 example tokens
uint PRICE = 500;
function () payable {
createTokens(msg.sender);
}
function createTokens(address recipient) payable {
if (msg.value == 0) throw;
uint tokens = safeMul(msg.value, getPrice());
totalSupply = safeAdd(totalSupply, tokens);
balances[recipient] = safeAdd(balances[recipient], tokens);
}
// replace this with any other price function
function getPrice() constant returns (uint result){
return PRICE;
}
}

@ -1,18 +0,0 @@
pragma solidity ^0.5.0;
/*
* ERC20 interface
* see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 {
uint public totalSupply;
function balanceOf(address who) constant returns (uint);
function allowance(address owner, address spender) constant returns (uint);
function transfer(address to, uint value) returns (bool ok);
function transferFrom(address from, address to, uint value) returns (bool ok);
function approve(address spender, uint value) returns (bool ok);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}

@ -1,14 +0,0 @@
pragma solidity ^0.5.0;
/*
* ERC20Basic
* Simpler version of ERC20 interface
* see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20Basic {
uint public totalSupply;
function balanceOf(address who) constant returns (uint);
function transfer(address to, uint value);
event Transfer(address indexed from, address indexed to, uint value);
}

@ -1,26 +0,0 @@
pragma solidity ^0.5.0;
import "./StandardToken.sol";
/*
* SimpleToken
*
* Very simple ERC20 Token example, where all tokens are pre-assigned
* to the creator. Note they can later distribute these tokens
* as they wish using `transfer` and other `StandardToken` functions.
*/
contract SimpleToken is StandardToken {
string public name = "SimpleToken";
string public symbol = "SIM";
uint public decimals = 18;
uint public INITIAL_SUPPLY = 10000;
function SimpleToken() {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
}
}

@ -1,49 +0,0 @@
pragma solidity ^0.5.0;
import './ERC20.sol';
import '../SafeMath.sol';
/**
* ERC20 token
*
* https://github.com/ethereum/EIPs/issues/20
* Based on code by FirstBlood:
* https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
contract StandardToken is ERC20, SafeMath {
mapping(address => uint) balances;
mapping (address => mapping (address => uint)) allowed;
function transfer(address _to, uint _value) returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], _value);
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint _value) returns (bool success) {
var _allowance = allowed[_from][msg.sender];
balances[_to] = safeAdd(balances[_to], _value);
balances[_from] = safeSub(balances[_from], _value);
allowed[_from][msg.sender] = safeSub(_allowance, _value);
Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
function approve(address _spender, uint _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint remaining) {
return allowed[_owner][_spender];
}
}

@ -5,234 +5,52 @@ const getInstrumentedVersion = require('./../lib/instrumentSolidity.js');
const util = require('./util/util.js');
describe('Battery test of production contracts: OpenZeppelin', () => {
it('should compile after instrumenting zeppelin-solidity/Bounty.sol', () => {
const bounty = getInstrumentedVersion(util.getCode('zeppelin/Bounty.sol'), 'Bounty.sol');
const ownable = getInstrumentedVersion(util.getCode('zeppelin/Ownable.sol'), 'Ownable.sol');
const pullPayment = getInstrumentedVersion(util.getCode('zeppelin/PullPayment.sol'), 'PullPayment.sol');
const killable = getInstrumentedVersion(util.getCode('zeppelin/Killable.sol'), 'Killable.sol');
const inputs = {
'Ownable.sol': ownable.contract,
'PullPayment.sol': pullPayment.contract,
'Killable.sol': killable.contract,
'Bounty.sol': bounty.contract,
};
const output = solc.compile({
sources: inputs,
}, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/Claimable.sol', () => {
const claimable = getInstrumentedVersion(util.getCode('zeppelin/Claimable.sol'), 'Claimable.sol');
const ownable = getInstrumentedVersion(util.getCode('zeppelin/Ownable.sol'), 'Ownable.sol');
const inputs = {
'Ownable.sol': ownable.contract,
'Claimable.sol': claimable.contract,
};
const output = solc.compile({
sources: inputs,
}, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/DayLimit.sol', () => {
const dayLimit = getInstrumentedVersion(util.getCode('zeppelin/DayLimit.sol'), 'DayLimit.sol');
const ownable = getInstrumentedVersion(util.getCode('zeppelin/Ownable.sol'), 'Ownable.sol');
const shareable = getInstrumentedVersion(util.getCode('zeppelin/Shareable.sol'), 'Shareable.sol');
const inputs = {
'Ownable.sol': ownable.contract,
'DayLimit.sol': dayLimit.contract,
'Shareable.sol': shareable.contract,
};
const output = solc.compile({
sources: inputs,
}, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/Killable.sol', () => {
const ownable = getInstrumentedVersion(util.getCode('zeppelin/Ownable.sol'), 'Ownable.sol');
const killable = getInstrumentedVersion(util.getCode('zeppelin/Killable.sol'), 'Killable.sol');
const inputs = {
'Ownable.sol': ownable.contract,
'Killable.sol': killable.contract,
};
const output = solc.compile({
sources: inputs,
}, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/LimitBalance.sol', () => {
const contract = util.getCode('zeppelin/LimitBalance.sol');
const info = getInstrumentedVersion(contract, 'test.sol');
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/Migrations.sol', () => {
const ownable = getInstrumentedVersion(util.getCode('zeppelin/Ownable.sol'), 'Ownable.sol');
const migrations = getInstrumentedVersion(util.getCode('zeppelin/Migrations.sol'), 'Migrations.sol');
const inputs = {
'Ownable.sol': ownable.contract,
'Migrations.sol': migrations.contract,
};
const output = solc.compile({
sources: inputs,
}, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/Multisig.sol', () => {
const contract = util.getCode('zeppelin/Multisig.sol');
const info = getInstrumentedVersion(contract, 'test.sol');
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/MultisigWallet.sol', () => {
const multisig = getInstrumentedVersion(util.getCode('zeppelin/Multisig.sol'), 'Multisig.sol');
const shareable = getInstrumentedVersion(util.getCode('zeppelin/Shareable.sol'), 'Shareable.sol');
const dayLimit = getInstrumentedVersion(util.getCode('zeppelin/DayLimit.sol'), 'DayLimit.sol');
const multisigWallet = getInstrumentedVersion(util.getCode('zeppelin/MultisigWallet.sol'), 'MultisigWallet.sol');
const inputs = {
'Multisig.sol': multisig.contract,
'Shareable.sol': shareable.contract,
'DayLimit.sol': dayLimit.contract,
'MultisigWallet.sol': multisigWallet.contract,
};
const output = solc.compile({
sources: inputs,
}, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/Ownable.sol', () => {
const contract = util.getCode('zeppelin/Ownable.sol');
const info = getInstrumentedVersion(contract, 'test.sol');
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/PullPayment.sol', () => {
const contract = util.getCode('zeppelin/PullPayment.sol');
const info = getInstrumentedVersion(contract, 'test.sol');
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/SafeMath.sol', () => {
const contract = util.getCode('zeppelin/SafeMath.sol');
const info = getInstrumentedVersion(contract, 'test.sol');
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/Shareable.sol', () => {
const contract = util.getCode('zeppelin/Shareable.sol');
const info = getInstrumentedVersion(contract, 'test.sol');
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/Stoppable.sol', () => {
const stoppable = getInstrumentedVersion(util.getCode('zeppelin/Stoppable.sol'), 'Stoppable.sol');
const ownable = getInstrumentedVersion(util.getCode('zeppelin/Ownable.sol'), 'Ownable.sol');
const inputs = {
'Ownable.sol': ownable.contract,
'Stoppable.sol': stoppable.contract,
};
const output = solc.compile({
sources: inputs,
}, 1);
util.report(output.errors);
});
// --- Tokens ---
it('should compile after instrumenting zeppelin-solidity/BasicToken.sol', () => {
const basicToken = getInstrumentedVersion(util.getCode('zeppelin/token/BasicToken.sol'), 'BasicToken.sol');
const safeMath = getInstrumentedVersion(util.getCode('zeppelin/SafeMath.sol'), 'SafeMath.sol');
const ERC20Basic = getInstrumentedVersion(util.getCode('zeppelin/token/ERC20Basic.sol'), 'ERC20Basic.sol');
const inputs = {
'ERC20Basic.sol': ERC20Basic.contract,
'SafeMath.sol': safeMath.contract,
'BasicToken.sol': basicToken.contract,
};
const output = solc.compile({
sources: inputs,
}, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/CrowdsaleToken.sol', () => {
const crowdsaleToken = getInstrumentedVersion(util.getCode('zeppelin/token/CrowdsaleToken.sol'), 'CrowdsaleToken.sol');
const standardToken = getInstrumentedVersion(util.getCode('zeppelin/token/StandardToken.sol'), 'StandardToken.sol');
const ERC20Basic = getInstrumentedVersion(util.getCode('zeppelin/token/ERC20Basic.sol'), 'ERC20Basic.sol');
const ERC20 = getInstrumentedVersion(util.getCode('zeppelin/token/ERC20.sol'), 'ERC20.sol');
const safeMath = getInstrumentedVersion(util.getCode('zeppelin/SafeMath.sol'), 'SafeMath.sol');
const inputs = {
'StandardToken.sol': standardToken.contract,
'CrowdsaleToken.sol': crowdsaleToken.contract,
'ERC20Basic.sol': ERC20Basic.contract,
'ERC20.sol': ERC20.contract,
'SafeMath.sol': safeMath.contract,
};
const output = solc.compile({
sources: inputs,
}, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/ERC20.sol', () => {
const contract = util.getCode('zeppelin/token/ERC20.sol');
const info = getInstrumentedVersion(contract, 'test.sol');
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/ERC20Basic.sol', () => {
const contract = util.getCode('zeppelin/token/ERC20Basic.sol');
const info = getInstrumentedVersion(contract, 'test.sol');
const output = solc.compile(info.contract, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/SimpleToken.sol', () => {
const standardToken = getInstrumentedVersion(util.getCode('zeppelin/token/StandardToken.sol'), 'StandardToken.sol');
const simpleToken = getInstrumentedVersion(util.getCode('zeppelin/token/SimpleToken.sol'), 'SimpleToken.sol');
const ERC20 = getInstrumentedVersion(util.getCode('zeppelin/token/ERC20.sol'), 'ERC20.sol');
const safeMath = getInstrumentedVersion(util.getCode('zeppelin/SafeMath.sol'), 'SafeMath.sol');
const inputs = {
'StandardToken.sol': standardToken.contract,
'SimpleToken.sol': simpleToken.contract,
'ERC20.sol': ERC20.contract,
'SafeMath.sol': safeMath.contract,
};
const output = solc.compile({
sources: inputs,
}, 1);
util.report(output.errors);
});
it('should compile after instrumenting zeppelin-solidity/StandardToken.sol', () => {
const ERC20Basic = getInstrumentedVersion(util.getCode('zeppelin/token/ERC20Basic.sol'), 'ERC20Basic.sol');
const standardToken = getInstrumentedVersion(util.getCode('zeppelin/token/StandardToken.sol'), 'StandardToken.sol');
const safeMath = getInstrumentedVersion(util.getCode('zeppelin/SafeMath.sol'), 'SafeMath.sol');
const ERC20 = getInstrumentedVersion(util.getCode('zeppelin/token/ERC20.sol'), 'ERC20.sol');
const inputs = {
'ERC20Basic.sol': ERC20Basic.contract,
'SafeMath.sol': safeMath.contract,
'StandardToken.sol': standardToken.contract,
'ERC20.sol': ERC20.contract,
};
const output = solc.compile({
sources: inputs,
}, 1);
it('should compile after instrumenting ConditionalEscrow.sol', () => {
const conditionalEscrow = getInstrumentedVersion(util.getCode('zeppelin/contracts/payment/escrow/ConditionalEscrow.sol'), 'ConditionalEscrow.sol');
const escrow = getInstrumentedVersion(util.getCode('zeppelin/contracts/payment/escrow/Escrow.sol'), 'Escrow.sol');
const safeMath = getInstrumentedVersion(util.getCode('zeppelin/contracts/math/SafeMath.sol'), 'SafeMath.sol');
const secondary = getInstrumentedVersion(util.getCode('zeppelin/contracts/ownership/Secondary.sol'), 'Secondary.sol');
const input = JSON.stringify({
language: 'Solidity',
sources: {
'ConditionalEscrow.sol': { content: conditionalEscrow.contract },
'Escrow.sol': { content: escrow.contract},
'SafeMath.sol': { content: safeMath.contract},
'Secondary.sol': { content: secondary.contract},
},
settings: {
remappings: ["math/=", "ownership/=" ]
}
});
const output = JSON.parse(solc.compile(input));
util.report(output.errors);
});
it('should compile after instrumenting FinalizableCrowdsale', () => {
const finalizableCrowdsale = getInstrumentedVersion(util.getCode('zeppelin/contracts/crowdsale/distribution/FinalizableCrowdsale.sol'), 'FinalizableCrowdsale.sol');
const timedCrowdsale = getInstrumentedVersion(util.getCode('zeppelin/contracts/crowdsale/validation/TimedCrowdsale.sol'), 'TimedCrowdsale.sol');
const safeMath = getInstrumentedVersion(util.getCode('zeppelin/contracts/math/SafeMath.sol'), 'SafeMath.sol');
const crowdsale = getInstrumentedVersion(util.getCode('zeppelin/contracts/crowdsale/Crowdsale.sol'), 'Crowdsale.sol');
const ierc20 = getInstrumentedVersion(util.getCode('zeppelin/contracts/token/ERC20/IERC20.sol'), 'IERC20.sol');
const safeErc20 = getInstrumentedVersion(util.getCode('zeppelin/contracts/token/ERC20/SafeERC20.sol'), 'SafeERC20.sol');
const reentrancyGuard = getInstrumentedVersion(util.getCode('zeppelin/contracts/utils/ReentrancyGuard.sol'), 'ReentrancyGuard.sol');
const input = JSON.stringify({
language: 'Solidity',
sources: {
'FinalizableCrowdsale.sol': { content: finalizableCrowdsale.contract },
'TimedCrowdsale.sol': { content: timedCrowdsale.contract},
'SafeMath.sol': { content: safeMath.contract},
'Crowdsale.sol': { content: crowdsale.contract},
'IERC20.sol': { content: ierc20.contract},
'SafeERC20.sol': { content: safeErc20.contract},
'ReentrancyGuard.sol': { content: reentrancyGuard.contract},
},
settings: {
remappings: ["math/=", "token/ERC20/=", "utils/=", "crowdsale/=", "validation/="]
}
});
const output = JSON.parse(solc.compile(input));
util.report(output.errors);
});
});

Loading…
Cancel
Save