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

test: add event checking to TestStoreCode #63

Merged
merged 5 commits into from
Aug 10, 2023

Conversation

da1suk8
Copy link
Member

@da1suk8 da1suk8 commented Aug 9, 2023

Description

TestStoreCode

https://github.com/Finschia/wasmd/blob/main/docs/proto/proto-docs.md#msgstorecode

The event was not checked, so it was added to the test.
Also, here is a test on instantiate_permission.

func TestStoreCodeValidation(t *testing.T) {
bad, err := sdk.AccAddressFromHex("012345")
require.NoError(t, err)
badAddress := bad.String()
// proper address size
goodAddress := sdk.AccAddress(make([]byte, ContractAddrLen)).String()
sdk.GetConfig().SetAddressVerifier(VerifyAddressLen())
cases := map[string]struct {
msg MsgStoreCode
valid bool
}{
"empty": {
msg: MsgStoreCode{},
valid: false,
},
"correct minimal": {
msg: MsgStoreCode{
Sender: goodAddress,
WASMByteCode: []byte("foo"),
},
valid: true,
},
"missing code": {
msg: MsgStoreCode{
Sender: goodAddress,
},
valid: false,
},
"bad sender minimal": {
msg: MsgStoreCode{
Sender: badAddress,
WASMByteCode: []byte("foo"),
},
valid: false,
},
"correct maximal": {
msg: MsgStoreCode{
Sender: goodAddress,
WASMByteCode: []byte("foo"),
},
valid: true,
},
"invalid InstantiatePermission": {
msg: MsgStoreCode{
Sender: goodAddress,
WASMByteCode: []byte("foo"),
InstantiatePermission: &AccessConfig{Permission: AccessTypeOnlyAddress, Address: badAddress},
},
valid: false,
},
}
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
err := tc.msg.ValidateBasic()
if tc.valid {
assert.NoError(t, err)
} else {
assert.Error(t, err)
}
})
}
}

Motivation and context

Checklist:

  • I followed the contributing guidelines and code of conduct.
  • I have added a relevant changelog to CHANGELOG.md
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have updated API documentation client/docs/swagger-ui/swagger.yaml

@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Merging #63 (459a1b6) into main (dedcd9e) will decrease coverage by 0.04%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #63      +/-   ##
==========================================
- Coverage   62.02%   61.99%   -0.04%     
==========================================
  Files          80       80              
  Lines        9971     9971              
==========================================
- Hits         6185     6182       -3     
- Misses       3450     3452       +2     
- Partials      336      337       +1     

see 1 file with indirect coverage changes

@da1suk8 da1suk8 marked this pull request as ready for review August 9, 2023 08:04
@da1suk8 da1suk8 self-assigned this Aug 9, 2023
@da1suk8 da1suk8 changed the title test: added because there was no event check test: add event checking to TestStoreCode Aug 10, 2023
@da1suk8 da1suk8 merged commit 52a6659 into Finschia:main Aug 10, 2023
12 checks passed
@da1suk8 da1suk8 deleted the test/check_event_TestStoreCode branch August 10, 2023 07:11
@zemyblue zemyblue mentioned this pull request Oct 19, 2023
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.

3 participants