Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Add non zero check to deposit
Browse files Browse the repository at this point in the history
  • Loading branch information
asoong committed Jun 11, 2018
1 parent 3d80f4a commit 5e56d33
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
15 changes: 12 additions & 3 deletions contracts/core/Core.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ contract Core is

// Error messages
string constant ADDRESSES_MISSING = "Addresses must not be empty.";
string constant QUANTITES_MISSING = "Quantities must not be empty.";
string constant BATCH_INPUT_MISMATCH = "Addresses and quantities must be the same length.";
string constant QUANTITES_MISSING = "Quantities must not be empty.";
string constant ZERO_QUANTITY = "Quantity must be greater than zero.";

/* ============ State Variables ============ */

Expand All @@ -52,7 +53,15 @@ contract Core is

/* ============ Modifiers ============ */

// Confirm that all inputs are valid for batch transactions
modifier isNonZero(uint _quantity) {
require(
_quantity > 0,
ZERO_QUANTITY
);
_;
}

// Confirm that all inputs are valid for batch transactions
modifier isValidBatchTransaction(address[] _tokenAddresses, uint[] _quantities) {
// Confirm an empty _addresses array is not passed
require(
Expand All @@ -72,7 +81,6 @@ contract Core is
_;
}


/* ============ No Constructor ============ */

/* ============ Setter Functions ============ */
Expand Down Expand Up @@ -168,6 +176,7 @@ contract Core is
uint _quantity
)
public
isNonZero(_quantity)
{
// Call TransferProxy contract to transfer user tokens to Vault
TransferProxy(transferProxyAddress).transferToVault(
Expand Down
10 changes: 10 additions & 0 deletions test/core.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ contract("Core", (accounts) => {
expect(newOwnerBalance).to.be.bignumber.equal(existingOwnerVaultBalance.add(amountToDeposit));
});

describe("when the amount is zero", async () => {
before(async () => {
amountToDeposit = new BigNumber(0);
});

it("should revert", async () => {
await expectRevertError(subject());
});
});

describe("when the amount is not the full balance of the token for the owner", async () => {
before(async () => {
amountToDeposit = STANDARD_INITIAL_TOKENS.div(2);
Expand Down

0 comments on commit 5e56d33

Please sign in to comment.