2015-02-25 14:34:12 +02:00
|
|
|
package blockpool
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/blockpool/test"
|
2015-03-20 00:53:15 +02:00
|
|
|
"github.com/ethereum/go-ethereum/event"
|
2015-02-25 14:34:12 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestBlockPoolConfig(t *testing.T) {
|
|
|
|
test.LogInit()
|
2015-03-20 00:53:15 +02:00
|
|
|
blockPool := &BlockPool{Config: &Config{}, chainEvents: &event.TypeMux{}}
|
2015-02-25 14:34:12 +02:00
|
|
|
blockPool.Start()
|
|
|
|
c := blockPool.Config
|
|
|
|
test.CheckInt("BlockHashesBatchSize", c.BlockHashesBatchSize, blockHashesBatchSize, t)
|
|
|
|
test.CheckInt("BlockBatchSize", c.BlockBatchSize, blockBatchSize, t)
|
|
|
|
test.CheckInt("BlocksRequestRepetition", c.BlocksRequestRepetition, blocksRequestRepetition, t)
|
|
|
|
test.CheckInt("BlocksRequestMaxIdleRounds", c.BlocksRequestMaxIdleRounds, blocksRequestMaxIdleRounds, t)
|
2015-04-12 22:25:09 +03:00
|
|
|
test.CheckInt("NodeCacheSize", c.NodeCacheSize, nodeCacheSize, t)
|
2015-02-25 14:34:12 +02:00
|
|
|
test.CheckDuration("BlockHashesRequestInterval", c.BlockHashesRequestInterval, blockHashesRequestInterval, t)
|
|
|
|
test.CheckDuration("BlocksRequestInterval", c.BlocksRequestInterval, blocksRequestInterval, t)
|
|
|
|
test.CheckDuration("BlockHashesTimeout", c.BlockHashesTimeout, blockHashesTimeout, t)
|
|
|
|
test.CheckDuration("BlocksTimeout", c.BlocksTimeout, blocksTimeout, t)
|
2015-03-03 21:06:15 +02:00
|
|
|
test.CheckDuration("IdleBestPeerTimeout", c.IdleBestPeerTimeout, idleBestPeerTimeout, t)
|
2015-03-20 00:46:54 +02:00
|
|
|
test.CheckDuration("PeerSuspensionInterval", c.PeerSuspensionInterval, peerSuspensionInterval, t)
|
2015-03-20 01:14:08 +02:00
|
|
|
test.CheckDuration("StatusUpdateInterval", c.StatusUpdateInterval, statusUpdateInterval, t)
|
2015-02-25 14:34:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestBlockPoolOverrideConfig(t *testing.T) {
|
|
|
|
test.LogInit()
|
2015-03-20 00:53:15 +02:00
|
|
|
blockPool := &BlockPool{Config: &Config{}, chainEvents: &event.TypeMux{}}
|
2015-04-12 22:25:09 +03:00
|
|
|
c := &Config{128, 32, 1, 0, 500, 300 * time.Millisecond, 100 * time.Millisecond, 90 * time.Second, 0, 30 * time.Second, 30 * time.Second, 4 * time.Second}
|
2015-02-25 14:34:12 +02:00
|
|
|
|
|
|
|
blockPool.Config = c
|
|
|
|
blockPool.Start()
|
|
|
|
test.CheckInt("BlockHashesBatchSize", c.BlockHashesBatchSize, 128, t)
|
|
|
|
test.CheckInt("BlockBatchSize", c.BlockBatchSize, 32, t)
|
|
|
|
test.CheckInt("BlocksRequestRepetition", c.BlocksRequestRepetition, blocksRequestRepetition, t)
|
|
|
|
test.CheckInt("BlocksRequestMaxIdleRounds", c.BlocksRequestMaxIdleRounds, blocksRequestMaxIdleRounds, t)
|
2015-04-12 22:25:09 +03:00
|
|
|
test.CheckInt("NodeCacheSize", c.NodeCacheSize, 500, t)
|
2015-02-25 14:34:12 +02:00
|
|
|
test.CheckDuration("BlockHashesRequestInterval", c.BlockHashesRequestInterval, 300*time.Millisecond, t)
|
|
|
|
test.CheckDuration("BlocksRequestInterval", c.BlocksRequestInterval, 100*time.Millisecond, t)
|
|
|
|
test.CheckDuration("BlockHashesTimeout", c.BlockHashesTimeout, 90*time.Second, t)
|
|
|
|
test.CheckDuration("BlocksTimeout", c.BlocksTimeout, blocksTimeout, t)
|
2015-03-03 21:06:15 +02:00
|
|
|
test.CheckDuration("IdleBestPeerTimeout", c.IdleBestPeerTimeout, 30*time.Second, t)
|
2015-03-20 00:46:54 +02:00
|
|
|
test.CheckDuration("PeerSuspensionInterval", c.PeerSuspensionInterval, 30*time.Second, t)
|
2015-03-20 01:14:08 +02:00
|
|
|
test.CheckDuration("StatusUpdateInterval", c.StatusUpdateInterval, 4*time.Second, t)
|
2015-02-25 14:34:12 +02:00
|
|
|
}
|