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

Make Coins.AllGT() more robust and consistent #3820

Merged
merged 9 commits into from
Mar 12, 2019
Merged

Conversation

sunnya97
Copy link
Member

@sunnya97 sunnya97 commented Mar 7, 2019

  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added entries in PENDING.md with issue #

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@alessio
Copy link
Contributor

alessio commented Mar 7, 2019

Please have a look at my implementation in #3678

// IsAllGT returns true if for every denom in coins, the denom is present at a
// greater amount in coinsB.
func (coins Coins) IsAllGT(coinsB Coins) bool {
	if len(coins) == 0 {
		return false
	}

	if len(coinsB) == 0 {
		return true
	}

	if !coins.ContainsDenomsOf(coinsB) {
		return false
	}

	for _, coinB := range coinsB {
		amountA, amountB := coins.AmountOf(coinB.Denom), coinB.Amount
		if !amountA.GT(amountB) {
			return false
		}
	}

	return true
}

@codecov
Copy link

codecov bot commented Mar 8, 2019

Codecov Report

Merging #3820 into develop will increase coverage by 0.01%.
The diff coverage is 100%.

@@             Coverage Diff             @@
##           develop    #3820      +/-   ##
===========================================
+ Coverage    60.93%   60.94%   +0.01%     
===========================================
  Files          192      192              
  Lines        14328    14342      +14     
===========================================
+ Hits          8731     8741      +10     
- Misses        5028     5031       +3     
- Partials       569      570       +1

@alessio alessio changed the title WIP: Failing coins.AllGT test Make Coins.AllGT() more robust and consistent Mar 8, 2019
@alessio alessio removed the WIP label Mar 11, 2019
Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

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

ACKing Sunny's changes

types/coin.go Outdated Show resolved Hide resolved
Copy link
Contributor

@rigelrozanski rigelrozanski left a comment

Choose a reason for hiding this comment

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

I dig the DenomSubset approach

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

Several questions on implementation and comment/code mismatches.

types/coin.go Outdated Show resolved Hide resolved
types/coin.go Show resolved Hide resolved
types/coin.go Show resolved Hide resolved
types/coin.go Show resolved Hide resolved
@alessio alessio requested a review from cwgoes March 12, 2019 15:09
@cwgoes
Copy link
Contributor

cwgoes commented Mar 12, 2019

Fails test_cover, looks like, and needs PENDING.md comments resolved.

@alessio
Copy link
Contributor

alessio commented Mar 12, 2019

@cwgoes

E[2019-03-12|15:08:37.960] Stopped accept routine, as transport is closed module=p2p numPeers=0
--- FAIL: TestBonding (5.05s)
	Error Trace:	lcd_test.go:557
	Error:      	Not equal: 
	            	expected: 30000000.000000000000000000
	            	actual  : 29700000.000000000000000000
	            	
	            	Diff:
	            	--- Expected
	            	+++ Actual
	            	@@ -1,2 +1,2 @@
	            	-(types.Dec) 30000000.000000000000000000
	            	+(types.Dec) 29700000.000000000000000000
	            	 
	Test:       	TestBonding
LADDR tcp://0.0.0.0:46464

@cwgoes cwgoes merged commit f97e85e into develop Mar 12, 2019
@cwgoes cwgoes deleted the sunny/coins-AllGT-test branch March 12, 2019 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants