Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Brian Tiger Chow <[email protected]>
  • Loading branch information
Brian Tiger Chow committed Dec 13, 2014
1 parent 7cddd41 commit e92d48b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
6 changes: 3 additions & 3 deletions epictest/addcat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func AddCatBytes(conf Config) error {
)

local := sesgen.Next()
local.Configure(bitswap.BlockstoreLatency(0)) // set latency to zero during local add
local.SetBlockstoreLatency(0) // set latency to zero during local add
node, err := importer.BuildDagFromReader(
bytes.NewReader(data.Bytes()),
merkledag.NewDAGService(&blockservice.BlockService{local.Blockstore(), local.Exchange}),
Expand All @@ -120,10 +120,10 @@ func AddCatBytes(conf Config) error {
if err != nil {
return err
}
local.Configure(bitswap.BlockstoreLatency(conf.BlockstoreLatency)) // add some blockstore delay to make the requestor wait
local.SetBlockstoreLatency(conf.BlockstoreLatency) // add some blockstore delay to make the requestor wait

remote := sesgen.Next()
remote.Configure(bitswap.BlockstoreLatency(conf.BlockstoreLatency))
remote.SetBlockstoreLatency(conf.BlockstoreLatency)
remotedag := merkledag.NewDAGService(&blockservice.BlockService{remote.Blockstore(), remote.Exchange})
dagnode, err := (&path.Resolver{remotedag}).ResolvePath(k.String())
if err != nil {
Expand Down
15 changes: 2 additions & 13 deletions exchange/bitswap/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,8 @@ func (i *Instance) Blockstore() blockstore.Blockstore {
return i.blockstore
}

type IOption func(*Instance) IOption

func (i *Instance) Configure(opt IOption) IOption {
prev := opt(i)
return prev
}

// TODO move all of this to a mock package
func BlockstoreLatency(d time.Duration) IOption {
return func(i *Instance) IOption {
prev := i.blockstoreDelay.Set(d)
return BlockstoreLatency(prev)
}
func (i *Instance) SetBlockstoreLatency(t time.Duration) time.Duration {
return i.blockstoreDelay.Set(t)
}

// session creates a test bitswap session.
Expand Down

0 comments on commit e92d48b

Please sign in to comment.