)
func TestCalcReorganizeNodes(t *testing.T) {
+ config.CommonConfig = config.DefaultConfig()
c := &Chain{index: state.NewBlockIndex()}
header := config.GenesisBlock().BlockHeader
initNode, err := state.NewBlockNode(&header, nil)
mainChainNode := initNode
for i := 1; i <= 7; i++ {
header.Height = uint64(i)
- header.Nonce = 0
mainChainNode, err = state.NewBlockNode(&header, mainChainNode)
if err != nil {
t.Fatal(err)
sideChainNode := initNode
for i := 1; i <= 13; i++ {
header.Height = uint64(i)
- header.Nonce = 1
sideChainNode, err = state.NewBlockNode(&header, sideChainNode)
if err != nil {
t.Fatal(err)
}
func TestEdgeCalcReorganizeNodes(t *testing.T) {
+ config.CommonConfig = config.DefaultConfig()
header := config.GenesisBlock().BlockHeader
initNode, err := state.NewBlockNode(&header, nil)
if err != nil {
for i := uint64(1); i <= 5; i++ {
node := &state.BlockNode{
Height: i,
- Nonce: 0,
Hash: bc.Hash{V0: uint64(i)},
Parent: testNodes[i-1],
}
newNode := &state.BlockNode{
Height: i,
- Nonce: 1,
Hash: bc.Hash{V1: uint64(i)},
Parent: testNewNodes[i-1],
}