Skip to content

Commit

Permalink
move testdata out of internal for re-use in integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kocubinski committed May 31, 2023
1 parent 12d10ab commit 91a9688
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 13 deletions.
4 changes: 2 additions & 2 deletions tests/integration/aminojson/aminojson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ import (
ed25519types "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
secp256k1types "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
gogo_testpb "github.com/cosmos/cosmos-sdk/tests/integration/aminojson/internal/gogo/testpb"
pulsar_testpb "github.com/cosmos/cosmos-sdk/tests/integration/aminojson/internal/pulsar/testpb"
gogo_testpb "github.com/cosmos/cosmos-sdk/tests/integration/aminojson/testdata/gogo/testpb"
pulsar_testpb "github.com/cosmos/cosmos-sdk/tests/integration/aminojson/testdata/pulsar/testpb"
"github.com/cosmos/cosmos-sdk/tests/integration/rapidgen"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/cosmos/cosmos-sdk/types"
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/aminojson/repeated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (
"github.com/stretchr/testify/require"

"cosmossdk.io/x/tx/signing/aminojson"

"github.com/cosmos/cosmos-sdk/codec"
gogopb "github.com/cosmos/cosmos-sdk/tests/integration/aminojson/internal/gogo/testpb"
pulsarpb "github.com/cosmos/cosmos-sdk/tests/integration/aminojson/internal/pulsar/testpb"
gogopb "github.com/cosmos/cosmos-sdk/tests/integration/aminojson/testdata/gogo/testpb"
pulsarpb "github.com/cosmos/cosmos-sdk/tests/integration/aminojson/testdata/pulsar/testpb"
)

func TestRepeatedFields(t *testing.T) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions tests/integration/tx/context_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package tx

import (
"testing"

"cosmossdk.io/x/tx/signing"
"github.com/stretchr/testify/require"
)

func TestDefineCustomGetSigners(t *testing.T) {
customMsg := &testpb.CustomSignedMessage{}
signers := [][]byte{[]byte("foo")}

context, err := signing.NewContext(signing.Options{
AddressCodec: dummyAddressCodec{},
ValidatorAddressCodec: dummyValidatorAddressCodec{},
})
require.NoError(t, err)

_, err = context.GetSigners(customMsg)
// before calling DefineCustomGetSigners, we should get an error
require.ErrorContains(t, err, "need custom signers function")
signing.DefineCustomGetSigners(context, func(msg *testpb.CustomSignedMessage) ([][]byte, error) {
return signers, nil
})
// after calling DefineCustomGetSigners, we should get the signers
gotSigners, err := context.GetSigners(customMsg)
require.NoError(t, err)
require.Equal(t, signers, gotSigners)
}
1 change: 1 addition & 0 deletions x/tx/internal/testpb/1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ message Ballot {
repeated WeightedBallotOption options = 4;
}

// TODO remove
message CustomSignedMessage {
option (cosmos.msg.v1.custom_signer) = true;
string thing1 = 1;
Expand Down

0 comments on commit 91a9688

Please sign in to comment.