Skip to content

Commit

Permalink
delete test case
Browse files Browse the repository at this point in the history
  • Loading branch information
skyargos committed Nov 14, 2023
1 parent b3f414d commit c5312f1
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 903 deletions.
248 changes: 0 additions & 248 deletions app/upgrade_handler_test.go

This file was deleted.

18 changes: 0 additions & 18 deletions common/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,6 @@ const (
Bech32PrefixConsPub = Bech32MainPrefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic
)

// PrefixToCertik convert shentu prefix address to certik prefix address
func PrefixToCertik(address string) (string, error) {
hrp, data, err := bech32.DecodeAndConvert(address)
if err != nil {
return "", err
}
if !strings.HasPrefix(hrp, "shentu") {
return "", fmt.Errorf("invalid address:%s", address)
}

newhrp := strings.Replace(hrp, "shentu", "certik", 1)
certikAddr, err := bech32.ConvertAndEncode(newhrp, data)
if err != nil {
return "", err
}
return certikAddr, nil
}

// PrefixToShentu convert certik prefix address to shentu prefix address
func PrefixToShentu(address string) (string, error) {
hrp, data, err := bech32.DecodeAndConvert(address)
Expand Down
22 changes: 3 additions & 19 deletions common/prefix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,14 @@ package common

import (
"crypto/sha256"
"github.com/stretchr/testify/require"
"strings"
"testing"

"github.com/stretchr/testify/require"

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

func TestPrefixToCertik(t *testing.T) {
sum := sha256.Sum256([]byte("hello world\n"))
ss := "shentu"

address, err := bech32.ConvertAndEncode(ss, sum[:])
require.NoError(t, err)

certikAddr, err := PrefixToCertik(address)
require.NoError(t, err)
require.True(t, strings.HasPrefix(certikAddr, "certik"))

address, err = bech32.ConvertAndEncode("certik", sum[:])
require.NoError(t, err)
_, err = PrefixToCertik(address)
require.Error(t, err)
}

func TestPrefixToShentu(t *testing.T) {
sum := sha256.Sum256([]byte("hello world\n"))
ss := "certik"
Expand All @@ -40,5 +24,5 @@ func TestPrefixToShentu(t *testing.T) {
address, err = bech32.ConvertAndEncode("shentu", sum[:])
require.NoError(t, err)
_, err = PrefixToShentu(address)
require.Error(t, err)
require.NoError(t, err)
}
Loading

0 comments on commit c5312f1

Please sign in to comment.