core: add nativenames.All list
It's useful to keep the ordered set of native contract names. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
4ca2686583
commit
36e128516b
2 changed files with 28 additions and 0 deletions
|
@ -2480,3 +2480,17 @@ func TestBlockchain_GenesisTransactionExtension(t *testing.T) {
|
|||
require.Equal(t, int64(amount), actualNeo.Int64())
|
||||
require.Equal(t, 0, int(lub))
|
||||
}
|
||||
|
||||
// TestNativenames ensures that nativenames.All contains all expected native contract names
|
||||
// in the right order.
|
||||
func TestNativenames(t *testing.T) {
|
||||
bc, _ := chain.NewSingleWithCustomConfig(t, func(cfg *config.Blockchain) {
|
||||
cfg.Hardforks = map[string]uint32{}
|
||||
cfg.P2PSigExtensions = true
|
||||
})
|
||||
natives := bc.GetNatives()
|
||||
require.Equal(t, len(natives), len(nativenames.All))
|
||||
for i, cs := range natives {
|
||||
require.Equal(t, cs.Manifest.Name, nativenames.All[i], i)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,20 @@ const (
|
|||
StdLib = "StdLib"
|
||||
)
|
||||
|
||||
// All contains the list of all native contract names ordered by the contract ID.
|
||||
var All = []string{
|
||||
Management,
|
||||
StdLib,
|
||||
CryptoLib,
|
||||
Ledger,
|
||||
Neo,
|
||||
Gas,
|
||||
Policy,
|
||||
Designation,
|
||||
Oracle,
|
||||
Notary,
|
||||
}
|
||||
|
||||
// IsValid checks if the name is a valid native contract's name.
|
||||
func IsValid(name string) bool {
|
||||
return name == Management ||
|
||||
|
|
Loading…
Reference in a new issue