Skip to content
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

Run clippy from the test script #1079

Merged
merged 5 commits into from Jul 26, 2022

Conversation

tcharding
Copy link
Member

@tcharding tcharding commented Jun 30, 2022

Currently we run clippy in CI using a github action. The invocation has a couple of shortcomings

  1. it does not lint the tests (this requires --all-targets)
  2. it does not lint the examples

I could not find a way to lint the examples without explicitly linting each example by name.

This PR does the following:

  • Fix clippy issues (patch 1-4)
  • Move the clippy control to test.sh
  • Add an env var DO_LINT to control it
  • Remove the separate CI job
  • Run the linter during the Test job using the stable toolchain.
  • Run clippy with --all-features AND --all-targets (only recently made possible).
  • Run each example explicitly

Thanks to dunxen for noticing all the errors in my psbt example on review and prompting me to work out why clippy was not running :)

@tcharding tcharding marked this pull request as draft June 30, 2022 01:23
@tcharding tcharding force-pushed the 06-30-clippy-in-test-script branch from 851df5c to 9e777c1 Compare July 19, 2022 05:53
@tcharding tcharding marked this pull request as ready for review July 19, 2022 05:53
@tcharding
Copy link
Member Author

Ha win! It found a bunch of warnings already, will fix and re-spin.

dunxen
dunxen previously approved these changes Jul 19, 2022
Copy link
Contributor

@dunxen dunxen left a comment

Choose a reason for hiding this comment

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

Nice :)
This LGTM (with the linting addressed)

sanket1729 added a commit that referenced this pull request Jul 19, 2022
cd2369b Run ecdsa-psbt example in test script (Tobin C. Harding)
6967c0e Add psbt example (Tobin Harding)

Pull request description:

  Add an example PSBT workflow. The workflow we simulate is that of a setup using a watch-only online wallet (contains only public keys) and a cold-storage wallet (contains the private keys).

  We create and update a PSBT using the watch-only wallet then pass the PSBT to the cold-storage wallet to sign.

  Partially resolves #892 (more done in #935).

  ## Note

  This PR includes a sub-module in `examples/psbt.rs` that implements ECDSA signing. This will hopefully eventually be merged into the main crate by way of #957.  We have three PRs that add examples/tests of PSBTs that need to do signing, in order to help us design a good AP in #957 I think it would be beneficial to complete and merge these three PRs.

  1. This PR (PSBT ECDSA example)
  2. PBST ECDSA integration test: #935
  3. PSBT taproot example: #999

  Note to self, this will need a change to `test.sh` if #1079 merges.

ACKs for top commit:
  apoelstra:
    ACK cd2369b
  sanket1729:
    ACK cd2369b. The example is clean, you can address the comments in followups.

Tree-SHA512: c4fb8ec631bf8bfc30534e8974b1f6c4bb7cc6def165a4ee2bb7aa73f5aa7fdc11d2000ca25792a4b534b2c5bf1592efe542ada14a9d702c7dfacbaa808f3aea
@tcharding tcharding force-pushed the 06-30-clippy-in-test-script branch from 9e777c1 to f43542c Compare July 20, 2022 03:03
@apoelstra
Copy link
Member

Looks good! I notice that the commit message for f43542c says you don't lint the tests or examples, as you would need --all-targets or explicitly enumerating the examples ... but it looks from the diff that you do do that.'

apoelstra
apoelstra previously approved these changes Jul 20, 2022
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK f43542c

@tcharding
Copy link
Member Author

I notice that the commit message for f43542c says you don't lint the tests or examples, as you would need --all-targets or explicitly enumerating the examples ... but it looks from the diff that you do do that.'

Drats, that's stale. I have a tendency to not read my own commit logs during rebase, chance to lift my game :)

@tcharding
Copy link
Member Author

oh, turns out it wasn't stale, just hard to read. I didn't bother changing the commit log and force pushing but I did update the PR description.

@tcharding
Copy link
Member Author

tcharding commented Jul 21, 2022

