neoneo-go/pkg/wallet/token_test.go
Evgenii Stratonikov 7b4ca57e33 *: change address to the new format
NEO3 uses new prefix for address (53 = 0x35), thus string representations as
well as encrypted WIFs should be changed.
2020-06-17 15:58:21 +03:00

29 lines
822 B
Go

package wallet
import (
"encoding/json"
"testing"
"github.com/nspcc-dev/neo-go/pkg/util"
"github.com/stretchr/testify/require"
)
func TestToken_MarshalJSON(t *testing.T) {
// From the https://neo-python.readthedocs.io/en/latest/prompt.html#import-nep5-compliant-token
h, err := util.Uint160DecodeStringLE("f8d448b227991cf07cb96a6f9c0322437f1599b9")
require.NoError(t, err)
tok := NewToken(h, "NEP5 Standard", "NEP5", 8)
require.Equal(t, "NEP5 Standard", tok.Name)
require.Equal(t, "NEP5", tok.Symbol)
require.EqualValues(t, 8, tok.Decimals)
require.Equal(t, h, tok.Hash)
require.Equal(t, "NcqKahsZ93ZyYS5bep8G2TY1zRB7tfUPdK", tok.Address())
data, err := json.Marshal(tok)
require.NoError(t, err)
actual := new(Token)
require.NoError(t, json.Unmarshal(data, actual))
require.Equal(t, tok, actual)
}