Skip to content

Commit

Permalink
Merge pull request #429 from ava-labs/tmpnet-deferrals
Browse files Browse the repository at this point in the history
Tmpnet deferrals
  • Loading branch information
feuGeneA authored Jul 19, 2024
2 parents 3b82c10 + 4afe45b commit c6c6117
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions tests/interfaces/subnet_test_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

// Tracks information about a test subnet used for executing tests against.
type SubnetTestInfo struct {
SubnetName string
SubnetID ids.ID
BlockchainID ids.ID
NodeURIs []string
Expand Down
4 changes: 2 additions & 2 deletions tests/local/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ var _ = ginkgo.BeforeSuite(func() {
log.Info("Set up ginkgo before suite")

ginkgo.AddReportEntry(
"network directory with has node logs & configs; useful in the case of failures",
LocalNetworkInstance.Dir(),
"network directory with node logs & configs; useful in the case of failures",
LocalNetworkInstance.tmpnet.Dir,
ginkgo.ReportEntryVisibilityFailureOrVerbose,
)
})
Expand Down
20 changes: 13 additions & 7 deletions tests/local/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ func (n *LocalNetwork) setPrimaryNetworkValues() {
// Get the C-Chain node URIs.
// All subnet nodes validate the C-Chain, so we can include them all here
var nodeURIs []string
nodeURIs = append(nodeURIs, n.subnetsInfo[n.tmpnet.GetSubnet("A").SubnetID].NodeURIs...)
nodeURIs = append(nodeURIs, n.subnetsInfo[n.tmpnet.GetSubnet("B").SubnetID].NodeURIs...)
for _, subnetInfo := range n.subnetsInfo {
nodeURIs = append(nodeURIs, subnetInfo.NodeURIs...)
}
for _, extraNode := range n.extraNodes {
uri, err := n.tmpnet.GetURIForNodeID(extraNode.NodeID)
Expect(err).Should(BeNil())
Expand Down Expand Up @@ -231,6 +232,7 @@ func (n *LocalNetwork) setSubnetValues(subnet *tmpnet.Subnet) {
if n.subnetsInfo[subnetID] == nil {
n.subnetsInfo[subnetID] = &interfaces.SubnetTestInfo{}
}
n.subnetsInfo[subnetID].SubnetName = subnet.Name
n.subnetsInfo[subnetID].SubnetID = subnetID
n.subnetsInfo[subnetID].BlockchainID = blockchainID
n.subnetsInfo[subnetID].NodeURIs = chainNodeURIs
Expand Down Expand Up @@ -336,10 +338,11 @@ func (n *LocalNetwork) DeployTeleporterRegistryContracts(
}

func (n *LocalNetwork) GetSubnetsInfo() []interfaces.SubnetTestInfo {
return []interfaces.SubnetTestInfo{
*n.subnetsInfo[n.tmpnet.GetSubnet("A").SubnetID],
*n.subnetsInfo[n.tmpnet.GetSubnet("B").SubnetID],
subnetsInfo := make([]interfaces.SubnetTestInfo, 0, len(n.subnetsInfo))
for _, subnetInfo := range n.subnetsInfo {
subnetsInfo = append(subnetsInfo, *subnetInfo)
}
return subnetsInfo
}

func (n *LocalNetwork) GetPrimaryNetworkInfo() interfaces.SubnetTestInfo {
Expand Down Expand Up @@ -430,8 +433,11 @@ func (n *LocalNetwork) setAllSubnetValues() {
subnetIDs := n.GetSubnetsInfo()
Expect(len(subnetIDs)).Should(Equal(2))

n.setSubnetValues(n.tmpnet.GetSubnet("A"))
n.setSubnetValues(n.tmpnet.GetSubnet("B"))
for _, subnetInfo := range n.subnetsInfo {
subnet := n.tmpnet.GetSubnet(subnetInfo.SubnetName)
Expect(subnet).ShouldNot(BeNil())
n.setSubnetValues(n.tmpnet.GetSubnet(subnetInfo.SubnetName))
}

n.setPrimaryNetworkValues()
}
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ func InstantiateGenesisTemplate(

var replaced string = string(templateFileBytes[:])
for _, s := range substitutions {
replaced = strings.Replace(replaced, s.Target, s.Value, 1)
replaced = strings.ReplaceAll(replaced, s.Target, s.Value)
}

subnetGenesisFile.WriteString(replaced)
Expand Down

0 comments on commit c6c6117

Please sign in to comment.