github.com/nspcc-dev/neo-go@v0.105.2-0.20240517133400-6be757af3eba/pkg/core/native/contract_test.go (about)

     1  package native
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/nspcc-dev/neo-go/pkg/config"
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  // TestNativeGetMethod is needed to ensure that methods list has the same sorting
    11  // rule as we expect inside the `ContractMD.GetMethod`.
    12  func TestNativeGetMethod(t *testing.T) {
    13  	cfg := config.ProtocolConfiguration{P2PSigExtensions: true}
    14  	cs := NewContracts(cfg)
    15  	latestHF := config.LatestHardfork()
    16  	for _, c := range cs.Contracts {
    17  		hfMD := c.Metadata().HFSpecificContractMD(&latestHF)
    18  		t.Run(c.Metadata().Name, func(t *testing.T) {
    19  			for _, m := range hfMD.Methods {
    20  				_, ok := hfMD.GetMethod(m.MD.Name, len(m.MD.Parameters))
    21  				require.True(t, ok)
    22  			}
    23  		})
    24  	}
    25  }