planetmint-go/x/asset/keeper/asset_test.go
Julian Strobl d4eed021c8
[go.mod] Switch module to github.com (#86)
This is the quasi-standard and fixes the error below:

```
$ go get -u github.com/planetmint/planetmint-go@v0.1.0
go: github.com/planetmint/planetmint-go@v0.1.0: parsing go.mod:
        module declares its path as: planetmint-go
                but was required as: github.com/planetmint/planetmint-go
```

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-09-21 17:37:57 +02:00

38 lines
954 B
Go

package keeper_test
import (
"crypto/sha256"
"strconv"
"testing"
keepertest "github.com/planetmint/planetmint-go/testutil/keeper"
"github.com/planetmint/planetmint-go/x/asset/keeper"
"github.com/planetmint/planetmint-go/x/asset/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/assert"
)
func createNAsset(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Asset {
items := make([]types.Asset, n)
for i := range items {
hash := sha256.Sum256([]byte(strconv.FormatInt(int64(i), 2)))
hashStr := string(hash[:])
items[i].Hash = hashStr
items[i].Pubkey = "pubkey"
items[i].Signature = "sign"
keeper.StoreAsset(ctx, items[i])
}
return items
}
func TestGetAsset(t *testing.T) {
keeper, ctx := keepertest.AssetKeeper(t)
items := createNAsset(keeper, ctx, 10)
for _, item := range items {
asset, found := keeper.GetAsset(ctx, item.Hash)
assert.True(t, found)
assert.Equal(t, item, asset)
}
}