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

Commit

Permalink
feat(testutil): add testutil pkg to generate sample objects (#10)
Browse files Browse the repository at this point in the history
* add testutil pkg to generate sample objects

* add unit test
  • Loading branch information
Pantani authored Sep 2, 2021
1 parent 3cfa2ea commit a4d5c00
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions testutil/sample/sample.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package sample

import (
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// AccAddress returns a sample account address
func AccAddress() string {
pk := ed25519.GenPrivKey().PubKey()
addr := pk.Address()
return sdk.AccAddress(addr).String()
}
15 changes: 15 additions & 0 deletions testutil/sample/sample_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package sample

import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"
)

func TestAccAddress(t *testing.T) {
got := AccAddress()
require.NotEmpty(t, got)
_, err := sdk.AccAddressFromBech32(got)
require.NoError(t, err)
}

0 comments on commit a4d5c00

Please sign in to comment.