github.com/nspcc-dev/neo-go@v0.105.2-0.20240517133400-6be757af3eba/pkg/wallet/token_test.go (about) 1 package wallet 2 3 import ( 4 "encoding/json" 5 "testing" 6 7 "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" 8 "github.com/nspcc-dev/neo-go/pkg/util" 9 "github.com/stretchr/testify/require" 10 ) 11 12 func TestToken_MarshalJSON(t *testing.T) { 13 // From the https://neo-python.readthedocs.io/en/latest/prompt.html#import-nep5-compliant-token 14 h, err := util.Uint160DecodeStringLE("f8d448b227991cf07cb96a6f9c0322437f1599b9") 15 require.NoError(t, err) 16 17 tok := NewToken(h, "NEP-17 standard token", "NEPT", 8, manifest.NEP17StandardName) 18 require.Equal(t, "NEP-17 standard token", tok.Name) 19 require.Equal(t, "NEPT", tok.Symbol) 20 require.EqualValues(t, 8, tok.Decimals) 21 require.Equal(t, h, tok.Hash) 22 require.Equal(t, "NcqKahsZ93ZyYS5bep8G2TY1zRB7tfUPdK", tok.Address()) 23 24 data, err := json.Marshal(tok) 25 require.NoError(t, err) 26 27 actual := new(Token) 28 require.NoError(t, json.Unmarshal(data, actual)) 29 require.Equal(t, tok, actual) 30 }