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

Add grant system tests #1626

Merged
merged 5 commits into from
Sep 15, 2023
Merged

Add grant system tests #1626

merged 5 commits into from
Sep 15, 2023

Conversation

pinosu
Copy link
Contributor

@pinosu pinosu commented Sep 14, 2023

No description provided.

@pinosu pinosu marked this pull request as ready for review September 15, 2023 06:44
@pinosu pinosu requested a review from alpe as a code owner September 15, 2023 06:44
@codecov
Copy link

codecov bot commented Sep 15, 2023

Codecov Report

Merging #1626 (c5a9537) into main (e0bfaa5) will decrease coverage by 0.03%.
The diff coverage is 8.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1626      +/-   ##
==========================================
- Coverage   56.63%   56.60%   -0.03%     
==========================================
  Files          64       64              
  Lines        8896     8904       +8     
==========================================
+ Hits         5038     5040       +2     
- Misses       3468     3475       +7     
+ Partials      390      389       -1     
Files Changed Coverage Δ
x/wasm/client/cli/tx.go 14.92% <0.00%> (-0.29%) ⬇️
x/wasm/types/authz.go 81.96% <100.00%> (ø)

... and 1 file with indirect coverage changes

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.

Very good! Revisiting the logic from the client perspective inspired some changes to restructure the CLI tree.

)

//set params
sut.ModifyGenesisJSON(t, SetCodeUploadPermission(t, "AnyOfAddresses", []string{account1Addr}))
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

cli := NewWasmdCLI(t, sut, verbose)

// add genesis account with some tokens
account1Addr := cli.AddKey("account1")
Copy link
Contributor

Choose a reason for hiding this comment

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

account1 and 2 are not very verbose. Can think about the role that the address represents?
Maybe something like chain_authorization and dev ?

rsp = cli.CustomCommand("tx", "wasm", "grant-store-code", account2Addr, "*:*", "--from="+account1Addr)
RequireTxSuccess(t, rsp)

// address2 store code fails
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// address2 store code fails
// address2 store code fails as the address is not in the code-upload accept-list

rsp = cli.CustomCommand("tx", "wasm", "store", "./testdata/hackatom.wasm.gzip", "--from="+account2Addr, "--gas=1500000", "--fees=2stake")
RequireTxFailure(t, rsp)

// create tx
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// create tx
// create tx should work for addresses in the accept-list

err := os.WriteFile(pathToTx, []byte(tx), os.FileMode(0o744))
require.NoError(t, err)

// address2 authz exec store code should succeed
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// address2 authz exec store code should succeed
// store code via authz execution uses the given grant and should succeed

tests/system/grant_test.go Outdated Show resolved Hide resolved
tests/system/fraud_test.go Show resolved Hide resolved
@@ -31,3 +31,15 @@ func GetGenesisBalance(rawGenesis []byte, addr string) sdk.Coins {
}
return r
}

// SetCodeUploadPermission sets the code upload permissions
func SetCodeUploadPermission(t *testing.T, permission string, addresses []string) GenesisMutator {
Copy link
Contributor

Choose a reason for hiding this comment

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

personal preference :-)

Suggested change
func SetCodeUploadPermission(t *testing.T, permission string, addresses []string) GenesisMutator {
func SetCodeUploadPermission(t *testing.T, permission string, addresses ...string) GenesisMutator {

tests/system/genesis_io.go Show resolved Hide resolved
x/wasm/client/cli/tx.go Outdated Show resolved Hide resolved
pinosu and others added 2 commits September 15, 2023 10:53
* Restructure CLI; fix system test

* Review feedback
@alpe alpe merged commit 6a2bffd into main Sep 15, 2023
@alpe alpe deleted the grant_system_test branch September 15, 2023 14:59
alpe added a commit that referenced this pull request Sep 19, 2023
* main:
  Set default query limit and ensure constraints (#1632)
  Fix genesis import with predictable addresses
  Add grant system tests (#1626)
  Ensure some contraints and limits on pin/unpin code ids
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.

2 participants