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

PoE contract address query #192

Merged
merged 10 commits into from
Nov 25, 2021
Merged

PoE contract address query #192

merged 10 commits into from
Nov 25, 2021

Conversation

maurolacy
Copy link
Contributor

Closes #168.

@maurolacy maurolacy requested a review from alpe November 23, 2021 10:03
Copy link
Contributor

@alpe alpe left a comment

Choose a reason for hiding this comment

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

This should work already. Awesome start. I have added some comments and nits to help with idiomatic Go.

Please run make format

x/poe/wasm/query_plugin.go Show resolved Hide resolved
x/poe/wasm/query_plugin.go Outdated Show resolved Hide resolved
x/poe/wasm/query_plugin.go Show resolved Hide resolved
x/poe/wasm/query_plugin.go Outdated Show resolved Hide resolved
x/poe/wasm/query_plugin.go Outdated Show resolved Hide resolved
x/poe/wasm/query_plugin.go Outdated Show resolved Hide resolved
@alpe
Copy link
Contributor

alpe commented Nov 23, 2021

btw the TestPoEAddPostGenesisValidatorWithGovProposalEngagementPoints system test was failing but not because of your code. It became flickering in the last weeks and I have not had the time to investigate.

@maurolacy
Copy link
Contributor Author

maurolacy commented Nov 23, 2021

btw the TestPoEAddPostGenesisValidatorWithGovProposalEngagementPoints system test was failing but not because of your code. It became flickering in the last weeks and I have not had the time to investigate.

I still have to extend ViewKeeperMock with the new interface. That is the reason for some failed tests.

Copy link
Contributor

@alpe alpe left a comment

Choose a reason for hiding this comment

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

Good refactorings

x/poe/wasm/query_plugin.go Show resolved Hide resolved
x/poe/wasm/query_plugin.go Show resolved Hide resolved
x/poe/wasm/query_plugin.go Outdated Show resolved Hide resolved
x/poe/wasm/query_plugin.go Outdated Show resolved Hide resolved
@maurolacy maurolacy force-pushed the 168-query-poe-contract-addresses branch from 49296fd to f9b7a90 Compare November 24, 2021 08:37
@maurolacy maurolacy marked this pull request as ready for review November 24, 2021 08:42
Copy link
Contributor

@alpe alpe left a comment

Choose a reason for hiding this comment

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

Almost perfect. Very good test coverage 💐

x/poe/wasm/query_plugin_test.go Outdated Show resolved Hide resolved
x/poe/wasm/query_plugin_test.go Outdated Show resolved Hide resolved
src: []byte(`{ "poe_contract_address": { "contract_type": "staking"} }`),
mock: ViewKeeperMock{
GetPoEContractAddressFn: func(ctx sdk.Context, contractType poetypes.PoEContractType) (sdk.AccAddress, error) {
if contractType == poetypes.PoEContractTypeStaking {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 good to have the switch here.
you can also use require.Equals(t, types.PoEContractTypeStaking, got) instead but it is lacking the right instance of t so that the whole test fails and not the single case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I cannot do that here easily, because of table tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant the following mock function would do the same as here or L318 but may be more readable

				GetPoEContractAddressFn: func(ctx sdk.Context, contractType poetypes.PoEContractType) (sdk.AccAddress, error) {
					assert.Equal(t, poetypes.PoEContractTypeUndefined, contractType)
					return nil, sdkerrors.Wrap(wasmtypes.ErrInvalid, "contract type")
				}},

@maurolacy maurolacy merged commit f48e7b7 into main Nov 25, 2021
@alpe alpe deleted the 168-query-poe-contract-addresses branch January 7, 2022 08:27
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.

Query PoE contract addresses from contracts
2 participants