Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Internal improvement: Move compile-solidity tests to a new separate package #5445

Merged
merged 20 commits into from
Sep 13, 2022

Conversation

eggplantzzz
Copy link
Contributor

@eggplantzzz eggplantzzz commented Aug 16, 2022

While bootstrapping Truffle, you will notice a warning printed by lerna about a circular dependency. The tests for @truffle/compile-solidity use @truffle/resolver (as it is required in the config for certain flows) and @truffle/resolver has a dependency on @truffle/compile-solidity. To eliminate this circular dependency, these tests have been moved to their own package (and converted to TypeScript for kicks!).

Note that this PR is against the moreTS branch which is the branch where @truffle/compile-solidity is fully converted (almost, not the tests) to TypeScript in this PR.

Copy link
Contributor

@haltman-at haltman-at left a comment

Choose a reason for hiding this comment

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

My main note here is that there are a bunch of places where assert is used in a way that isn't the closest match to the intent, I would suggest changing those. A bunch of those are pre-existing so maybe that's not entirely necessary? But I thought it was worth pointing out at least.

@@ -129,8 +133,11 @@ describe("compileWithPragmaAnalysis", function () {
options: config,
paths: [path.join(sourceDirectory, "withImports", "C.sol")]
});
if (!compilations) {
Copy link
Contributor

@haltman-at haltman-at Aug 25, 2022

Choose a reason for hiding this comment

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

If you're doing if (...) { assert.fail() }, you're not using assertions properly. I think the right way to do this in chai would be assert.isDefined(compilations, "Compilations were not created").

packages/compile-solidity-tests/test/run.ts Outdated Show resolved Hide resolved
packages/compile-solidity-tests/package.json Outdated Show resolved Hide resolved
@eggplantzzz
Copy link
Contributor Author

Sounds good to me @haltman-at about the massaging of the chai assertions!

@eggplantzzz
Copy link
Contributor Author

@haltman-at it seems like chai has no preference for assert(a === b) or assert.equal(a, b). They have examples of both kinds of usage in the docs https://www.chaijs.com/api/assert/. I changed some of them over. Do you have a preference for assert.equal?

@haltman-at
Copy link
Contributor

@haltman-at it seems like chai has no preference for assert(a === b) or assert.equal(a, b). They have examples of both kinds of usage in the docs https://www.chaijs.com/api/assert/. I changed some of them over. Do you have a preference for assert.equal?

Yeah the latter generates much better error messages when it fails.

@eggplantzzz
Copy link
Contributor Author

Oh that's when it gives you the actual values of the things being tested on failure in the test report. That's always super helpful.

Copy link
Contributor

@haltman-at haltman-at left a comment

Choose a reason for hiding this comment

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

(Actually, just noticed a few asserts that could use assert.include!)

packages/compile-solidity-tests/test/supplier.ts Outdated Show resolved Hide resolved
packages/compile-solidity-tests/test/supplier.ts Outdated Show resolved Hide resolved
packages/compile-solidity-tests/test/supplier.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@haltman-at haltman-at left a comment

Choose a reason for hiding this comment

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

OK, seems good to me, except package versions need to be updated again due to the release last week!

"test": "./scripts/test.sh"
},
"devDependencies": {
"@truffle/artifactor": "^4.0.167",
Copy link
Contributor

Choose a reason for hiding this comment

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

These need to be updated again.

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.

3 participants