-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: adjust hardfork enabling logic
Follow the logic described in neo-project/neo#2886 (comment) and port the neo-project/neo#2886. Close #3096. Signed-off-by: Anna Shaleva <[email protected]>
- Loading branch information
1 parent
7d75526
commit 5d3938a
Showing
7 changed files
with
163 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package interop | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/nspcc-dev/neo-go/pkg/config" | ||
"github.com/nspcc-dev/neo-go/pkg/core/block" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestIsHardforkEnabled(t *testing.T) { | ||
t.Run("not configured", func(t *testing.T) { | ||
ic := &Context{Hardforks: map[string]uint32{config.HFAspidochelone.String(): 0, config.HFBasilisk.String(): 0}, Block: &block.Block{Header: block.Header{Index: 10}}} | ||
require.True(t, ic.IsHardforkEnabled(config.HFAspidochelone)) | ||
require.True(t, ic.IsHardforkEnabled(config.HFBasilisk)) | ||
}) | ||
t.Run("new disabled", func(t *testing.T) { | ||
ic := &Context{Hardforks: map[string]uint32{config.HFAspidochelone.String(): 5}, Block: &block.Block{Header: block.Header{Index: 10}}} | ||
require.True(t, ic.IsHardforkEnabled(config.HFAspidochelone)) | ||
require.False(t, ic.IsHardforkEnabled(config.HFBasilisk)) | ||
}) | ||
t.Run("old enabled", func(t *testing.T) { | ||
ic := &Context{Hardforks: map[string]uint32{config.HFAspidochelone.String(): 0, config.HFBasilisk.String(): 10}, Block: &block.Block{Header: block.Header{Index: 5}}} | ||
require.True(t, ic.IsHardforkEnabled(config.HFAspidochelone)) | ||
require.False(t, ic.IsHardforkEnabled(config.HFBasilisk)) | ||
}) | ||
t.Run("not yet enabled", func(t *testing.T) { | ||
ic := &Context{Hardforks: map[string]uint32{config.HFAspidochelone.String(): 10}, Block: &block.Block{Header: block.Header{Index: 5}}} | ||
require.False(t, ic.IsHardforkEnabled(config.HFAspidochelone)) | ||
}) | ||
t.Run("already enabled", func(t *testing.T) { | ||
ic := &Context{Hardforks: map[string]uint32{config.HFAspidochelone.String(): 10}, Block: &block.Block{Header: block.Header{Index: 15}}} | ||
require.True(t, ic.IsHardforkEnabled(config.HFAspidochelone)) | ||
}) | ||
} |