Some checks are pending
Docs Deploy / build_and_deploy (push) Waiting to run
Generate Docs / cli (push) Waiting to run
Generate Config Doc / cli (push) Waiting to run
Go formatting / go-formatting (push) Waiting to run
Check links / markdown-link-check (push) Waiting to run
Integration / pre-test (push) Waiting to run
Integration / test on (push) Blocked by required conditions
Integration / status (push) Blocked by required conditions
Lint / Lint Go code (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
51 lines
1 KiB
Go
51 lines
1 KiB
Go
package chainregistry
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestChainSaveJSON(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "chain.json")
|
|
in := Chain{
|
|
ChainName: "ignite",
|
|
ChainID: "ignite-1",
|
|
}
|
|
|
|
require.NoError(t, in.SaveJSON(path))
|
|
|
|
raw, err := os.ReadFile(path)
|
|
require.NoError(t, err)
|
|
var got Chain
|
|
require.NoError(t, json.Unmarshal(raw, &got))
|
|
require.Equal(t, in.ChainName, got.ChainName)
|
|
require.Equal(t, in.ChainID, got.ChainID)
|
|
}
|
|
|
|
func TestAssetListSaveJSON(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "assetlist.json")
|
|
in := AssetList{
|
|
ChainName: "ignite",
|
|
Assets: []Asset{
|
|
{
|
|
Name: "Ignite",
|
|
Base: "uignite",
|
|
Symbol: "IGNT",
|
|
},
|
|
},
|
|
}
|
|
|
|
require.NoError(t, in.SaveJSON(path))
|
|
|
|
raw, err := os.ReadFile(path)
|
|
require.NoError(t, err)
|
|
var got AssetList
|
|
require.NoError(t, json.Unmarshal(raw, &got))
|
|
require.Equal(t, in.ChainName, got.ChainName)
|
|
require.Len(t, got.Assets, 1)
|
|
require.Equal(t, "IGNT", got.Assets[0].Symbol)
|
|
}
|