mirror of
https://github.com/btcsuite/btcd.git
synced 2025-01-18 05:12:27 +01:00
Merge pull request #2276 from starius/wire-signet
wire: add bitcoin network magic for default SigNet
This commit is contained in:
commit
f3bd1f58e7
@ -9,6 +9,9 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"math/big"
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/btcsuite/btcd/wire"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestInvalidHashStr ensures the newShaHashFromStr function panics when used to
|
// TestInvalidHashStr ensures the newShaHashFromStr function panics when used to
|
||||||
@ -104,6 +107,12 @@ func TestSigNetPowLimit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestSigNetMagic makes sure that the default signet has the expected bitcoin
|
||||||
|
// network magic.
|
||||||
|
func TestSigNetMagic(t *testing.T) {
|
||||||
|
require.Equal(t, wire.SigNet, SigNetParams.Net)
|
||||||
|
}
|
||||||
|
|
||||||
// compactToBig is a copy of the blockchain.CompactToBig function. We copy it
|
// compactToBig is a copy of the blockchain.CompactToBig function. We copy it
|
||||||
// here so we don't run into a circular dependency just because of a test.
|
// here so we don't run into a circular dependency just because of a test.
|
||||||
func compactToBig(compact uint32) *big.Int {
|
func compactToBig(compact uint32) *big.Int {
|
||||||
|
@ -86,6 +86,7 @@ the following constants:
|
|||||||
wire.MainNet
|
wire.MainNet
|
||||||
wire.TestNet (Regression test network)
|
wire.TestNet (Regression test network)
|
||||||
wire.TestNet3 (Test network version 3)
|
wire.TestNet3 (Test network version 3)
|
||||||
|
wire.SigNet (Signet, default)
|
||||||
wire.SimNet (Simulation test network)
|
wire.SimNet (Simulation test network)
|
||||||
|
|
||||||
# Determining Message Type
|
# Determining Message Type
|
||||||
|
@ -165,7 +165,7 @@ func (f ServiceFlag) String() string {
|
|||||||
// BitcoinNet represents which bitcoin network a message belongs to.
|
// BitcoinNet represents which bitcoin network a message belongs to.
|
||||||
type BitcoinNet uint32
|
type BitcoinNet uint32
|
||||||
|
|
||||||
// Constants used to indicate the message bitcoin network. They can also be
|
// Constants used to indicate the message bitcoin network. They can also be
|
||||||
// used to seek to the next message when a stream's state is unknown, but
|
// used to seek to the next message when a stream's state is unknown, but
|
||||||
// this package does not provide that functionality since it's generally a
|
// this package does not provide that functionality since it's generally a
|
||||||
// better idea to simply disconnect clients that are misbehaving over TCP.
|
// better idea to simply disconnect clients that are misbehaving over TCP.
|
||||||
@ -179,6 +179,10 @@ const (
|
|||||||
// TestNet3 represents the test network (version 3).
|
// TestNet3 represents the test network (version 3).
|
||||||
TestNet3 BitcoinNet = 0x0709110b
|
TestNet3 BitcoinNet = 0x0709110b
|
||||||
|
|
||||||
|
// SigNet represents the public default SigNet. For custom signets,
|
||||||
|
// see CustomSignetParams.
|
||||||
|
SigNet BitcoinNet = 0x40CF030A
|
||||||
|
|
||||||
// SimNet represents the simulation test network.
|
// SimNet represents the simulation test network.
|
||||||
SimNet BitcoinNet = 0x12141c16
|
SimNet BitcoinNet = 0x12141c16
|
||||||
)
|
)
|
||||||
@ -189,6 +193,7 @@ var bnStrings = map[BitcoinNet]string{
|
|||||||
MainNet: "MainNet",
|
MainNet: "MainNet",
|
||||||
TestNet: "TestNet",
|
TestNet: "TestNet",
|
||||||
TestNet3: "TestNet3",
|
TestNet3: "TestNet3",
|
||||||
|
SigNet: "SigNet",
|
||||||
SimNet: "SimNet",
|
SimNet: "SimNet",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ func TestBitcoinNetStringer(t *testing.T) {
|
|||||||
{MainNet, "MainNet"},
|
{MainNet, "MainNet"},
|
||||||
{TestNet, "TestNet"},
|
{TestNet, "TestNet"},
|
||||||
{TestNet3, "TestNet3"},
|
{TestNet3, "TestNet3"},
|
||||||
|
{SigNet, "SigNet"},
|
||||||
{SimNet, "SimNet"},
|
{SimNet, "SimNet"},
|
||||||
{0xffffffff, "Unknown BitcoinNet (4294967295)"},
|
{0xffffffff, "Unknown BitcoinNet (4294967295)"},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user