-
Notifications
You must be signed in to change notification settings - Fork 13
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
test-helpers: re-organize, update to web3 1.0, and add utilities from dao-templates, react-boilerplate #43
Conversation
? await blockOrPromise() | ||
: await blockOrPromise | ||
} catch (error) { | ||
if (isGeth(ctx)) { |
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.
This part is a bit sketchy and taken from dao-templates.
I think this should still work on an Istanbul context, but I won't know until we try 😄.
In any case, my philosophy here is to ensure we can use the same utilities regardless of ganache or a real chain and we can certainly come back to this to fix it if it doesn't end up working well.
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.
LGTM!
bn(actual).toString(), | ||
bn(expected).toString(), |
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.
Bear in mind this may not work for different versions of BN, I prefer being flexible here. Calling .toString()
to any type of BN seems safer to me.
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.
Done in 9bebc4d.
function normalizeArg(arg) { | ||
if (isBN(arg)) { |
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 were some versions of web3-utils
that do not include isBN
.
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.
This is likely from the 0.2 series—I think since the 1.0 series started, and they moved over the bn.js
, this has existed.
return arg.toString() | ||
} else if (isAddress(arg)) { | ||
return toChecksumAddress(arg) | ||
} |
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.
Let's contemplate the case of comparing contracts with addresses: see #35 (comment)
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.
Oh interesting, so that's why that was there. I'll add it back!
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.
Done in 762277e.
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 like the new structure!
Co-authored-by: Gabriel Garcia <gabrielpk.18@gmail.com>
@@ -0,0 +1,13 @@ | |||
const EMPTY_BYTES = '0x' | |||
const ZERO_BYTES32 = | |||
'0x0000000000000000000000000000000000000000000000000000000000000000' |
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.
What about '0x' + '0'.repeat(64)
?
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.
Works as well! We can do so for addresses as well :).
Can you push a PR?
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.
Sure, I’ll do!
Replaces #30 with a more aggressive re-organization. Takes the useful utilities from
dao-templates
andaragon-react-boilerplate
(fixes #28).dcda933 is the primary commit with changes to add new or refactor existing utilities.
Utilities from
@aragon/contract-helpers-test
are now grouped into separate sections:root
: base utilities for Ethereum-related interactionsasserts
: Ethereum-related assertionsaragon-os
: aragonOS-related utilitiesaragon-os/asserts
: aragonOS-related assertionsIt now also includes the concept of a "configuration", shamelessly inspired by Open Zeppelin's own test helpers, that will detect the global truffle environment or allow a user to override and inject their own.
Future PRs: