-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull out some test helpers for genesis_test
- Loading branch information
Showing
2 changed files
with
40 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package wasm | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/require" | ||
"strconv" | ||
"testing" | ||
) | ||
|
||
// ensure store code returns the expected response | ||
func assertStoreCodeResponse(t *testing.T, data []byte, expected int64) { | ||
var pStoreResp MsgStoreCodeResponse | ||
require.NoError(t, pStoreResp.Unmarshal(data)) | ||
// TODO: change this when it we store int natively | ||
require.Equal(t, pStoreResp.CodeID, strconv.FormatInt(expected, 10)) | ||
} | ||
|
||
// ensure execution returns the expected data | ||
func assertExecuteResponse(t *testing.T, data []byte, expected []byte) { | ||
var pExecResp MsgExecuteContractResponse | ||
require.NoError(t, pExecResp.Unmarshal(data)) | ||
require.Equal(t, pExecResp.Data, expected) | ||
} | ||
|
||
// ensures this returns a valid bech32 address and returns it | ||
func parseInitResponse(t *testing.T, data []byte) string { | ||
var pInstResp MsgInstantiateContractResponse | ||
require.NoError(t, pInstResp.Unmarshal(data)) | ||
require.NotEmpty(t, pInstResp.Address) | ||
addr := pInstResp.Address | ||
// ensure this is a valid sdk address | ||
_, err := sdk.AccAddressFromBech32(addr) | ||
require.NoError(t, err) | ||
return addr | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters