Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

test-helpers: Add missing pieces for aragonOS#53

Closed
bingen wants to merge 4 commits intomasterfrom
aragonOS
Closed

test-helpers: Add missing pieces for aragonOS#53
bingen wants to merge 4 commits intomasterfrom
aragonOS

Conversation

@bingen
Copy link
Copy Markdown

@bingen bingen commented Aug 7, 2020

No description provided.

Copy link
Copy Markdown
Contributor

@facuspagnuolo facuspagnuolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't apply some of these changes. Ideally, we were thinking to upgrade the test suites to Truffle 5 + web3 1.x along with adopting these test-helpers

"web3": "^1.0.0"
},
"dependencies": {
"chai": "^4.2.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is marked as peer dep I think, so it shouldn't be here


function getNewProxyAddress(receipt) {
return getEventArgument(receipt, 'NewAppProxy', 'proxy')
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't getInstalledApp enough? Look at this example

v: signedPayload.substr(130, 2) == '00' ? 27 : 28,
})
})
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Part of the idea of the whole migration to test helpers was to do it while upgrading to Truffle 5, carrying web3 1.x with it. Thus, I think we should remove the promisified versions

}
if(error.message.includes(THROW_ERROR_PREFIX_V4)) {
error.reason = error.message.replace(THROW_ERROR_PREFIX_V4, '').trim()
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below my comment about Truffle 5

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if we are assuming that we are always using truffle 5, shouldn’t remove the if completely? It is supposed to be for truffle 4 (see comment above), but it was not working for me without this fix.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good point, let's remove the if and align just on v5!

@sohkai sohkai changed the title test-helpers: Add missinng pieces for aragonOS test-helpers: Add missing pieces for aragonOS Aug 7, 2020
}
if(error.message.includes(THROW_ERROR_PREFIX_V4)) {
error.reason = error.message.replace(THROW_ERROR_PREFIX_V4, '').trim()
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good point, let's remove the if and align just on v5!

function decodeEvents(receipt, contractAbi, eventName) {
const rawLogs =
receipt.rawLogs || (receipt.receipt && receipt.receipt.rawLogs) || []
receipt.rawLogs || (receipt.receipt && receipt.receipt.rawLogs) || receipt.logs || []
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand this; the receipt.logs are already decoded, right?

async function isGanache(ctx) {
const isNodeResult = await isNode(ctx, GANACHE_NODE_ID)
if (isNodeResult === undefined) {
return web3.currentProvider.host === 'http://localhost:8545'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is really safe, as a local geth would also be running on this host and port by default, right?

injectWeb3,
...addresses,
...aragonOS,
...asserts,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I had actually wanted to avoid re-exporting these directly from index.js, especially not destructured.

I was hoping to get something like:

import { ANY_ENTITY } from '@aragon/contract-helpers-test/aragon-os'

For the user, but this turned out difficult to do.


Would appreciate any other suggestions, but otherwise I wonder if we should keep it for now as:

import { ANY_ENTITY } from '@aragon/contract-helpers-test/aragon-os/src/aragon-os'

Or export the entire object out, rather than destructuring it, so it looks like this to the user:

import { aragonOS } from '@aragon/contract-helpers-test/aragon-os'
const { ANY_ENTITY } = aragonOS

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this to optimize? Does it have a great impact in performance?
I did it this way to not have to remember the path of those methods, which is less convenient.

Copy link
Copy Markdown
Contributor

@sohkai sohkai Aug 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all, I wanted to provide some structure to group some utilities / asserts as not all of them may be useful in a vanilla project (e.g. Staking).

But yes, thinking about this, perhaps exporting the base assert part of the library would be better, and the only level of separation we have is with aragon-os (and perhaps in the future, aragon-court)!

// Truffle v5 provides `error.reason`, but v4 does not.
if (!error.reason && error.message.includes(THROW_ERROR_PREFIX)) {
error.reason = error.message.replace(THROW_ERROR_PREFIX, '').trim()
if (!error.reason) {
Copy link
Copy Markdown
Contributor

@0xGabi 0xGabi Aug 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing the migration to use buidler I notice that when running tests with the buidler-evm the error is not an object and just a string like the following:

Error: VM Exception while processing transaction: revert INIT_ALREADY_INITIALIZED

Followed by the error stack trace, for example:

at <UnrecognizedContract>.<unknown> (0xc9495a8dab51533490bf09007daf60c7a1fc207d)
    at <UnrecognizedContract>.<unknown> (0xc9495a8dab51533490bf09007daf60c7a1fc207d)
    at TruffleContract.initialize (/Users/gabi/code/Aragon/aragon-apps/node_modules/@nomiclabs/truffle-contract/lib/execute.js:169:26)
    at Context.<anonymous> (/Users/gabi/code/Aragon/aragon-apps/apps/finance/test/finance.js:128:32)
    at callFn (/Users/gabi/code/Aragon/aragon-apps/node_modules/mocha/lib/runnable.js:374:21)
    at Test.Runnable.run (/Users/gabi/code/Aragon/aragon-apps/node_modules/mocha/lib/runnable.js:361:7)
    at Runner.runTest (/Users/gabi/code/Aragon/aragon-apps/node_modules/mocha/lib/runner.js:619:10)
    at /Users/gabi/code/Aragon/aragon-apps/node_modules/mocha/lib/runner.js:745:12
    at next (/Users/gabi/code/Aragon/aragon-apps/node_modules/mocha/lib/runner.js:536:14)
    at /Users/gabi/code/Aragon/aragon-apps/node_modules/mocha/lib/runner.js:546:7
    at next (/Users/gabi/code/Aragon/aragon-apps/node_modules/mocha/lib/runner.js:448:14)
    at /Users/gabi/code/Aragon/aragon-apps/node_modules/mocha/lib/runner.js:509:7
    at done (/Users/gabi/code/Aragon/aragon-apps/node_modules/mocha/lib/runnable.js:314:5)
    at /Users/gabi/code/Aragon/aragon-apps/node_modules/mocha/lib/runnable.js:379:11
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

As a consequence every test that is currently using our assertRevert fails. Wonder if we may want to consider this case?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's add a case for it.

@facuspagnuolo
Copy link
Copy Markdown
Contributor

Closing in favor of aragon/aragonOS@c5cc374

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants