Skip to content

Commit

Permalink
chore: removed more legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Aug 31, 2024
1 parent 71f169c commit b8a6103
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 52 deletions.
15 changes: 0 additions & 15 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package utils

import (
"bytes"
"encoding/hex"
"fmt"
"math"
Expand Down Expand Up @@ -160,20 +159,6 @@ func MakeShuffledArray(length int) []int {
return array
}

func CompareTwoBech32(first, second string) (bool, error) {
_, firstBytes, err := bech32.Decode(first)
if err != nil {
return false, err
}

_, secondBytes, err := bech32.Decode(second)
if err != nil {
return false, err
}

return bytes.Equal(firstBytes, secondBytes), nil
}

func MustDecodeBech32(addr string) string {
_, bech32Bytes, err := bech32.Decode(addr)
if err != nil {
Expand Down
38 changes: 1 addition & 37 deletions pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,43 +105,7 @@ func TestMakeShuffledArray(t *testing.T) {
assert.Len(t, array, 10, "Array should have 10 entries!")
}

func TestCompareTwoBech32FirstInvalid(t *testing.T) {
t.Parallel()

_, err := CompareTwoBech32("test", "cosmos1xqz9pemz5e5zycaa89kys5aw6m8rhgsvtp9lt2")
require.Error(t, err, "Error should be present!")
}

func TestCompareTwoBech32SecondInvalid(t *testing.T) {
t.Parallel()

_, err := CompareTwoBech32("cosmos1xqz9pemz5e5zycaa89kys5aw6m8rhgsvtp9lt2", "test")
require.Error(t, err, "Error should be present!")
}

func TestCompareTwoBech32SecondEqual(t *testing.T) {
t.Parallel()

equal, err := CompareTwoBech32(
"cosmos1xqz9pemz5e5zycaa89kys5aw6m8rhgsvtp9lt2",
"cosmosvaloper1xqz9pemz5e5zycaa89kys5aw6m8rhgsvw4328e",
)
require.NoError(t, err, "Error should not be present!")
assert.True(t, equal, "Bech addresses should be equal!")
}

func TestCompareTwoBech32SecondNotEqual(t *testing.T) {
t.Parallel()

equal, err := CompareTwoBech32(
"cosmos1xqz9pemz5e5zycaa89kys5aw6m8rhgsvtp9lt2",
"cosmos1c4k24jzduc365kywrsvf5ujz4ya6mwymy8vq4q",
)
require.NoError(t, err, "Error should not be present!")
assert.False(t, equal, "Bech addresses should not be equal!")
}

func TestCompareBoolToFloat64(t *testing.T) {
func TestBoolToFloat64(t *testing.T) {
t.Parallel()
assert.InDelta(t, float64(1), BoolToFloat64(true), 0.001, "Value mismatch!")
assert.InDelta(t, float64(0), BoolToFloat64(false), 0.001, "Value mismatch!")
Expand Down

0 comments on commit b8a6103

Please sign in to comment.