From a164db92cc119f12761982db7c9cd41e36ff31b3 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 4 Dec 2024 22:20:57 +0300 Subject: [PATCH] config: replace LatestHardfork() with HFLatestStable Function doesn't make much sense here. The change is rather trivial and this is not expected to be used by external code, so no deprecation. Signed-off-by: Roman Khimov --- pkg/compiler/native_test.go | 2 +- pkg/config/hardfork.go | 8 +++----- pkg/core/native/compatibility_test.go | 2 +- pkg/core/native/contract_test.go | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/compiler/native_test.go b/pkg/compiler/native_test.go index a3c6780e0..d3fe17e9b 100644 --- a/pkg/compiler/native_test.go +++ b/pkg/compiler/native_test.go @@ -310,7 +310,7 @@ func getMethod(t *testing.T, ctr interop.ContractMD, name string, params []strin name = strings.TrimSuffix(name, "WithData") } - latestHF := config.LatestHardfork() + latestHF := config.HFLatestKnown cMD := ctr.HFSpecificContractMD(&latestHF) md, ok := cMD.GetMethod(name, paramLen) require.True(t, ok, cMD.Manifest.Name, name, paramLen) diff --git a/pkg/config/hardfork.go b/pkg/config/hardfork.go index 675510989..6b946dde2 100644 --- a/pkg/config/hardfork.go +++ b/pkg/config/hardfork.go @@ -57,6 +57,9 @@ const ( // between releases even if the set of known hardforks is the same. const HFLatestStable = HFDomovoi +// HFLatestKnown is the latest known hardfork. +const HFLatestKnown = hfLast >> 1 + // StableHardforks is an ordered slice of all stable hardforks (before or // equal [HFLatestStable]). var StableHardforks []Hardfork @@ -110,8 +113,3 @@ func IsHardforkValid(s string) bool { _, ok := hardforks[s] return ok } - -// LatestHardfork returns latest known hardfork. -func LatestHardfork() Hardfork { - return hfLast >> 1 -} diff --git a/pkg/core/native/compatibility_test.go b/pkg/core/native/compatibility_test.go index d28c00bcd..9ed1074f4 100644 --- a/pkg/core/native/compatibility_test.go +++ b/pkg/core/native/compatibility_test.go @@ -12,7 +12,7 @@ import ( func TestNamesASCII(t *testing.T) { cfg := config.ProtocolConfiguration{P2PSigExtensions: true} cs := NewContracts(cfg) - latestHF := config.LatestHardfork() + latestHF := config.HFLatestKnown for _, c := range cs.Contracts { require.True(t, isASCII(c.Metadata().Name)) hfMD := c.Metadata().HFSpecificContractMD(&latestHF) diff --git a/pkg/core/native/contract_test.go b/pkg/core/native/contract_test.go index bda672689..c12cf25f9 100644 --- a/pkg/core/native/contract_test.go +++ b/pkg/core/native/contract_test.go @@ -12,7 +12,7 @@ import ( func TestNativeGetMethod(t *testing.T) { cfg := config.ProtocolConfiguration{P2PSigExtensions: true} cs := NewContracts(cfg) - latestHF := config.LatestHardfork() + latestHF := config.HFLatestKnown for _, c := range cs.Contracts { hfMD := c.Metadata().HFSpecificContractMD(&latestHF) t.Run(c.Metadata().Name, func(t *testing.T) {