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!: extract simulation helpers out of simapp #13402

Merged
merged 8 commits into from
Sep 27, 2022
Merged

Conversation

julienrbrt
Copy link
Member

Description

Closes: #13379


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)

// PostRequest defines a wrapper around an HTTP POST request with a provided URL and data.
// An error is returned if the request or reading the body fails.
func PostRequest(url string, contentType string, data []byte) ([]byte, error) {
res, err := http.Post(url, contentType, bytes.NewBuffer(data)) //nolint:gosec

Check failure

Code scanning / gosec

Potential HTTP request made with variable url

Potential HTTP request made with variable url
// GetRequest defines a wrapper around an HTTP GET request with a provided URL.
// An error is returned if the request or reading the body fails.
func GetRequest(url string) ([]byte, error) {
res, err := http.Get(url) //nolint:gosec

Check failure

Code scanning / gosec

Potential HTTP request made with variable url

Potential HTTP request made with variable url
@@ -62,7 +62,7 @@
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, _ := rest.GetRequest(tc.url)
resp, _ := testutil.GetRequest(tc.url)

Check warning

Code scanning / gosec

Returned error is not propagated up the stack.

Returned error is not propagated up the stack.
return nil, fmt.Errorf("error while sending post request: %w", err)
}
defer func() {
_ = res.Body.Close()

Check warning

Code scanning / gosec

Returned error is not propagated up the stack.

Returned error is not propagated up the stack.
return nil, err
}
defer func() {
_ = res.Body.Close()

Check warning

Code scanning / gosec

Returned error is not propagated up the stack.

Returned error is not propagated up the stack.
@@ -61,7 +61,7 @@
for _, tc := range testCases {
uri := fmt.Sprintf(balanceURL, tc.args.Owner, tc.args.ClassID)
s.Run(tc.name, func() {
resp, _ := rest.GetRequest(uri)
resp, _ := testutil.GetRequest(uri)

Check warning

Code scanning / gosec

Returned error is not propagated up the stack.

Returned error is not propagated up the stack.
@codecov
Copy link

codecov bot commented Sep 27, 2022

Codecov Report

Merging #13402 (1c8d69f) into main (9bae8a8) will decrease coverage by 0.41%.
The diff coverage is 0.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13402      +/-   ##
==========================================
- Coverage   54.31%   53.90%   -0.42%     
==========================================
  Files         637      657      +20     
  Lines       54601    56651    +2050     
==========================================
+ Hits        29658    30539     +881     
- Misses      22562    23679    +1117     
- Partials     2381     2433      +52     
Impacted Files Coverage Δ
simapp/app.go 77.30% <ø> (ø)
simapp/state.go 0.00% <0.00%> (ø)
testutil/rest.go 0.00% <0.00%> (ø)
testutil/sims/app_helpers.go 0.00% <ø> (ø)
testutil/sims/simulation_helpers.go 17.14% <0.00%> (ø)
x/distribution/simulation/operations.go 80.64% <0.00%> (-9.68%) ⬇️
tx/textual/valuerenderer/dec.go 74.19% <0.00%> (ø)
simapp/export.go 11.94% <0.00%> (ø)
simapp/test_helpers.go 30.25% <0.00%> (ø)
tx/textual/valuerenderer/int.go 78.94% <0.00%> (ø)
... and 17 more

@julienrbrt julienrbrt merged commit 91d66f3 into main Sep 27, 2022
@julienrbrt julienrbrt deleted the julien/simapp branch September 27, 2022 19:19
Wryhder pushed a commit to Wryhder/cosmos-sdk that referenced this pull request Oct 26, 2022
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
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.

Verify apps do not need to import simapp
2 participants