2023-03-02 01:05:53 +00:00
|
|
|
package util_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
|
2024-04-24 11:41:25 +00:00
|
|
|
"github.com/0glabs/0g-chain/chaincfg"
|
2024-04-24 07:10:22 +00:00
|
|
|
"github.com/0glabs/0g-chain/tests/util"
|
2023-03-02 01:05:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestAddressConversion(t *testing.T) {
|
2024-04-24 11:41:25 +00:00
|
|
|
chaincfg.SetSDKConfig()
|
|
|
|
bech32Addr := sdk.MustAccAddressFromBech32("0g17d2wax0zhjrrecvaszuyxdf5wcu5a0p4qlx3t5")
|
2023-03-02 01:05:53 +00:00
|
|
|
hexAddr := common.HexToAddress("0xf354ee99e2bc863cE19d80b843353476394EbC35")
|
|
|
|
require.Equal(t, bech32Addr, util.EvmToSdkAddress(hexAddr))
|
|
|
|
require.Equal(t, hexAddr, util.SdkToEvmAddress(bech32Addr))
|
|
|
|
}
|