Skip to content

Commit

Permalink
chore: test types.Explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Feb 24, 2024
1 parent b95f666 commit 0c09d51
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/config/types/explorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (e *MintscanExplorer) ToExplorer() *Explorer {
ProposalLinkPattern: fmt.Sprintf("https://mintscan.io/%s/proposals/%%s", e.Prefix),
WalletLinkPattern: fmt.Sprintf("https://mintscan.io/%s/account/%%s", e.Prefix),
ValidatorLinkPattern: fmt.Sprintf("https://mintscan.io/%s/validators/%%s", e.Prefix),
TransactionLinkPattern: fmt.Sprintf("https://mintscan.io/%s/txs/%%s", e.Prefix),
TransactionLinkPattern: fmt.Sprintf("https://mintscan.io/%s/tx/%%s", e.Prefix),
BlockLinkPattern: fmt.Sprintf("https://mintscan.io/%s/blocks/%%s", e.Prefix),
}
}
Expand Down
34 changes: 34 additions & 0 deletions pkg/config/types/explorer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package types_test

import (
"main/pkg/config/types"
"testing"

"github.com/stretchr/testify/require"
)

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

explorer := types.MintscanExplorer{Prefix: "chain"}
appExplorer := explorer.ToExplorer()

require.Equal(t, "https://mintscan.io/chain/blocks/%s", appExplorer.BlockLinkPattern)
require.Equal(t, "https://mintscan.io/chain/tx/%s", appExplorer.TransactionLinkPattern)
require.Equal(t, "https://mintscan.io/chain/validators/%s", appExplorer.ValidatorLinkPattern)
require.Equal(t, "https://mintscan.io/chain/account/%s", appExplorer.WalletLinkPattern)
require.Equal(t, "https://mintscan.io/chain/proposals/%s", appExplorer.ProposalLinkPattern)
}

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

explorer := types.PingExplorer{Prefix: "chain", BaseUrl: "https://example.com"}
appExplorer := explorer.ToExplorer()

require.Equal(t, "https://example.com/chain/blocks/%s", appExplorer.BlockLinkPattern)
require.Equal(t, "https://example.com/chain/tx/%s", appExplorer.TransactionLinkPattern)
require.Equal(t, "https://example.com/chain/staking/%s", appExplorer.ValidatorLinkPattern)
require.Equal(t, "https://example.com/chain/account/%s", appExplorer.WalletLinkPattern)
require.Equal(t, "https://example.com/chain/gov/%s", appExplorer.ProposalLinkPattern)
}

0 comments on commit 0c09d51

Please sign in to comment.