2020-03-06 12:58:24 +00:00
|
|
|
package wallet
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"testing"
|
|
|
|
|
2021-04-23 14:32:48 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
2020-03-06 12:58:24 +00:00
|
|
|
"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)
|
|
|
|
|
2021-11-18 13:37:42 +00:00
|
|
|
tok := NewToken(h, "NEP-17 standard token", "NEPT", 8, manifest.NEP17StandardName)
|
|
|
|
require.Equal(t, "NEP-17 standard token", tok.Name)
|
|
|
|
require.Equal(t, "NEPT", tok.Symbol)
|
2020-03-06 12:58:24 +00:00
|
|
|
require.EqualValues(t, 8, tok.Decimals)
|
|
|
|
require.Equal(t, h, tok.Hash)
|
2020-06-16 10:47:29 +00:00
|
|
|
require.Equal(t, "NcqKahsZ93ZyYS5bep8G2TY1zRB7tfUPdK", tok.Address())
|
2020-03-06 12:58:24 +00:00
|
|
|
|
|
|
|
data, err := json.Marshal(tok)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
actual := new(Token)
|
|
|
|
require.NoError(t, json.Unmarshal(data, actual))
|
|
|
|
require.Equal(t, tok, actual)
|
|
|
|
}
|