-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Escrows #1014
Merged
Merged
Escrows #1014
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2d2075a
Added basic Escrow
nventuro b879f4c
PullPayment now uses an Escrow, removing all trust from the contract
nventuro 48b64ce
Abstracted the Escrow tests to a behaviour
nventuro 3600240
Added ConditionalEscrow
nventuro fe63f2e
Added RefundableEscrow.
nventuro 3a33ffb
RefundableCrowdsale now uses a RefundEscrow, removed RefundVault.
nventuro d389fd3
Merge branch 'master' into feat/escrow
nventuro e01edb3
Renaming after code review.
nventuro 5dfb9ce
Added log test helper.
nventuro 6166248
Now allowing empty deposits and withdrawals.
nventuro cd84c37
Style fixes.
nventuro dabb3d7
Minor review comments.
nventuro 4422858
Add Deposited and Withdrawn events, removed Refunded
nventuro be8d65f
The base Escrow is now Ownable, users of it (owners) must provide metβ¦
nventuro 597aba7
Merge branch 'master' into feat/escrow
frangio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import EVMRevert from '../helpers/EVMRevert'; | ||
import { inLogs } from '../helpers/expectEvent'; | ||
|
||
const BigNumber = web3.BigNumber; | ||
|
||
|
@@ -40,8 +41,7 @@ contract('RefundEscrow', function ([owner, beneficiary, refundee1, refundee2]) { | |
|
||
const receipt = await this.escrow.close({ from: owner }); | ||
|
||
receipt.logs.length.should.equal(1); | ||
receipt.logs[0].event.should.equal('Closed'); | ||
await inLogs(receipt.logs, 'Closed'); | ||
}); | ||
|
||
context('closed state', function () { | ||
|
@@ -73,8 +73,7 @@ contract('RefundEscrow', function ([owner, beneficiary, refundee1, refundee2]) { | |
|
||
const receipt = await this.escrow.enableRefunds({ from: owner }); | ||
|
||
receipt.logs.length.should.equal(1); | ||
receipt.logs[0].event.should.equal('RefundsEnabled'); | ||
inLogs(receipt.logs, 'RefundsEnabled'); | ||
}); | ||
|
||
context('refund state', function () { | ||
|
@@ -96,9 +95,7 @@ contract('RefundEscrow', function ([owner, beneficiary, refundee1, refundee2]) { | |
|
||
refundeeFinalBalance.sub(refundeeInitialBalance).should.be.bignumber.equal(amount); | ||
|
||
receipt.logs.length.should.equal(1); | ||
receipt.logs[0].event.should.equal('Refunded'); | ||
receipt.logs[0].args.refundee.should.equal(refundee); | ||
inLogs(receipt.logs, 'Refunded', { refundee }); | ||
receipt.logs[0].args.weiAmount.should.be.bignumber.equal(amount); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notice that the helper returns the event, so you can do const event = expectEvent.inLogs(receipt.logs, 'Refunded', { refundee });
event.args.weiAmount.should.be.bignumber.equal(amount); In this way you also stop relying on the event being at index 0. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neat, I missed that bit, ty! |
||
} | ||
}); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The preferred usage for better readability is:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that made more sense, but preferred to copy the existing code style :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's both styles, unfortunately.
https://github.com/OpenZeppelin/openzeppelin-solidity/blob/f18c3bc438b366f9cb3a8613f5be160c2cbced5e/test/ownership/Whitelist.test.js#L49-L53