From b63c7aad73a4be9c06aa77a79307f6b9b36dee1f Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Tue, 19 Nov 2024 17:01:23 +0300 Subject: [PATCH] rpcsrv: add NEP24 test Signed-off-by: Ekaterina Pavlova --- pkg/services/rpcsrv/client_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkg/services/rpcsrv/client_test.go b/pkg/services/rpcsrv/client_test.go index 9e2744238..9f24c7b53 100644 --- a/pkg/services/rpcsrv/client_test.go +++ b/pkg/services/rpcsrv/client_test.go @@ -45,6 +45,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/rpcclient/neo" "github.com/nspcc-dev/neo-go/pkg/rpcclient/nep11" "github.com/nspcc-dev/neo-go/pkg/rpcclient/nep17" + "github.com/nspcc-dev/neo-go/pkg/rpcclient/nep24" "github.com/nspcc-dev/neo-go/pkg/rpcclient/neptoken" "github.com/nspcc-dev/neo-go/pkg/rpcclient/nns" "github.com/nspcc-dev/neo-go/pkg/rpcclient/notary" @@ -2460,3 +2461,26 @@ func TestClient_GetVersion_Hardforks(t *testing.T) { } require.InDeltaMapValues(t, expected, v.Protocol.Hardforks, 0) } + +func TestClient_NEP24(t *testing.T) { + _, _, httpSrv := initServerWithInMemoryChain(t) + + c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{}) + require.NoError(t, err) + t.Cleanup(c.Close) + require.NoError(t, c.Init()) + + h, err := util.Uint160DecodeStringLE(nfsoContractHash) + require.NoError(t, err) + reader := nep24.NewRoyaltyReader(invoker.New(c, nil), h) + + t.Run("RoyaltyInfo", func(t *testing.T) { + id, err := util.Uint160DecodeStringLE(nfsoToken1ID) + require.NoError(t, err) + info, err := reader.RoyaltyInfo(id.BytesLE(), h, big.NewInt(1000)) + require.NoError(t, err) + for _, r := range info { + require.Equal(t, big.NewInt(50), r.Amount) + } + }) +}