Skip to content

Commit

Permalink
Set address current network for non-mainnet since default is changed (#…
Browse files Browse the repository at this point in the history
…12574)

Default `address.CurrentNetwork` was changed in an upstream dependency.
Update the build constants for non-mainnet to explicitly set it to
`Testnet`.

Add tests to assert it.
  • Loading branch information
masih authored and rjan90 committed Oct 14, 2024
1 parent ca7eaa7 commit a3c918d
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build/buildconstants/params_2k.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/ipfs/go-cid"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
)
Expand Down Expand Up @@ -98,6 +99,7 @@ var ConsensusMinerMinPower = abi.NewStoragePower(2048)
var PreCommitChallengeDelay = abi.ChainEpoch(10)

func init() {
SetAddressNetwork(address.Testnet)
getGenesisNetworkVersion := func(ev string, def network.Version) network.Version {
hs, found := os.LookupEnv(ev)
if found {
Expand Down
16 changes: 16 additions & 0 deletions build/buildconstants/params_2k_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build debug || 2k
// +build debug 2k

package buildconstants

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-address"
)

func Test_NetworkName(t *testing.T) {
require.Equal(t, address.CurrentNetwork, address.Testnet)
}
16 changes: 16 additions & 0 deletions build/buildconstants/params_butterfly_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build butterflynet
// +build butterflynet

package buildconstants

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-address"
)

func Test_NetworkName(t *testing.T) {
require.Equal(t, address.CurrentNetwork, address.Testnet)
}
16 changes: 16 additions & 0 deletions build/buildconstants/params_calibnet_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build calibnet
// +build calibnet

package buildconstants

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-address"
)

func Test_NetworkName(t *testing.T) {
require.Equal(t, address.CurrentNetwork, address.Testnet)
}
16 changes: 16 additions & 0 deletions build/buildconstants/params_interop_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build interopnet
// +build interopnet

package buildconstants

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-address"
)

func Test_NetworkName(t *testing.T) {
require.Equal(t, address.CurrentNetwork, address.Testnet)
}
16 changes: 16 additions & 0 deletions build/buildconstants/params_mainnet_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build !debug && !2k && !testground && !calibnet && !butterflynet && !interopnet
// +build !debug,!2k,!testground,!calibnet,!butterflynet,!interopnet

package buildconstants

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-address"
)

func Test_NetworkName(t *testing.T) {
require.Equal(t, address.CurrentNetwork, address.Mainnet)
}
2 changes: 2 additions & 0 deletions build/buildconstants/params_testground.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p/core/peer"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
Expand Down Expand Up @@ -137,6 +138,7 @@ var (
)

func init() {
SetAddressNetwork(address.Testnet)
Devnet = true
}

Expand Down
16 changes: 16 additions & 0 deletions build/buildconstants/params_testground_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build testground
// +build testground

package buildconstants

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-address"
)

func Test_NetworkName(t *testing.T) {
require.Equal(t, address.CurrentNetwork, address.Testnet)
}

0 comments on commit a3c918d

Please sign in to comment.