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

tests: Add unit testing for the CompressScript function #17220

Merged
merged 1 commit into from Oct 25, 2019

Conversation

adamjonas
Copy link
Member

Salvaging #15104 which adds unit tests for CompressScript function in compressor.cpp

Tested following cases for the CScript:

  • CKeyID
  • CScriptID
  • Uncompressed CPubKey (of size: 65)
  • Compressed CPubKey (of size: 32)

@fanquake fanquake added the Tests label Oct 22, 2019
Comment on lines 72 to 74
CScript script;
script.clear();
script << OP_DUP << OP_HASH160 << ToByteVector(pubkey.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This could be put in one line by immediately assigning the script on the declaration: CScript script = CScript() << OP_DUP ..... << OP_CHECKSIG (also applies to the other three functions).

Copy link
Member Author

Choose a reason for hiding this comment

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

wouldn't assigning the script on the declaration remove the opportunity to call .clear() on it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that calling .clear() is needed here at all, since newly constructed CScripts are empty anyway?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to clear() it, since the default constructor CScript() constructs a (logically) empty CScript.

@laanwj
Copy link
Member

laanwj commented Oct 23, 2019

ACK, thanks for adding tests.

Copy link
Contributor

@dongcarl dongcarl left a comment

Choose a reason for hiding this comment

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

ACK 3208906
Read code, ran tests, feel free to ignore the nit!

Comment on lines 72 to 74
CScript script;
script.clear();
script << OP_DUP << OP_HASH160 << ToByteVector(pubkey.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to clear() it, since the default constructor CScript() constructs a (logically) empty CScript.

@adamjonas adamjonas force-pushed the add_compress_test_cases branch 2 times, most recently from 4d3cdda to 7756f06 Compare October 23, 2019 17:47
@theStack
Copy link
Contributor

ACK b05ec41

laanwj added a commit that referenced this pull request Oct 25, 2019
b05ec41 Add unit testing for the CompressScript functions (marcaiaf)

Pull request description:

  Salvaging #15104 which adds unit tests for CompressScript function in `compressor.cpp`

  Tested following cases for the CScript:
    - CKeyID
    - CScriptID
    - Uncompressed CPubKey (of size: 65)
    - Compressed CPubKey (of size: 32)

ACKs for top commit:
  theStack:
    ACK b05ec41

Tree-SHA512: 7e23ace39383122802dfe5f7d38190d772f5db4045a67b7a9bd4c06797a17e0cdc41d6fac92d448057eb7df50172155dc824587c16c68c79fd1a4de37b772001
@laanwj laanwj merged commit b05ec41 into bitcoin:master Oct 25, 2019
@adamjonas adamjonas deleted the add_compress_test_cases branch October 25, 2019 16:03
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 30, 2020
Summary: This is a backport of Core [[bitcoin/bitcoin#17220 | PR17220]]

Test Plan: `ninja && ninja check`

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Subscribers: majcosta

Differential Revision: https://reviews.bitcoinabc.org/D8192
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Nov 1, 2021
…unction

b05ec41 Add unit testing for the CompressScript functions (marcaiaf)

Pull request description:

  Salvaging bitcoin#15104 which adds unit tests for CompressScript function in `compressor.cpp`

  Tested following cases for the CScript:
    - CKeyID
    - CScriptID
    - Uncompressed CPubKey (of size: 65)
    - Compressed CPubKey (of size: 32)

ACKs for top commit:
  theStack:
    ACK bitcoin@b05ec41

Tree-SHA512: 7e23ace39383122802dfe5f7d38190d772f5db4045a67b7a9bd4c06797a17e0cdc41d6fac92d448057eb7df50172155dc824587c16c68c79fd1a4de37b772001
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Nov 3, 2021
…unction

b05ec41 Add unit testing for the CompressScript functions (marcaiaf)

Pull request description:

  Salvaging bitcoin#15104 which adds unit tests for CompressScript function in `compressor.cpp`

  Tested following cases for the CScript:
    - CKeyID
    - CScriptID
    - Uncompressed CPubKey (of size: 65)
    - Compressed CPubKey (of size: 32)

ACKs for top commit:
  theStack:
    ACK bitcoin@b05ec41

Tree-SHA512: 7e23ace39383122802dfe5f7d38190d772f5db4045a67b7a9bd4c06797a17e0cdc41d6fac92d448057eb7df50172155dc824587c16c68c79fd1a4de37b772001
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Nov 18, 2021
…unction

b05ec41 Add unit testing for the CompressScript functions (marcaiaf)

Pull request description:

  Salvaging bitcoin#15104 which adds unit tests for CompressScript function in `compressor.cpp`

  Tested following cases for the CScript:
    - CKeyID
    - CScriptID
    - Uncompressed CPubKey (of size: 65)
    - Compressed CPubKey (of size: 32)

ACKs for top commit:
  theStack:
    ACK bitcoin@b05ec41

Tree-SHA512: 7e23ace39383122802dfe5f7d38190d772f5db4045a67b7a9bd4c06797a17e0cdc41d6fac92d448057eb7df50172155dc824587c16c68c79fd1a4de37b772001
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants