Commit Graph

215 Commits

Author SHA1 Message Date
Mark Rushakoff
1bb632a567
chore: prefer to panic instead of os.Exit (#15285) 2023-03-07 15:12:39 +00:00
Mark Rushakoff
e7097b1468
test: add cmdtest package (#15251)
## Description

This PR introduces the `cmdtest` package, offering a lightweight wrapper around cobra commands to simplify testing CLI utilities.

I backfilled tests for the `version` command, which was an example of a very simple test setup; and for the `export` command, which was more involved due to the server and client context requirements.

I did notice that there are some existing tests for some utilities, but the `cmdtest` package follows a simple pattern that has been easy to use successfully in [the relayer](https://github.com/cosmos/relayer/blob/main/internal/relayertest/system.go) and in other projects outside the Cosmos ecosystem.

While filling in these tests, I started removing uses of `cmd.Print`, as that is the root cause of issues like #8498, #7964, #15167, and possibly others. Internal to cobra, the print family of methods write to `cmd.OutOrStderr()` -- meaning that if the authors call `cmd.SetOutput()` before executing the command, the output will be written to stdout as expected; otherwise it will go to stderr. I don't understand why that would be the default behavior, but it is probably too late to change from cobra's side.

Instead of `cmd.Print`, we prefer to `fmt.Fprint(cmd.OutOrStdout())` or `fmt.Fprint(cmd.ErrOrStderr())` as appropriate, giving an unambiguous destination for output. And the new tests collect those outputs in plain `bytes.Buffer` values so that we can assert their content appropriately.

In the longer term, I would like to deprecate and eventually remove the `testutil` package's `ApplyMockIO` method and its `BufferWriter` and `BufferReader` types, as they are unnecessary indirection when a simpler solution exists. But that can wait until `cmdtest` has propagated through the codebase more.

---

### 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...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] ~~provided a link to the relevant issue or specification~~
- [x] 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](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed all author checklist items have been addressed
- [ ] confirmed that this PR does not change production code
2023-03-06 19:40:24 +00:00
Mark Rushakoff
f151bf627a
refactor(log): require destination in calls to NewLogger (#15262) 2023-03-06 19:05:49 +00:00
Julien Robert
5f47935747
chore: make proto-gen due to dep update (#15268) 2023-03-06 10:54:50 +01:00
Julien Robert
5d559dd265
feat!: use cosmossdk.io/log logger (#15011) 2023-02-27 21:36:22 +00:00
Matt Kocubinski
976ecd4c08
feat: protoreflect based amino json encoder (#14877) 2023-02-23 21:41:06 +00:00
Aleksandr Bezobchuk
7f99ad5fe7
refactor: cleanup server logic (#15041) 2023-02-22 16:09:08 +00:00
Julien Robert
832517befc
feat: add application genesis (#15031) 2023-02-22 10:29:03 +00:00
Facundo Medica
4a6a1e3cb8
refactor: fix lint issues + gofumpt (#15062) 2023-02-19 10:31:49 +00:00
Marko
2b484a241f
feat: add rand funcs to math (#15043) 2023-02-18 18:39:46 +00:00
Julien Robert
a90569c7e4
fix: correct path required proto testdata (#14991) 2023-02-11 16:59:16 +00:00
Julien Robert
4f13b5b319
refactor!: extract AppStateFn out of simapp (#14977) 2023-02-09 14:16:07 +00:00
Julien Robert
c17c3caab8
refactor: rename commands to match consensus engine name (#14956) 2023-02-08 20:09:28 +00:00
Julien Robert
a7ac29e3f4
chore: rename log pkg and add zerolog (#14955) 2023-02-08 11:32:22 +00:00
Marko
281017ae90
refactor: use cosmos-sdk/log throughout (#14909)
## Description

removes the dependency of tendermint/utils/log from countless locations. This is in effort of reducing Tendermint's lib usage in the sdk 

this is nonbreaking as the interface is the same. To eliminate tm/utils/log in the sdk we need a few more things. Once we have fully removed the tendermint logger, I would propose we break the interface and define our own for our use case, when we pass the logger to tendermint in the node.New() function we can wrap our logger for its use case 

---

### 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](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] 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](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) 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)
2023-02-07 10:54:48 +00:00
Julien Robert
80dd55f79b
refactor: rename to CometBFT (#14914) 2023-02-06 18:11:14 +00:00
Facundo Medica
5e57be076e
test: use a queue of open ports for tests (#14893)
Co-authored-by: Marko <marbar3778@yahoo.com>
2023-02-06 13:29:18 +00:00
Julien Robert
41a3dfeced
refactor!: migrate Cosmos SDK to CometBFT (#14897) 2023-02-05 14:51:33 +01:00
Facundo Medica
21021b8378
feat: Implement BeginBlock EndBlock for Core API modules (#14819)
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
2023-02-01 14:20:39 +00:00
Matt Kocubinski
72db75bffe
feat: add rapidproto generator (#14849) 2023-01-31 21:26:10 +00:00
Julien Robert
d3c3194185
fix: add simulation tests for new param change (#14728) 2023-01-27 20:44:39 +00:00
Aaron Craelius
aceadb0b7e
feat: support core API genesis in module manager (#14582)
Co-authored-by: Facundo Medica <facundomedica@gmail.com>
Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
2023-01-27 17:14:56 +00:00
Likhita Polavarapu
7559d9ecd3
refactor: create go.mod for store (#14746)
Co-authored-by: Marko <marbar3778@yahoo.com>
2023-01-25 13:31:56 +00:00
Julien Robert
8dbdfea9ef
refactor: remove .Type() and .Route() from msgs (#14751) 2023-01-24 17:03:06 +00:00
Julien Robert
4f6f6c0002
feat: use same port for grpc-web and api server (#14652) 2023-01-20 15:07:17 +00:00
Facundo Medica
7505c18e2f
test: fix flaky tests + new method RetryForBlocks (#14609)
Co-authored-by: Marko <marbar3778@yahoo.com>
2023-01-17 15:58:29 +00:00
Aleksandr Bezobchuk
f2b6013cee
chore: use sdkmath in misc packages (#14606)
Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
2023-01-16 12:48:32 +00:00
Marko
a2eb630906
refactor: remove sdk dep from store (#14603)
Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
2023-01-13 17:43:09 +00:00
Likhita Polavarapu
fae3332d62
chore: Remove testify from testdata package (#14575) 2023-01-13 09:52:33 +01:00
Federico Kunze Küllmer
551e8f9eb9
feat(app): Update post handlers to incorporate the runMsg success bool (#13940)
Co-authored-by: MalteHerrmann <42640438+MalteHerrmann@users.noreply.github.com>
Co-authored-by: Vladislav Varadinov <vladislav.varadinov@gmail.com>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
2023-01-12 09:37:29 +00:00
Likhita Polavarapu
f590f290fc
chore: Replace testify with gotest.tools in bank integration tests (#14477)
Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com>
2023-01-11 16:16:28 +01:00
Likhita Polavarapu
f7ead8cbd8
chore: Replace testify with gotest.tools in staking integration tests (#14504) 2023-01-11 14:20:20 +01:00
Noel Ukwa
c822836501
refactor: migrate calls from alias file to appropriate store/types (#14455)
Co-authored-by: Marko <marbar3778@yahoo.com>
Closes https://github.com/cosmos/cosmos-sdk/issues/14406
2023-01-10 15:31:06 +00:00
Rafael Tenfen
91a916ec1a
refactor: add option to set bondDenom on simulations (#14529)
## Description




- Add new property `BondDenom` to `SimulationState` struct in `types/module/simulation.go`
- Changed the `x/modules/simulation/genesis.go` mostly to use the new property

---

### 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...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing)
- [x] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] 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](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) 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)
2023-01-08 18:21:51 +00:00
Julien Robert
461cf87218
chore: loosen assertions in SetOrderInitGenesis and SetOrderExportGenesis (#14457) 2023-01-02 10:05:09 +01:00
Aaron Craelius
ebfd057716
feat(client/v2): add autocli run + simapp example (#13867)
Co-authored-by: Julien Robert <julien@rbrt.fr>
2022-12-31 01:53:08 +00:00
Marko
f3dd51029a
refactor: remove global metrics in store (#14439) 2022-12-30 14:46:29 +01:00
Jacob Gadikian
1bb0629846
chore: iavl-v0.20-alpha1 and cosmos-db (#14411)
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
2022-12-28 21:42:00 +01:00
Marko
7d2ba36357
refactor: pass logger to store (#14438) 2022-12-28 13:20:44 +01:00
Marko
3684966676
chore: remove unused code from server (#14437) 2022-12-27 23:46:12 +00:00
Julien Robert
419de8de82
refactor: revert API breaking change on Slash (#14363) 2022-12-20 12:12:05 +01:00
Jacob Gadikian
be8c5a09c2
chore: lint tests (#14268) 2022-12-18 23:48:31 +00:00
Julien Robert
99b5919194
refactor: types audit (#14283) 2022-12-13 15:41:57 +01:00
Marko
ce8c96bbf5
chore: clean up sdk dependencies from store package (#14245) 2022-12-10 22:56:36 +00:00
Julien Robert
4e2196fcc3
fix: app config and simapp (v1,v2) fixes (#14209) 2022-12-08 23:08:40 +01:00
Amaury
fb4d964f7e
refactor: don't break SignModeHandler API (#14087)
* refactor: Make SignModeHandler update not API breaking

* changelog

* fix tests

* add comment

* Revert rosetta

* address reviews

* shorter name

* Fix test build
2022-12-01 16:20:10 +01:00
Amaury
fffc9d07d5
refactor!: Add context arg to sign mode handler GetSignBytes (#13701)
* refactor!: Add context arg to sign mode handler `GetSignBytes`

* fix build

* fix tests

* Fix goling

* fix lint

* Fix lint

* Fix test

* Update CHANGELOG.md

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>

* Fix tests

* Fix rosetta deps

* fix

* go mod tidy all

* go mod tidy

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
2022-11-29 18:49:51 +00:00
Julien Robert
6f329d70c6
docs: add docs about x/auth/tx (#14021)
* docs: add docs about `x/auth/tx`

* updates

* updates

* updates

* updates

* updates

* updates

* updates

Co-authored-by: Marko <marbar3778@yahoo.com>
2022-11-27 20:30:23 +00:00
Julien Robert
eb4afa74ba
ci: configure sonarcloud (#13921) 2022-11-18 15:14:49 +00:00
Aaron Craelius
ec27c5384b
refactor!: migrate to core appmodule.AppModule extension interfaces (#13794) 2022-11-14 21:23:55 +00:00