mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-23 23:30:36 +00:00
ce9d0b22cf
Standards are NEP-11 and NEP-17, not NEP11, not NEP17, not anything else. Variable/function names of course can use whatever fits, but documents and comments should be consistent wrt this.
30 lines
924 B
Go
30 lines
924 B
Go
package wallet
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
|
"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, "NEP-17 standard token", "NEPT", 8, manifest.NEP17StandardName)
|
|
require.Equal(t, "NEP-17 standard token", tok.Name)
|
|
require.Equal(t, "NEPT", 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)
|
|
}
|