Skip to content

[WIP] More tests #744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/utils/DAOFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ contract DAOFactory is Initializable {
require(locks[address(_avatar)].sender == msg.sender, "sender is not holding the lock");
// Mint token and reputation for founders:
for (uint256 i = 0; i < _founders.length; i++) {
require(_founders[i] != address(0));
require(_founders[i] != address(0), "founder address cannot be 0");
if (_foundersTokenAmount[i] > 0) {
Controller(
_avatar.owner()).mintTokens(_foundersTokenAmount[i], _founders[i]);
Expand Down
67 changes: 66 additions & 1 deletion test/daofactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@ contract('DaoFactory', function(accounts) {
helpers.assertVMException(ex);
}

try {
await registration.daoFactory.forgeOrg("testOrg",nativeTokenData,[accounts[0]],[],[11],[0,0,0],{gas:constants.ARC_GAS_LIMIT});
assert(false,"should revert because token array size is 0");
}
catch(ex){
helpers.assertVMException(ex);
}

try {
await registration.daoFactory.forgeOrg("testOrg",
nativeTokenData,[accounts[0],
Expand All @@ -236,7 +244,7 @@ contract('DaoFactory', function(accounts) {
[amountToMint,amountToMint],
[0,0,0],
{gas:constants.ARC_GAS_LIMIT});
assert(false,"should revert because account is 0");
assert(false,"should revert because account is 0");
}
catch(ex){
helpers.assertVMException(ex);
Expand Down Expand Up @@ -287,6 +295,63 @@ contract('DaoFactory', function(accounts) {
assert.equal(tx.logs[2].args._avatar, avatar.address);
});


it("setSchemes to SchemeMock and addFounders wrong lengths", async function() {
var amountToMint = 10;
await setup(accounts,amountToMint,amountToMint);
var foundersArray = [];
var founderReputation = [];
var founderToken = [];

try {
await registration.daoFactory.addFounders(avatar.address,foundersArray,founderReputation,founderToken,{gas:constants.ARC_GAS_LIMIT});
assert(false, "should revert because founders list is empty");
}
catch(ex){
helpers.assertVMException(ex);
}

var i;
var numberOfFounders = 60;
for (i=0;i<numberOfFounders;i++) {
foundersArray[i] = accounts[1];
founderReputation[i] = 1;
founderToken[i] = 1;

}
founderToken[i] = 1;
try {
await registration.daoFactory.addFounders(avatar.address,foundersArray,founderReputation,founderToken,{gas:constants.ARC_GAS_LIMIT});
assert(false, "should revert because founders list is shorter than tokens");
} catch(ex) {
helpers.assertVMException(ex);
}
founderToken.pop();
founderReputation[i] = 1;
try {
await registration.daoFactory.addFounders(avatar.address,foundersArray,founderReputation,founderToken,{gas:constants.ARC_GAS_LIMIT});
assert(false, "should revert because founders list is shorter than reputations");
} catch(ex) {
helpers.assertVMException(ex);
}
founderReputation.pop();
foundersArray[i-1] = helpers.NULL_ADDRESS;
try {
await registration.daoFactory.addFounders(avatar.address,foundersArray,founderReputation,founderToken,{gas:constants.ARC_GAS_LIMIT});
assert(false, "should revert because founder address cannot be 0");
} catch(ex) {
helpers.assertVMException(ex);
}
foundersArray[i-1] = accounts[1];
founderReputation[i-1] = 0;
founderToken[i-1] = 0;
await registration.daoFactory.addFounders(avatar.address,foundersArray,founderReputation,founderToken,{gas:constants.ARC_GAS_LIMIT});
var rep = await reputation.balanceOf(accounts[1],{from:accounts[1]});
assert.equal(rep.toNumber(),numberOfFounders - 1);
var founderBalance = await daoToken.balanceOf(accounts[1],{from:accounts[1]});
assert.equal(founderBalance.toNumber(),numberOfFounders - 1);
});

it("forgeOrg different version", async function() {
var amountToMint = 10;
await setup(accounts,amountToMint,amountToMint);
Expand Down
17 changes: 17 additions & 0 deletions test/reputationfromtoken.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ contract('ReputationFromToken and RepAllocation', accounts => {
assert.equal(tx.logs[0].args._sender,accounts[0]);
assert.equal(await testSetup.org.reputation.balanceOf(accounts[0]),1000);
assert.equal(await testSetup.org.reputation.balanceOf(accounts[1]),expected);

try {
await testSetup.reputationFromToken.redeem(accounts[1]);
assert(false, "cannot redeem twice");
} catch(error) {
helpers.assertVMException(error);
}
});

it("redeemWithSignature", async () => {
Expand Down Expand Up @@ -225,6 +232,16 @@ contract('ReputationFromToken and RepAllocation', accounts => {
assert.equal(await testSetup.org.reputation.balanceOf(accounts[1]),0);
});

it("cannot redeem before initialize", async () => {
try {
let reputationFromToken = await ReputationFromToken.new();
await reputationFromToken.redeem(accounts[1]);
assert(false, "cannot redeem before initialize");
} catch(error) {
helpers.assertVMException(error);
}
});

it("cannot initialize twice", async () => {
let testSetup = await setup(accounts);
try {
Expand Down
20 changes: 20 additions & 0 deletions test/schemeregistrar.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,26 @@ contract('SchemeRegistrar', accounts => {
assert.equal(tx.logs[0].event, "RemoveSchemeProposal");
});

it("proposeScheme cannot be 0", async function() {
var testSetup = await setup(accounts);
try {
await testSetup.schemeRegistrar.proposeScheme(
helpers.NULL_ADDRESS,
"0x00000000",
helpers.NULL_HASH);
} catch(ex) {
helpers.assertVMException(ex);
}
});

it("proposeToRemoveScheme cannot be 0", async function() {
var testSetup = await setup(accounts);
try {
await testSetup.schemeRegistrar.proposeToRemoveScheme(helpers.NULL_ADDRESS, helpers.NULL_HASH);
} catch(ex) {
helpers.assertVMException(ex);
}
});

it("execute proposeScheme and execute -yes - fee > 0 ", async function() {
var testSetup = await setup(accounts);
Expand Down