pfff! I just see that --all-targets has been changed to --targets=all, have to rebase now :( Bizzare, its only when running cargo tree

  • cargo tree --target=all
  • cargo clippy --all-targets

@tcharding
Copy link
Member Author

If #999 goes in before this, then we will need to add an additional call to clippy to lint the taproot-psbt example.

@tcharding
Copy link
Member Author

Changes in force push:

  • rebased, fixing multiple merge conflicts
  • Add clippy lint of new ecdsa-psbt example

apoelstra
apoelstra previously approved these changes Jul 25, 2022
Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 5134ba3

Copy link
Collaborator

@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

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

The first commit looks wrong, the rest looks OK.

src/util/misc.rs Outdated
let msg_hash = super::signed_msg_hash(&message);
let msg = secp256k1::Message::from(msg_hash);
let msg_hash = super::signed_msg_hash(message);
let msg = secp256k1::Message::from_slice(&msg_hash).expect("message");
Copy link
Collaborator

Choose a reason for hiding this comment

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

What? This looks like a step back.

Copy link
Member

Choose a reason for hiding this comment

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

Wow, I don't know how I missed this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh boy, that's a bad mistake, thanks @Kixunil. I did not check over my rebase well enough.

Clippy emits various warnings of type:

  warning: this expression creates a reference which is immediately
  dereferenced by the compiler

As suggested, remove the unnecessary explicit reference.
Clippy emits:

  warning: used `assert_eq!` with a literal bool

As suggested, use `assert` instead of `assert_eq`.
Clippy emits various warnings of form:

  warning: redundant clone

As suggested, remove the redundant calls to `clone`.
Clippy emits two warnings of form:

  warning: redundant field names in struct initialization

Remove the redundant field names and use struct short initialization
form.
Currently we run clippy in CI using a github action. The invocation has
a couple of shortcomings

1. it does not lint the tests (this requires `--all-targets`)
2. it does not lint the examples

I could not find a way to lint the examples without explicitly linting
each example by name.

Move the clippy control to `test.sh` and add an env var `DO_LINT` to
control it. Remove the explicit CI job and run the linter during the
`Test` job using the stable toolchain.
@tcharding
Copy link
Member Author

Changes in force push: Remove re-introduction of Message::from_slice from patch one. No other changes.

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 74f3a5a

Copy link
Collaborator

@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

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

ACK 74f3a5a

@apoelstra apoelstra merged commit 92b6211 into rust-bitcoin:master Jul 26, 2022
@tcharding tcharding deleted the 06-30-clippy-in-test-script branch July 27, 2022 00:54
ChallengeDev210 pushed a commit to ChallengeDev210/rust-bitcoin that referenced this pull request Aug 1, 2022
74f3a5a Run clippy from the test script (Tobin C. Harding)
aa8109a Use struct field short form (Tobin C. Harding)
d1a0540 Remove redundant calls to clone (Tobin C. Harding)
1964925 Use assert instead of assert_eq (Tobin C. Harding)
3173ef9 Remove unnecessary explicit reference (Tobin C. Harding)

Pull request description:

  Currently we run clippy in CI using a github action. The invocation has a couple of shortcomings

  1. it does not lint the tests (this requires `--all-targets`)
  2. it does not lint the examples

  I could not find a way to lint the examples without explicitly linting each example by name.

  **This PR does the following:**

  - Fix clippy issues (patch 1-4)
  - Move the clippy control to `test.sh`
  - Add an env var `DO_LINT` to control it
  - Remove the separate CI job
  - Run the linter during the `Test` job using the stable toolchain.
  - Run clippy with ` --all-features` AND `--all-targets` (only recently made possible).
  - Run each example explicitly

  Thanks to dunxen for noticing all the errors in my psbt example on review and prompting me to work out why clippy was not running :)

ACKs for top commit:
  apoelstra:
    ACK 74f3a5a
  Kixunil:
    ACK 74f3a5a

Tree-SHA512: 56dc6262144f4caa5efa6fdc46aeecf7bddc050ef134a639b31a34d4c5e01abcdeda18a00f4ded443866bbdfc982b4e5b67b0089639e0c253e207f0b54777f57
@Kixunil Kixunil added this to the 0.29.0 milestone Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants