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

refactor(x/ecocredit): add batch contract mapping #1226

Merged
merged 22 commits into from
Jul 6, 2022

Conversation

ryanchristo
Copy link
Member

@ryanchristo ryanchristo commented Jun 29, 2022

Description

Closes: #1127 / Closes: #1193 / Ref: #1206


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov
Copy link

codecov bot commented Jun 29, 2022

Codecov Report

Merging #1226 (323392d) into master (94f37dd) will decrease coverage by 5.10%.
The diff coverage is 84.05%.

@@            Coverage Diff             @@
##           master    #1226      +/-   ##
==========================================
- Coverage   79.34%   74.23%   -5.11%     
==========================================
  Files         228      225       -3     
  Lines       21423    19519    -1904     
==========================================
- Hits        16998    14490    -2508     
- Misses       3064     3737     +673     
+ Partials     1361     1292      -69     
Flag Coverage Δ
experimental-codecov ?
stable-codecov 74.23% <84.05%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
x/ecocredit/core/msg_bridge.go 20.00% <ø> (-7.28%) ⬇️
x/ecocredit/server/core/bridge.go 73.07% <72.72%> (-1.93%) ⬇️
x/ecocredit/server/core/create_batch.go 68.75% <75.00%> (+0.36%) ⬆️
x/ecocredit/server/core/bridge_receive.go 74.72% <87.75%> (-4.64%) ⬇️
x/ecocredit/server/core/cancel.go 66.03% <100.00%> (+0.65%) ⬆️
x/group/client/query.go 0.00% <0.00%> (-81.90%) ⬇️
x/group/client/tx.go 0.00% <0.00%> (-76.20%) ⬇️
x/group/client/util.go 0.00% <0.00%> (-73.34%) ⬇️
app/ante.go 0.00% <0.00%> (-61.30%) ⬇️
x/group/module/module.go 16.66% <0.00%> (-33.34%) ⬇️
... and 21 more

@@ -65,6 +65,7 @@ func (k Keeper) Cancel(ctx context.Context, req *core.MsgCancel) (*core.MsgCance
Address: owner,
TradableAmount: userBalTradable.String(),
RetiredAmount: userBalance.RetiredAmount,
EscrowedAmount: userBalance.EscrowedAmount,
Copy link
Member Author

Choose a reason for hiding this comment

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

Good thing we are updating these tests... critical issue resolved here.

Copy link
Member

Choose a reason for hiding this comment

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

good catch!

Copy link
Contributor

@aleem1314 aleem1314 Jul 4, 2022

Choose a reason for hiding this comment

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

Good thing we are updating these tests... critical issue resolved here.

We have similar issue in send and retire. We are not updating sender and recipient EscrowedAmount send.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, it looks like we do. Let's address this in a separate pull request and make sure we update tests.

Copy link
Member Author

@ryanchristo ryanchristo Jul 5, 2022

Choose a reason for hiding this comment

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

I'll work on this today alongside migrating tests to gherkin/gocuke.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will be resolved in #1236

@ryanchristo
Copy link
Member Author

Aside from the changes that will follow #1225, this is ready for an initial review. 🙏 @clevinson @technicallyty

Copy link
Contributor

@technicallyty technicallyty left a comment

Choose a reason for hiding this comment

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

initial review looks good! BridgeReceive looks cleaner now 👍🏻

Copy link
Member

@clevinson clevinson left a comment

Choose a reason for hiding this comment

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

Nice set of test cases, this approach is looking much cleaner than what we've done previously.

Generally giving a concept ACK on this work.

One note - I couldn't find the logic for adding new contracts to the BatchContractTable. It sounds like this will be done once #1225 is merged in as that provides some of the necessary pieces to finish this up.

// otherwise search for an existing project based on credit class id and
// project reference id and, if the project exists, create a credit batch
// under the existing project, otherwise, create a new project and then a
// new credit batch under the new project
Copy link
Member

Choose a reason for hiding this comment

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

👍 nice summary of the expected logic

@@ -65,6 +65,7 @@ func (k Keeper) Cancel(ctx context.Context, req *core.MsgCancel) (*core.MsgCance
Address: owner,
TradableAmount: userBalTradable.String(),
RetiredAmount: userBalance.RetiredAmount,
EscrowedAmount: userBalance.EscrowedAmount,
Copy link
Member

Choose a reason for hiding this comment

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

good catch!

x/ecocredit/server/core/features/msg_bridge.feature Outdated Show resolved Hide resolved
x/ecocredit/server/core/features/msg_bridge.feature Outdated Show resolved Hide resolved
},
}

for msg, test := range tests {
t.Run(msg, func(t *testing.T) {
t.Parallel()
Copy link
Member Author

Choose a reason for hiding this comment

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

Heads up. This was causing the same test to be run multiple times and not the others.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also see #1230 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted in 70e569a. This caused several errors unrelated to the scope of this pull request. Opening a separate pull request to address and will likely migrate to gherkin/gocuke.

Copy link
Member Author

Choose a reason for hiding this comment

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

Resolved in #1231

@ryanchristo ryanchristo marked this pull request as ready for review July 1, 2022 04:19
@@ -193,7 +193,6 @@ func TestMsgBridgeReceive_ValidateBasic(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
Copy link
Member Author

Choose a reason for hiding this comment

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

Heads up. This was causing the same test to be run multiple times and not the others.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also see #1230 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted in 70e569a. This caused several errors unrelated to the scope of this pull request and the get and reset message functionality used within this test was not working as intended and was causing additional errors. Opening a separate pull request to address and will likely migrate to gherkin/gocuke.

Copy link
Member Author

Choose a reason for hiding this comment

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

Resolved in #1231

@ryanchristo
Copy link
Member Author

cc @clevinson @technicallyty @aleem1314 ready for review 🙏

Copy link
Contributor

@technicallyty technicallyty left a comment

Choose a reason for hiding this comment

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

lgtm, 1 nit

x/ecocredit/server/core/bridge.go Outdated Show resolved Hide resolved
@ryanchristo ryanchristo merged commit a7144b8 into master Jul 6, 2022
@ryanchristo ryanchristo deleted the ryan/1127-batch-contract branch July 6, 2022 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants