netmode: add constant MainNetNeoFS and TestNetNeoFS

Extend netmode package with NeoFS chains IDs.

Close #3503

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
Ekaterina Pavlova 2024-07-31 11:02:17 +08:00
parent d8e3e57f88
commit ef20ba3701
3 changed files with 12 additions and 2 deletions

View file

@ -129,9 +129,9 @@ func getEmbeddedConfig(configPath string) ([]byte, error) {
return config.TestNet, nil
case fmt.Sprintf("%s/protocol.%s.yml", DefaultConfigPath, netmode.PrivNet):
return config.PrivNet, nil
case fmt.Sprintf("%s/protocol.mainnet.neofs.yml", DefaultConfigPath):
case fmt.Sprintf("%s/protocol.%s.yml", DefaultConfigPath, netmode.MainNetNeoFS):
return config.MainNetNeoFS, nil
case fmt.Sprintf("%s/protocol.testnet.neofs.yml", DefaultConfigPath):
case fmt.Sprintf("%s/protocol.%s.yml", DefaultConfigPath, netmode.TestNetNeoFS):
return config.TestNetNeoFS, nil
default:
return nil, fmt.Errorf("config '%s' doesn't exist and no matching embedded config was found", configPath)

View file

@ -11,6 +11,10 @@ const (
PrivNet Magic = 56753 // docker privnet
// UnitTestNet is a stub magic code used for testing purposes.
UnitTestNet Magic = 42
//MainNetNeoFS contains magic code used in the NeoFS main network.
MainNetNeoFS Magic = 0x572dfa5 // NeoFS mainnet
//TestNetNeoFS contains magic code used in the NeoFS test network.
TestNetNeoFS Magic = 0x2bdb2b5f // NeoFS testnet
)
// Magic describes the network the blockchain will operate on.
@ -27,6 +31,10 @@ func (n Magic) String() string {
return "mainnet"
case UnitTestNet:
return "unit_testnet"
case MainNetNeoFS:
return "mainnet.neofs"
case TestNetNeoFS:
return "testnet.neofs"
default:
return "net 0x" + strconv.FormatUint(uint64(n), 16)
}

View file

@ -1197,6 +1197,8 @@ func TestConfig_LoadDefaultConfigs(t *testing.T) {
netmode.PrivNet,
netmode.TestNet,
netmode.UnitTestNet,
netmode.MainNetNeoFS,
netmode.TestNetNeoFS,
"privnet.docker.one",
"privnet.docker.two",
"privnet.docker.three",