diff --git a/tests/fixture/tmpnet/subnet.go b/tests/fixture/tmpnet/subnet.go index cbff01585e20..55979a2eb81c 100644 --- a/tests/fixture/tmpnet/subnet.go +++ b/tests/fixture/tmpnet/subnet.go @@ -25,7 +25,10 @@ import ( "github.com/ava-labs/avalanchego/wallet/subnet/primary/common" ) -const defaultSubnetDirName = "subnets" +const ( + defaultSubnetDirName = "subnets" + jsonFileSuffix = ".json" +) type Chain struct { // Set statically @@ -209,7 +212,7 @@ func (s *Subnet) Write(subnetDir string, chainDir string) error { if err := os.MkdirAll(subnetDir, perms.ReadWriteExecute); err != nil { return fmt.Errorf("failed to create subnet dir: %w", err) } - tmpnetConfigPath := filepath.Join(subnetDir, s.Name+".json") + tmpnetConfigPath := filepath.Join(subnetDir, s.Name+jsonFileSuffix) // Since subnets are expected to be serialized for the first time // without their chains having been created (i.e. chains will have @@ -249,13 +252,8 @@ func (s *Subnet) Write(subnetDir string, chainDir string) error { return fmt.Errorf("failed to marshal avalanchego subnet config %s: %w", s.Name, err) } - avgoConfigDir := filepath.Join(subnetDir, s.SubnetID.String()) - if err := os.MkdirAll(avgoConfigDir, perms.ReadWriteExecute); err != nil { - return fmt.Errorf("failed to create avalanchego subnet config dir: %w", err) - } - - avgoConfigPath := filepath.Join(avgoConfigDir, defaultConfigFilename) - if err := os.WriteFile(avgoConfigPath, bytes, perms.ReadWrite); err != nil { + subnetConfigPath := filepath.Join(subnetDir, s.SubnetID.String()+jsonFileSuffix) + if err := os.WriteFile(subnetConfigPath, bytes, perms.ReadWrite); err != nil { return fmt.Errorf("failed to write avalanchego subnet config %s: %w", s.Name, err) } } @@ -351,7 +349,7 @@ func readSubnets(subnetDir string) ([]*Subnet, error) { // Looking only for files continue } - if filepath.Ext(entry.Name()) != ".json" { + if filepath.Ext(entry.Name()) != jsonFileSuffix { // Subnet files should have a .json extension continue }