Skip to content

Commit

Permalink
Merge pull request #14 from 1Hive/forwarding-fee-unit-test
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziovigevani committed Jul 19, 2019
2 parents 51763f6 + 66e03bc commit 2d717e3
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 4 deletions.
47 changes: 47 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"editor.tabSize": 2,
"editor.formatOnSave": true,
"prettier.singleQuote": true,
"prettier.trailingComma": "es5",
"prettier.semi": false,
"prettier.bracketSpacing": true,
"prettier.printWidth": 120,

"solidity.packageDefaultDependenciesContractsDirectory": "",
"solidity.packageDefaultDependenciesDirectory": "node_modules",

"solidity.soliumRules": {
"security/no-low-level-calls": "off",
"security/no-inline-assembly": "off",
"emit": "off",
"error-reason": "off",
"imports-on-top": "error",
"variable-declarations": "error",
"array-declarations": "error",
"operator-whitespace": "error",
"conditionals-whitespace": "error",
"comma-whitespace": "error",
"semicolon-whitespace": "error",
"function-whitespace": "error",
"lbrace": "error",
"mixedcase": "error",
"camelcase": "error",
"uppercase": "error",
"no-empty-blocks": "error",
"no-unused-vars": "error",
"quotes": "error",
"blank-lines": "error",
"indentation": "error",
"arg-overflow": ["error", 8],
"whitespace": "error",
"deprecated-suicide": "error",
"pragma-on-top": "error",
"function-order": "error",
"no-constant": "error",
"value-in-payable": "error",
"max-len": "error",
"visibility-first": "error",
"linebreak-style": "error"
},
"solidity.validationDelay": 0
}
23 changes: 19 additions & 4 deletions test/LockTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ contract('Lock', ([rootAccount, ...accounts]) => {
assert.isTrue(hasInitialized)
})

it("get's forwarding fee information", async () => {
const [actualToken, actualLockAmount] = Object.values(await lockForwarder.forwardFee())

assert.strictEqual(actualToken, mockErc20.address)
assert.equal(actualLockAmount, INITIAL_LOCK_AMOUNT)
})

it('checks it is forwarder', async () => {
assert.isTrue(await lockForwarder.isForwarder())
})
Expand Down Expand Up @@ -94,7 +101,9 @@ contract('Lock', ([rootAccount, ...accounts]) => {

//should this test be done separately in say, 3 tests?
it('forwards action successfully', async () => {
await mockErc20.approve(lockForwarder.address, INITIAL_LOCK_AMOUNT, { from: rootAccount })
await mockErc20.approve(lockForwarder.address, INITIAL_LOCK_AMOUNT, {
from: rootAccount,
})

const expectedCounter = 1
const expectedLockerBalance = MOCK_TOKEN_BALANCE - INITIAL_LOCK_AMOUNT
Expand Down Expand Up @@ -159,7 +168,9 @@ contract('Lock', ([rootAccount, ...accounts]) => {

//increase time
await lockForwarder.mockIncreaseTime(INITIAL_LOCK_DURATION + 1)
await lockForwarder.withdrawTokens(locksToWithdraw, { from: rootAccount })
await lockForwarder.withdrawTokens(locksToWithdraw, {
from: rootAccount,
})

const actualLockCount = await lockForwarder.getWithdrawLocksCount(rootAccount)
const actualBalance = await mockErc20.balanceOf(rootAccount)
Expand Down Expand Up @@ -198,7 +209,9 @@ contract('Lock', ([rootAccount, ...accounts]) => {
await lockForwarder.changeLockDuration(newLockDuration)
//current locks's unlockTime is 60
await lockForwarder.mockIncreaseTime(INITIAL_LOCK_DURATION + 1)
await lockForwarder.withdrawTokens(locksToWithdraw, { from: rootAccount })
await lockForwarder.withdrawTokens(locksToWithdraw, {
from: rootAccount,
})

const actualLockCount = await lockForwarder.getWithdrawLocksCount(rootAccount)
assert.equal(actualLockCount, expectedLockCount)
Expand All @@ -225,7 +238,9 @@ contract('Lock', ([rootAccount, ...accounts]) => {
await lockForwarder.changeLockAmount(newLockAmount)
//current locks's lockAmount is 10
await lockForwarder.mockIncreaseTime(INITIAL_LOCK_DURATION + 1)
await lockForwarder.withdrawTokens(locksToWithdraw, { from: rootAccount })
await lockForwarder.withdrawTokens(locksToWithdraw, {
from: rootAccount,
})

const actualBalance = await mockErc20.balanceOf(rootAccount)
assert.equal(actualBalance, expectedBalance)
Expand Down

0 comments on commit 2d717e3

Please sign in to comment.