Skip to content

Commit

Permalink
test: add sign bytes test for MsgRegisterAccount
Browse files Browse the repository at this point in the history
  • Loading branch information
technicallyty committed Oct 25, 2022
1 parent ad127d4 commit e074640
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
24 changes: 23 additions & 1 deletion x/intertx/types/v1/features/msg_register_account.feature
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,26 @@ Feature: MsgRegisterAccount
}
"""
When the message is validated
Then expect the error "connection_id cannot be empty: invalid request"
Then expect the error "connection_id cannot be empty: invalid request"

Scenario: a valid amino msg
Given the message
"""
{
"owner": "regen16md38uw5z9v4du2dtq4qgake8ewyf36u6qgfza",
"connection_id": "channel-5",
"version": "3"
}
"""
When message sign bytes queried
Then expect the sign bytes
"""
{
"type": "intertx/MsgRegisterAccount",
"value":{
"connection_id": "channel-5",
"owner": "regen16md38uw5z9v4du2dtq4qgake8ewyf36u6qgfza",
"version": "3"
}
}
"""
19 changes: 16 additions & 3 deletions x/intertx/types/v1/msg_register_account_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package v1

import (
"bytes"
"encoding/json"
"testing"

"github.com/regen-network/gocuke"
"github.com/stretchr/testify/require"
"gotest.tools/v3/assert"

sdk "github.com/cosmos/cosmos-sdk/types"
)

type registerAccountSuite struct {
t gocuke.TestingT
msg *MsgRegisterAccount
err error
t gocuke.TestingT
msg *MsgRegisterAccount
signBytes string
err error
}

func TestMsgRegisterAccount(t *testing.T) {
Expand Down Expand Up @@ -44,3 +47,13 @@ func (s *registerAccountSuite) ExpectNoError() {
func (s *registerAccountSuite) ExpectTheError(a string) {
assert.ErrorContains(s.t, s.err, a)
}

func (s *registerAccountSuite) MessageSignBytesQueried() {
s.signBytes = string(s.msg.GetSignBytes())
}

func (s *registerAccountSuite) ExpectTheSignBytes(a gocuke.DocString) {
buffer := new(bytes.Buffer)
require.NoError(s.t, json.Compact(buffer, []byte(a.Content)))
require.Equal(s.t, buffer.String(), s.signBytes)
}

0 comments on commit e074640

Please sign in to comment.