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: Improve 'CAmount' tests #14460

Merged
merged 1 commit into from Oct 20, 2018
Merged

Conversation

@hebasto
Copy link
Member

@hebasto hebasto commented Oct 10, 2018

This provides:

  • more MoneyRange tests;
  • new CFeeRate constructor tests with zero byte size;
  • explicit using of the CAmount type.
This provides:
  - more `MoneyRange` tests;
  - new `CFeeRate` constructor tests with zero byte size;
  - explicit using of the `CAmount` type.
@fanquake fanquake added the Tests label Oct 11, 2018
@promag
Copy link
Member

@promag promag commented Oct 11, 2018

explicit using of the CAmount type.

Why? Is there an advantage?

@hebasto
Copy link
Member Author

@hebasto hebasto commented Oct 11, 2018

@promag

Why?

CAmount GetFee(size_t nBytes) const;

Is there an advantage?

It clearly shows what type of return value we are expecting from the methods being testing.

@promag
Copy link
Member

@promag promag commented Oct 11, 2018

utACK 29ed2d6.

@sipa
Copy link
Member

@sipa sipa commented Oct 12, 2018

utACK.

Is the eventual goal to remove the implicit conversion from other types to CAmount?

@arvidn perhaps you're interested in this?

@jb55
Copy link
Contributor

@jb55 jb55 commented Oct 12, 2018

Is the eventual goal to remove the implicit conversion from other types to CAmount

I hope so, right now this would remove testing of implicit conversions... is that a good thing?

@hebasto
Copy link
Member Author

@hebasto hebasto commented Oct 13, 2018

@sipa @jb55
Thank you for your reviews.

Is it worth to just add an explicit test case for type conversions like this:

BOOST_AUTO_TEST_CASE(CAmountTypeConversionTest)
{
    BOOST_CHECK_EQUAL(CAmount(-MAX_MONEY), -MAX_MONEY);
    BOOST_CHECK_EQUAL(CAmount(-1), -1);
    BOOST_CHECK_EQUAL(CAmount(0), 0);
    BOOST_CHECK_EQUAL(CAmount(1), 1);
    BOOST_CHECK_EQUAL(CAmount(MAX_MONEY), MAX_MONEY);
}

or just keep in mind that

typedef int64_t CAmount;

@laanwj
Copy link
Member

@laanwj laanwj commented Oct 18, 2018

Is it worth to just add an explicit test case for type conversions like this:

I don't think so—because at the same time that would be worth testing (e.g. CAmount becomes an actual type instead of typedef), implicit conversion will be no longer possible

@laanwj
Copy link
Member

@laanwj laanwj commented Oct 18, 2018

utACK 29ed2d6

1 similar comment
@sipa
Copy link
Member

@sipa sipa commented Oct 20, 2018

utACK 29ed2d6

@sipa sipa merged commit 29ed2d6 into bitcoin:master Oct 20, 2018
2 checks passed
sipa added a commit that referenced this issue Oct 20, 2018
29ed2d6 Improve CAmount tests (Hennadii Stepanov)

Pull request description:

  This provides:
    - more `MoneyRange` tests;
    - new `CFeeRate` constructor tests with zero byte size;
    - explicit using of the `CAmount` type.

Tree-SHA512: ca0ad6ccb37909a2a5c11034dc07b316a84c32fb40c6f8b6cfc28ebec72a1de157f31d22e767ae80d70ed06d7296f23870cc5ed0689f34a754ae763d50e23d43
@hebasto hebasto deleted the 20181010-amount-tests branch Oct 20, 2018
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this issue Feb 14, 2020
Summary:
29ed2d64f6 Improve CAmount tests (Hennadii Stepanov)

Pull request description:

  This provides:
    - more `MoneyRange` tests;
    - explicit using of the `CAmount` type.

Tree-SHA512: ca0ad6ccb37909a2a5c11034dc07b316a84c32fb40c6f8b6cfc28ebec72a1de157f31d22e767ae80d70ed06d7296f23870cc5ed0689f34a754ae763d50e23d43

Backport of Core [[bitcoin/bitcoin#14460 | PR14460]]
bitcoin/bitcoin#14460

Adjusted for our codebase.

Test Plan:
  ninja check

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D5277
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jun 24, 2021
29ed2d6 Improve CAmount tests (Hennadii Stepanov)

Pull request description:

  This provides:
    - more `MoneyRange` tests;
    - new `CFeeRate` constructor tests with zero byte size;
    - explicit using of the `CAmount` type.

Tree-SHA512: ca0ad6ccb37909a2a5c11034dc07b316a84c32fb40c6f8b6cfc28ebec72a1de157f31d22e767ae80d70ed06d7296f23870cc5ed0689f34a754ae763d50e23d43
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this issue Jun 27, 2021
29ed2d6 Improve CAmount tests (Hennadii Stepanov)

Pull request description:

  This provides:
    - more `MoneyRange` tests;
    - new `CFeeRate` constructor tests with zero byte size;
    - explicit using of the `CAmount` type.

Tree-SHA512: ca0ad6ccb37909a2a5c11034dc07b316a84c32fb40c6f8b6cfc28ebec72a1de157f31d22e767ae80d70ed06d7296f23870cc5ed0689f34a754ae763d50e23d43
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this issue Jun 28, 2021
29ed2d6 Improve CAmount tests (Hennadii Stepanov)

Pull request description:

  This provides:
    - more `MoneyRange` tests;
    - new `CFeeRate` constructor tests with zero byte size;
    - explicit using of the `CAmount` type.

Tree-SHA512: ca0ad6ccb37909a2a5c11034dc07b316a84c32fb40c6f8b6cfc28ebec72a1de157f31d22e767ae80d70ed06d7296f23870cc5ed0689f34a754ae763d50e23d43
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jun 28, 2021
29ed2d6 Improve CAmount tests (Hennadii Stepanov)

Pull request description:

  This provides:
    - more `MoneyRange` tests;
    - new `CFeeRate` constructor tests with zero byte size;
    - explicit using of the `CAmount` type.

Tree-SHA512: ca0ad6ccb37909a2a5c11034dc07b316a84c32fb40c6f8b6cfc28ebec72a1de157f31d22e767ae80d70ed06d7296f23870cc5ed0689f34a754ae763d50e23d43
PastaPastaPasta added a commit to PastaPastaPasta/dash that referenced this issue Jun 29, 2021
29ed2d6 Improve CAmount tests (Hennadii Stepanov)

Pull request description:

  This provides:
    - more `MoneyRange` tests;
    - new `CFeeRate` constructor tests with zero byte size;
    - explicit using of the `CAmount` type.

Tree-SHA512: ca0ad6ccb37909a2a5c11034dc07b316a84c32fb40c6f8b6cfc28ebec72a1de157f31d22e767ae80d70ed06d7296f23870cc5ed0689f34a754ae763d50e23d43
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jun 29, 2021
29ed2d6 Improve CAmount tests (Hennadii Stepanov)

Pull request description:

  This provides:
    - more `MoneyRange` tests;
    - new `CFeeRate` constructor tests with zero byte size;
    - explicit using of the `CAmount` type.

Tree-SHA512: ca0ad6ccb37909a2a5c11034dc07b316a84c32fb40c6f8b6cfc28ebec72a1de157f31d22e767ae80d70ed06d7296f23870cc5ed0689f34a754ae763d50e23d43
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jun 29, 2021
29ed2d6 Improve CAmount tests (Hennadii Stepanov)

Pull request description:

  This provides:
    - more `MoneyRange` tests;
    - new `CFeeRate` constructor tests with zero byte size;
    - explicit using of the `CAmount` type.

Tree-SHA512: ca0ad6ccb37909a2a5c11034dc07b316a84c32fb40c6f8b6cfc28ebec72a1de157f31d22e767ae80d70ed06d7296f23870cc5ed0689f34a754ae763d50e23d43
Munkybooty added a commit to Munkybooty/dash that referenced this issue Jun 29, 2021
29ed2d6 Improve CAmount tests (Hennadii Stepanov)

Pull request description:

  This provides:
    - more `MoneyRange` tests;
    - new `CFeeRate` constructor tests with zero byte size;
    - explicit using of the `CAmount` type.

Tree-SHA512: ca0ad6ccb37909a2a5c11034dc07b316a84c32fb40c6f8b6cfc28ebec72a1de157f31d22e767ae80d70ed06d7296f23870cc5ed0689f34a754ae763d50e23d43
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants