fix protocol tests

pull/4351/head
“GheisMohammadi” 2 years ago committed by Casey Gardiner
parent da83110429
commit eb15d13842
  1. 3
      api/service/stagedstreamsync/downloader.go
  2. 4
      api/service/stagedstreamsync/staged_stream_sync.go
  3. 2
      p2p/stream/common/streammanager/interface_test.go
  4. 2
      p2p/stream/common/streammanager/streammanager_test.go
  5. 12
      p2p/stream/protocols/sync/protocol_test.go
  6. 6
      p2p/stream/types/utils.go

@ -32,7 +32,7 @@ type (
downloadC chan struct{}
closeC chan struct{}
ctx context.Context
cancel func()
cancel context.CancelFunc
config Config
logger zerolog.Logger
@ -70,6 +70,7 @@ func NewDownloader(host p2p.Host, bc core.BlockChain, config Config) *Downloader
//TODO: use mem db should be in config file
stagedSyncInstance, err := CreateStagedSync(ctx, bc, false, sp, config, logger, config.LogProgress)
if err != nil {
cancel()
return nil
}

@ -65,7 +65,7 @@ type StagedStreamSync struct {
inserted int
config Config
logger zerolog.Logger
status status //TODO: merge this with currentSyncCycle
status *status //TODO: merge this with currentSyncCycle
initSync bool // if sets to true, node start long range syncing
UseMemDB bool
@ -294,7 +294,7 @@ func New(ctx context.Context,
db: db,
protocol: protocol,
gbm: nil,
status: status,
status: &status,
inserted: 0,
config: config,
logger: logger,

@ -17,7 +17,7 @@ var _ StreamManager = &streamManager{}
var (
myPeerID = makePeerID(0)
testProtoID = sttypes.ProtoID("harmony/sync/unitest/0/1.0.0")
testProtoID = sttypes.ProtoID("harmony/sync/unitest/0/1.0.0/1")
)
const (

@ -209,7 +209,7 @@ func TestStreamSet_numStreamsWithMinProtoID(t *testing.T) {
pid1 = testProtoID
numPid1 = 5
pid2 = sttypes.ProtoID("harmony/sync/unitest/0/1.0.1")
pid2 = sttypes.ProtoID("harmony/sync/unitest/0/1.0.1/1")
numPid2 = 10
)

@ -15,16 +15,18 @@ func TestProtocol_Match(t *testing.T) {
targetID string
exp bool
}{
{"harmony/sync/unitest/0/1.0.1", true},
{"harmony/sync/unitest/0/1.0.1/1", true},
{"harmony/sync/unitest/0/1.0.1/0", true},
{"h123456", false},
{"harmony/sync/unitest/0/0.9.9", false},
{"harmony/epoch/unitest/0/1.0.1", false},
{"harmony/sync/mainnet/0/1.0.1", false},
{"harmony/sync/unitest/1/1.0.1", false},
{"harmony/sync/unitest/0/0.9.9/1", false},
{"harmony/epoch/unitest/0/1.0.1/1", false},
{"harmony/sync/mainnet/0/1.0.1/1", false},
{"harmony/sync/unitest/1/1.0.1/1", false},
}
for i, test := range tests {
p := &Protocol{
beaconNode: true,
config: Config{
Network: "unitest",
ShardID: 0,

@ -49,8 +49,12 @@ type ProtoSpec struct {
// ToProtoID convert a ProtoSpec to ProtoID.
func (spec ProtoSpec) ToProtoID() ProtoID {
var versionStr string
if spec.Version != nil {
versionStr = spec.Version.String()
}
s := fmt.Sprintf(ProtoIDFormat, ProtoIDCommonPrefix, spec.Service,
spec.NetworkType, spec.ShardID, spec.Version.String(), bool2int(spec.BeaconNode))
spec.NetworkType, spec.ShardID, versionStr, bool2int(spec.BeaconNode))
return ProtoID(s)
}

Loading…
Cancel
Save