Skip to content
This repository was archived by the owner on Jan 6, 2022. It is now read-only.

Commit a4d5c00

Browse files
authored
feat(testutil): add testutil pkg to generate sample objects (#10)
* add testutil pkg to generate sample objects * add unit test
1 parent 3cfa2ea commit a4d5c00

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

testutil/sample/sample.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package sample
2+
3+
import (
4+
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
5+
sdk "github.com/cosmos/cosmos-sdk/types"
6+
)
7+
8+
// AccAddress returns a sample account address
9+
func AccAddress() string {
10+
pk := ed25519.GenPrivKey().PubKey()
11+
addr := pk.Address()
12+
return sdk.AccAddress(addr).String()
13+
}

testutil/sample/sample_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package sample
2+
3+
import (
4+
"testing"
5+
6+
sdk "github.com/cosmos/cosmos-sdk/types"
7+
"github.com/stretchr/testify/require"
8+
)
9+
10+
func TestAccAddress(t *testing.T) {
11+
got := AccAddress()
12+
require.NotEmpty(t, got)
13+
_, err := sdk.AccAddressFromBech32(got)
14+
require.NoError(t, err)
15+
}

0 commit comments

Comments
 (0)