mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-03 21:08:17 +08:00
Merge pull request #294 from jbenet/maybebtc-november
miscellaneous fixes
This commit is contained in:
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
@ -120,7 +120,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/jbenet/go-random",
|
"ImportPath": "github.com/jbenet/go-random",
|
||||||
"Rev": "e4585173eb8c47eea36c3dbff22f26f3f94d3586"
|
"Rev": "2e83344e7dc7898f94501665af34edd4aa95a013"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/kr/binarydist",
|
"ImportPath": "github.com/kr/binarydist",
|
||||||
|
8
Godeps/_workspace/src/github.com/jbenet/go-random/lib.go
generated
vendored
8
Godeps/_workspace/src/github.com/jbenet/go-random/lib.go
generated
vendored
@ -26,10 +26,10 @@ func WritePseudoRandomBytes(count int64, w io.Writer, seed int64) error {
|
|||||||
b = b[:bufsize]
|
b = b[:bufsize]
|
||||||
}
|
}
|
||||||
|
|
||||||
var n int64
|
var n uint32
|
||||||
for i := int64(0); i < bufsize; i++ {
|
for i := int64(0); i < bufsize; {
|
||||||
n = randmath.Int63()
|
n = randmath.Uint32()
|
||||||
for j := 0; j < 8 && i < bufsize; j++ {
|
for j := 0; j < 4 && i < bufsize; j++ {
|
||||||
b[i] = byte(n & 0xff)
|
b[i] = byte(n & 0xff)
|
||||||
n >>= 8
|
n >>= 8
|
||||||
i++
|
i++
|
||||||
|
@ -131,7 +131,7 @@ func (i *cmdInvocation) Run() (output io.Reader, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if debug || u.GetenvBool("DEBUG") {
|
if debug || u.GetenvBool("DEBUG") || os.Getenv("IPFS_LOGGING") == "debug" {
|
||||||
u.Debug = true
|
u.Debug = true
|
||||||
u.SetAllLoggers(logging.DEBUG)
|
u.SetAllLoggers(logging.DEBUG)
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
diag "github.com/jbenet/go-ipfs/diagnostics"
|
diag "github.com/jbenet/go-ipfs/diagnostics"
|
||||||
exchange "github.com/jbenet/go-ipfs/exchange"
|
exchange "github.com/jbenet/go-ipfs/exchange"
|
||||||
bitswap "github.com/jbenet/go-ipfs/exchange/bitswap"
|
bitswap "github.com/jbenet/go-ipfs/exchange/bitswap"
|
||||||
|
bsnet "github.com/jbenet/go-ipfs/exchange/bitswap/network"
|
||||||
merkledag "github.com/jbenet/go-ipfs/merkledag"
|
merkledag "github.com/jbenet/go-ipfs/merkledag"
|
||||||
namesys "github.com/jbenet/go-ipfs/namesys"
|
namesys "github.com/jbenet/go-ipfs/namesys"
|
||||||
inet "github.com/jbenet/go-ipfs/net"
|
inet "github.com/jbenet/go-ipfs/net"
|
||||||
@ -150,8 +151,8 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
|
|||||||
|
|
||||||
// setup exchange service
|
// setup exchange service
|
||||||
const alwaysSendToPeer = true // use YesManStrategy
|
const alwaysSendToPeer = true // use YesManStrategy
|
||||||
n.Exchange = bitswap.NetMessageSession(ctx, n.Identity, n.Network, exchangeService, n.Routing, n.Datastore, alwaysSendToPeer)
|
bitswapNetwork := bsnet.NewFromIpfsNetwork(exchangeService, n.Network)
|
||||||
// ok, this function call is ridiculous o/ consider making it simpler.
|
n.Exchange = bitswap.New(ctx, n.Identity, bitswapNetwork, n.Routing, n.Datastore, alwaysSendToPeer)
|
||||||
|
|
||||||
go initConnections(ctx, n.Config, n.Peerstore, dhtRouting)
|
go initConnections(ctx, n.Config, n.Peerstore, dhtRouting)
|
||||||
}
|
}
|
||||||
|
@ -15,24 +15,21 @@ import (
|
|||||||
bsnet "github.com/jbenet/go-ipfs/exchange/bitswap/network"
|
bsnet "github.com/jbenet/go-ipfs/exchange/bitswap/network"
|
||||||
notifications "github.com/jbenet/go-ipfs/exchange/bitswap/notifications"
|
notifications "github.com/jbenet/go-ipfs/exchange/bitswap/notifications"
|
||||||
strategy "github.com/jbenet/go-ipfs/exchange/bitswap/strategy"
|
strategy "github.com/jbenet/go-ipfs/exchange/bitswap/strategy"
|
||||||
inet "github.com/jbenet/go-ipfs/net"
|
|
||||||
peer "github.com/jbenet/go-ipfs/peer"
|
peer "github.com/jbenet/go-ipfs/peer"
|
||||||
u "github.com/jbenet/go-ipfs/util"
|
u "github.com/jbenet/go-ipfs/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = u.Logger("bitswap")
|
var log = u.Logger("bitswap")
|
||||||
|
|
||||||
// NetMessageSession initializes a BitSwap session that communicates over the
|
// New initializes a BitSwap instance that communicates over the
|
||||||
// provided NetMessage service.
|
// provided BitSwapNetwork. This function registers the returned instance as
|
||||||
|
// the network delegate.
|
||||||
// Runs until context is cancelled
|
// Runs until context is cancelled
|
||||||
func NetMessageSession(ctx context.Context, p peer.Peer,
|
func New(ctx context.Context, p peer.Peer,
|
||||||
net inet.Network, srv inet.Service, directory bsnet.Routing,
|
network bsnet.BitSwapNetwork, routing bsnet.Routing,
|
||||||
d ds.ThreadSafeDatastore, nice bool) exchange.Interface {
|
d ds.ThreadSafeDatastore, nice bool) exchange.Interface {
|
||||||
|
|
||||||
networkAdapter := bsnet.NetMessageAdapter(srv, net, nil)
|
|
||||||
|
|
||||||
notif := notifications.New()
|
notif := notifications.New()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
@ -44,11 +41,11 @@ func NetMessageSession(ctx context.Context, p peer.Peer,
|
|||||||
blockstore: blockstore.NewBlockstore(d),
|
blockstore: blockstore.NewBlockstore(d),
|
||||||
notifications: notif,
|
notifications: notif,
|
||||||
strategy: strategy.New(nice),
|
strategy: strategy.New(nice),
|
||||||
routing: directory,
|
routing: routing,
|
||||||
sender: networkAdapter,
|
sender: network,
|
||||||
wantlist: u.NewKeySet(),
|
wantlist: u.NewKeySet(),
|
||||||
}
|
}
|
||||||
networkAdapter.SetDelegate(bs)
|
network.SetDelegate(bs)
|
||||||
|
|
||||||
return bs
|
return bs
|
||||||
}
|
}
|
||||||
@ -57,7 +54,7 @@ func NetMessageSession(ctx context.Context, p peer.Peer,
|
|||||||
type bitswap struct {
|
type bitswap struct {
|
||||||
|
|
||||||
// sender delivers messages on behalf of the session
|
// sender delivers messages on behalf of the session
|
||||||
sender bsnet.Adapter
|
sender bsnet.BitSwapNetwork
|
||||||
|
|
||||||
// blockstore is the local database
|
// blockstore is the local database
|
||||||
// NB: ensure threadsafety
|
// NB: ensure threadsafety
|
||||||
|
@ -90,6 +90,9 @@ func TestGetBlockFromPeerAfterPeerAnnounces(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSwarm(t *testing.T) {
|
func TestSwarm(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
net := tn.VirtualNetwork()
|
net := tn.VirtualNetwork()
|
||||||
rs := mock.VirtualRoutingServer()
|
rs := mock.VirtualRoutingServer()
|
||||||
sg := NewSessionGenerator(net, rs)
|
sg := NewSessionGenerator(net, rs)
|
||||||
|
@ -8,8 +8,8 @@ import (
|
|||||||
u "github.com/jbenet/go-ipfs/util"
|
u "github.com/jbenet/go-ipfs/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Adapter provides network connectivity for BitSwap sessions
|
// BitSwapNetwork provides network connectivity for BitSwap sessions
|
||||||
type Adapter interface {
|
type BitSwapNetwork interface {
|
||||||
|
|
||||||
// DialPeer ensures there is a connection to peer.
|
// DialPeer ensures there is a connection to peer.
|
||||||
DialPeer(context.Context, peer.Peer) error
|
DialPeer(context.Context, peer.Peer) error
|
||||||
@ -31,6 +31,7 @@ type Adapter interface {
|
|||||||
SetDelegate(Receiver)
|
SetDelegate(Receiver)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Implement Receiver to receive messages from the BitSwapNetwork
|
||||||
type Receiver interface {
|
type Receiver interface {
|
||||||
ReceiveMessage(
|
ReceiveMessage(
|
||||||
ctx context.Context, sender peer.Peer, incoming bsmsg.BitSwapMessage) (
|
ctx context.Context, sender peer.Peer, incoming bsmsg.BitSwapMessage) (
|
||||||
@ -39,7 +40,6 @@ type Receiver interface {
|
|||||||
ReceiveError(error)
|
ReceiveError(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO rename -> Router?
|
|
||||||
type Routing interface {
|
type Routing interface {
|
||||||
// FindProvidersAsync returns a channel of providers for the given key
|
// FindProvidersAsync returns a channel of providers for the given key
|
||||||
FindProvidersAsync(context.Context, u.Key, int) <-chan peer.Peer
|
FindProvidersAsync(context.Context, u.Key, int) <-chan peer.Peer
|
||||||
|
@ -4,31 +4,32 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
|
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
|
||||||
"github.com/jbenet/go-ipfs/util"
|
|
||||||
|
|
||||||
bsmsg "github.com/jbenet/go-ipfs/exchange/bitswap/message"
|
bsmsg "github.com/jbenet/go-ipfs/exchange/bitswap/message"
|
||||||
inet "github.com/jbenet/go-ipfs/net"
|
inet "github.com/jbenet/go-ipfs/net"
|
||||||
netmsg "github.com/jbenet/go-ipfs/net/message"
|
netmsg "github.com/jbenet/go-ipfs/net/message"
|
||||||
peer "github.com/jbenet/go-ipfs/peer"
|
peer "github.com/jbenet/go-ipfs/peer"
|
||||||
|
util "github.com/jbenet/go-ipfs/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = util.Logger("net_message_adapter")
|
var log = util.Logger("bitswap_network")
|
||||||
|
|
||||||
// NetMessageAdapter wraps a NetMessage network service
|
// NewFromIpfsNetwork returns a BitSwapNetwork supported by underlying IPFS
|
||||||
func NetMessageAdapter(s inet.Service, n inet.Network, r Receiver) Adapter {
|
// Dialer & Service
|
||||||
adapter := impl{
|
func NewFromIpfsNetwork(s inet.Service, dialer inet.Dialer) BitSwapNetwork {
|
||||||
nms: s,
|
bitswapNetwork := impl{
|
||||||
net: n,
|
service: s,
|
||||||
receiver: r,
|
dialer: dialer,
|
||||||
}
|
}
|
||||||
s.SetHandler(&adapter)
|
s.SetHandler(&bitswapNetwork)
|
||||||
return &adapter
|
return &bitswapNetwork
|
||||||
}
|
}
|
||||||
|
|
||||||
// implements an Adapter that integrates with a NetMessage network service
|
// impl transforms the ipfs network interface, which sends and receives
|
||||||
|
// NetMessage objects, into the bitswap network interface.
|
||||||
type impl struct {
|
type impl struct {
|
||||||
nms inet.Service
|
service inet.Service
|
||||||
net inet.Network
|
dialer inet.Dialer
|
||||||
|
|
||||||
// inbound messages from the network are forwarded to the receiver
|
// inbound messages from the network are forwarded to the receiver
|
||||||
receiver Receiver
|
receiver Receiver
|
||||||
@ -36,30 +37,30 @@ type impl struct {
|
|||||||
|
|
||||||
// HandleMessage marshals and unmarshals net messages, forwarding them to the
|
// HandleMessage marshals and unmarshals net messages, forwarding them to the
|
||||||
// BitSwapMessage receiver
|
// BitSwapMessage receiver
|
||||||
func (adapter *impl) HandleMessage(
|
func (bsnet *impl) HandleMessage(
|
||||||
ctx context.Context, incoming netmsg.NetMessage) netmsg.NetMessage {
|
ctx context.Context, incoming netmsg.NetMessage) netmsg.NetMessage {
|
||||||
|
|
||||||
if adapter.receiver == nil {
|
if bsnet.receiver == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
received, err := bsmsg.FromNet(incoming)
|
received, err := bsmsg.FromNet(incoming)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
go adapter.receiver.ReceiveError(err)
|
go bsnet.receiver.ReceiveError(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
p, bsmsg := adapter.receiver.ReceiveMessage(ctx, incoming.Peer(), received)
|
p, bsmsg := bsnet.receiver.ReceiveMessage(ctx, incoming.Peer(), received)
|
||||||
|
|
||||||
// TODO(brian): put this in a helper function
|
// TODO(brian): put this in a helper function
|
||||||
if bsmsg == nil || p == nil {
|
if bsmsg == nil || p == nil {
|
||||||
adapter.receiver.ReceiveError(errors.New("ReceiveMessage returned nil peer or message"))
|
bsnet.receiver.ReceiveError(errors.New("ReceiveMessage returned nil peer or message"))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
outgoing, err := bsmsg.ToNet(p)
|
outgoing, err := bsmsg.ToNet(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
go adapter.receiver.ReceiveError(err)
|
go bsnet.receiver.ReceiveError(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,11 +68,11 @@ func (adapter *impl) HandleMessage(
|
|||||||
return outgoing
|
return outgoing
|
||||||
}
|
}
|
||||||
|
|
||||||
func (adapter *impl) DialPeer(ctx context.Context, p peer.Peer) error {
|
func (bsnet *impl) DialPeer(ctx context.Context, p peer.Peer) error {
|
||||||
return adapter.net.DialPeer(ctx, p)
|
return bsnet.dialer.DialPeer(ctx, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (adapter *impl) SendMessage(
|
func (bsnet *impl) SendMessage(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
p peer.Peer,
|
p peer.Peer,
|
||||||
outgoing bsmsg.BitSwapMessage) error {
|
outgoing bsmsg.BitSwapMessage) error {
|
||||||
@ -80,10 +81,10 @@ func (adapter *impl) SendMessage(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return adapter.nms.SendMessage(ctx, nmsg)
|
return bsnet.service.SendMessage(ctx, nmsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (adapter *impl) SendRequest(
|
func (bsnet *impl) SendRequest(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
p peer.Peer,
|
p peer.Peer,
|
||||||
outgoing bsmsg.BitSwapMessage) (bsmsg.BitSwapMessage, error) {
|
outgoing bsmsg.BitSwapMessage) (bsmsg.BitSwapMessage, error) {
|
||||||
@ -92,13 +93,13 @@ func (adapter *impl) SendRequest(
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
incomingMsg, err := adapter.nms.SendRequest(ctx, outgoingMsg)
|
incomingMsg, err := bsnet.service.SendRequest(ctx, outgoingMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return bsmsg.FromNet(incomingMsg)
|
return bsmsg.FromNet(incomingMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (adapter *impl) SetDelegate(r Receiver) {
|
func (bsnet *impl) SetDelegate(r Receiver) {
|
||||||
adapter.receiver = r
|
bsnet.receiver = r
|
||||||
}
|
}
|
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Network interface {
|
type Network interface {
|
||||||
Adapter(peer.Peer) bsnet.Adapter
|
Adapter(peer.Peer) bsnet.BitSwapNetwork
|
||||||
|
|
||||||
HasPeer(peer.Peer) bool
|
HasPeer(peer.Peer) bool
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ type network struct {
|
|||||||
clients map[util.Key]bsnet.Receiver
|
clients map[util.Key]bsnet.Receiver
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *network) Adapter(p peer.Peer) bsnet.Adapter {
|
func (n *network) Adapter(p peer.Peer) bsnet.BitSwapNetwork {
|
||||||
client := &networkClient{
|
client := &networkClient{
|
||||||
local: p,
|
local: p,
|
||||||
network: n,
|
network: n,
|
||||||
|
@ -83,6 +83,9 @@ func setupIpnsTest(t *testing.T, node *core.IpfsNode) (*core.IpfsNode, *fstest.M
|
|||||||
|
|
||||||
// Test writing a file and reading it back
|
// Test writing a file and reading it back
|
||||||
func TestIpnsBasicIO(t *testing.T) {
|
func TestIpnsBasicIO(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
_, mnt := setupIpnsTest(t, nil)
|
_, mnt := setupIpnsTest(t, nil)
|
||||||
defer mnt.Close()
|
defer mnt.Close()
|
||||||
|
|
||||||
@ -101,6 +104,9 @@ func TestIpnsBasicIO(t *testing.T) {
|
|||||||
|
|
||||||
// Test to make sure file changes persist over mounts of ipns
|
// Test to make sure file changes persist over mounts of ipns
|
||||||
func TestFilePersistence(t *testing.T) {
|
func TestFilePersistence(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
node, mnt := setupIpnsTest(t, nil)
|
node, mnt := setupIpnsTest(t, nil)
|
||||||
|
|
||||||
fname := "/local/atestfile"
|
fname := "/local/atestfile"
|
||||||
@ -126,6 +132,9 @@ func TestFilePersistence(t *testing.T) {
|
|||||||
|
|
||||||
// Test to make sure the filesystem reports file sizes correctly
|
// Test to make sure the filesystem reports file sizes correctly
|
||||||
func TestFileSizeReporting(t *testing.T) {
|
func TestFileSizeReporting(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
_, mnt := setupIpnsTest(t, nil)
|
_, mnt := setupIpnsTest(t, nil)
|
||||||
defer mnt.Close()
|
defer mnt.Close()
|
||||||
|
|
||||||
@ -144,6 +153,9 @@ func TestFileSizeReporting(t *testing.T) {
|
|||||||
|
|
||||||
// Test to make sure you cant create multiple entries with the same name
|
// Test to make sure you cant create multiple entries with the same name
|
||||||
func TestDoubleEntryFailure(t *testing.T) {
|
func TestDoubleEntryFailure(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
_, mnt := setupIpnsTest(t, nil)
|
_, mnt := setupIpnsTest(t, nil)
|
||||||
defer mnt.Close()
|
defer mnt.Close()
|
||||||
|
|
||||||
@ -160,6 +172,9 @@ func TestDoubleEntryFailure(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAppendFile(t *testing.T) {
|
func TestAppendFile(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
_, mnt := setupIpnsTest(t, nil)
|
_, mnt := setupIpnsTest(t, nil)
|
||||||
defer mnt.Close()
|
defer mnt.Close()
|
||||||
|
|
||||||
@ -198,6 +213,9 @@ func TestAppendFile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFastRepublish(t *testing.T) {
|
func TestFastRepublish(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
// make timeout noticeable.
|
// make timeout noticeable.
|
||||||
osrt := shortRepublishTimeout
|
osrt := shortRepublishTimeout
|
||||||
@ -299,6 +317,9 @@ func TestFastRepublish(t *testing.T) {
|
|||||||
|
|
||||||
// Test writing a medium sized file one byte at a time
|
// Test writing a medium sized file one byte at a time
|
||||||
func TestMultiWrite(t *testing.T) {
|
func TestMultiWrite(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
_, mnt := setupIpnsTest(t, nil)
|
_, mnt := setupIpnsTest(t, nil)
|
||||||
defer mnt.Close()
|
defer mnt.Close()
|
||||||
|
@ -21,6 +21,9 @@ func copyBuf(buf []byte) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSizeSplitterIsDeterministic(t *testing.T) {
|
func TestSizeSplitterIsDeterministic(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
test := func() {
|
test := func() {
|
||||||
bufR := randBuf(t, 10000000) // crank this up to satisfy yourself.
|
bufR := randBuf(t, 10000000) // crank this up to satisfy yourself.
|
||||||
|
@ -19,6 +19,9 @@ import (
|
|||||||
// These tests tests a combination of unixfs/io/dagreader and importer/chunk.
|
// These tests tests a combination of unixfs/io/dagreader and importer/chunk.
|
||||||
// Maybe split them up somehow?
|
// Maybe split them up somehow?
|
||||||
func TestBuildDag(t *testing.T) {
|
func TestBuildDag(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
td := os.TempDir()
|
td := os.TempDir()
|
||||||
fi, err := os.Create(td + "/tmpfi")
|
fi, err := os.Create(td + "/tmpfi")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -40,6 +43,9 @@ func TestBuildDag(t *testing.T) {
|
|||||||
|
|
||||||
//Test where calls to read are smaller than the chunk size
|
//Test where calls to read are smaller than the chunk size
|
||||||
func TestSizeBasedSplit(t *testing.T) {
|
func TestSizeBasedSplit(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
bs := &chunk.SizeSplitter{Size: 512}
|
bs := &chunk.SizeSplitter{Size: 512}
|
||||||
testFileConsistency(t, bs, 32*512)
|
testFileConsistency(t, bs, 32*512)
|
||||||
bs = &chunk.SizeSplitter{Size: 4096}
|
bs = &chunk.SizeSplitter{Size: 4096}
|
||||||
@ -118,10 +124,16 @@ func arrComp(a, b []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMaybeRabinConsistency(t *testing.T) {
|
func TestMaybeRabinConsistency(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
testFileConsistency(t, chunk.NewMaybeRabin(4096), 256*4096)
|
testFileConsistency(t, chunk.NewMaybeRabin(4096), 256*4096)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRabinBlockSize(t *testing.T) {
|
func TestRabinBlockSize(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
nbytes := 1024 * 1024
|
nbytes := 1024 * 1024
|
||||||
io.CopyN(buf, rand.Reader, int64(nbytes))
|
io.CopyN(buf, rand.Reader, int64(nbytes))
|
||||||
|
@ -83,7 +83,9 @@ func TestCancel(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCloseLeak(t *testing.T) {
|
func TestCloseLeak(t *testing.T) {
|
||||||
// t.Skip("Skipping in favor of another test")
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
if os.Getenv("TRAVIS") == "true" {
|
if os.Getenv("TRAVIS") == "true" {
|
||||||
t.Skip("this doesn't work well on travis")
|
t.Skip("this doesn't work well on travis")
|
||||||
|
@ -156,7 +156,9 @@ func setupMultiConns(t *testing.T, ctx context.Context) (a, b *MultiConn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMulticonnSend(t *testing.T) {
|
func TestMulticonnSend(t *testing.T) {
|
||||||
// t.Skip("fooo")
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
log.Info("TestMulticonnSend")
|
log.Info("TestMulticonnSend")
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
@ -220,7 +222,9 @@ func TestMulticonnSend(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMulticonnSendUnderlying(t *testing.T) {
|
func TestMulticonnSendUnderlying(t *testing.T) {
|
||||||
// t.Skip("fooo")
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
log.Info("TestMulticonnSendUnderlying")
|
log.Info("TestMulticonnSendUnderlying")
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
@ -105,7 +105,9 @@ func TestSecureCancel(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSecureCloseLeak(t *testing.T) {
|
func TestSecureCloseLeak(t *testing.T) {
|
||||||
// t.Skip("Skipping in favor of another test")
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
if os.Getenv("TRAVIS") == "true" {
|
if os.Getenv("TRAVIS") == "true" {
|
||||||
t.Skip("this doesn't work well on travis")
|
t.Skip("this doesn't work well on travis")
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,9 @@ func TestSimpleMuxer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSimultMuxer(t *testing.T) {
|
func TestSimultMuxer(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
// run muxer
|
// run muxer
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
|
||||||
|
@ -11,7 +11,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestSimultOpen(t *testing.T) {
|
func TestSimultOpen(t *testing.T) {
|
||||||
// t.Skip("skipping for another test")
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
addrs := []string{
|
addrs := []string{
|
||||||
"/ip4/127.0.0.1/tcp/1244",
|
"/ip4/127.0.0.1/tcp/1244",
|
||||||
@ -61,6 +63,9 @@ func TestSimultOpenMany(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSimultOpenFewStress(t *testing.T) {
|
func TestSimultOpenFewStress(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
// t.Skip("skipping for another test")
|
// t.Skip("skipping for another test")
|
||||||
|
|
||||||
num := 10
|
num := 10
|
||||||
|
@ -167,6 +167,9 @@ func SubtestSwarm(t *testing.T, addrs []string, MsgNum int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSwarm(t *testing.T) {
|
func TestSwarm(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
// t.Skip("skipping for another test")
|
// t.Skip("skipping for another test")
|
||||||
|
|
||||||
addrs := []string{
|
addrs := []string{
|
||||||
|
@ -73,6 +73,9 @@ func newPeerTime(t time.Time) peer.Peer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSyncQueue(t *testing.T) {
|
func TestSyncQueue(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
pq := NewXORDistancePQ(u.Key("11140beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a31"))
|
pq := NewXORDistancePQ(u.Key("11140beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a31"))
|
||||||
|
@ -231,7 +231,9 @@ func TestProvides(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestProvidesAsync(t *testing.T) {
|
func TestProvidesAsync(t *testing.T) {
|
||||||
// t.Skip("skipping test to debug another")
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
u.Debug = false
|
u.Debug = false
|
||||||
@ -295,7 +297,9 @@ func TestProvidesAsync(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLayeredGet(t *testing.T) {
|
func TestLayeredGet(t *testing.T) {
|
||||||
// t.Skip("skipping test to debug another")
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
u.Debug = false
|
u.Debug = false
|
||||||
@ -347,7 +351,9 @@ func TestLayeredGet(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFindPeer(t *testing.T) {
|
func TestFindPeer(t *testing.T) {
|
||||||
// t.Skip("skipping test to debug another")
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
u.Debug = false
|
u.Debug = false
|
||||||
@ -391,7 +397,9 @@ func TestFindPeer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConnectCollision(t *testing.T) {
|
func TestConnectCollision(t *testing.T) {
|
||||||
// t.Skip("skipping test to debug another")
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
runTimes := 10
|
runTimes := 10
|
||||||
|
|
||||||
|
@ -115,7 +115,9 @@ func (f *fauxNet) GetBandwidthTotals() (uint64, uint64) {
|
|||||||
func (f *fauxNet) Close() error { return nil }
|
func (f *fauxNet) Close() error { return nil }
|
||||||
|
|
||||||
func TestGetFailures(t *testing.T) {
|
func TestGetFailures(t *testing.T) {
|
||||||
// t.Skip("skipping test because it makes a lot of output")
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
fn := &fauxNet{}
|
fn := &fauxNet{}
|
||||||
@ -211,7 +213,9 @@ func _randPeer() peer.Peer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNotFound(t *testing.T) {
|
func TestNotFound(t *testing.T) {
|
||||||
// t.Skip("skipping test because it makes a lot of output")
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
fn := &fauxNet{}
|
fn := &fauxNet{}
|
||||||
|
@ -47,7 +47,7 @@ test_expect_success "generate 100MB file using go-random" '
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success "sha1 of the file looks ok" '
|
test_expect_success "sha1 of the file looks ok" '
|
||||||
echo "ae986dd159e4f014aee7409cdc2001ea74f618d1 mountdir/bigfile" >sha1_expected &&
|
echo "885b197b01e0f7ff584458dc236cb9477d2e736d mountdir/bigfile" >sha1_expected &&
|
||||||
shasum mountdir/bigfile >sha1_actual &&
|
shasum mountdir/bigfile >sha1_actual &&
|
||||||
test_cmp sha1_expected sha1_actual
|
test_cmp sha1_expected sha1_actual
|
||||||
'
|
'
|
||||||
@ -57,7 +57,7 @@ test_expect_success "ipfs add bigfile succeeds" '
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success "ipfs add bigfile output looks good" '
|
test_expect_success "ipfs add bigfile output looks good" '
|
||||||
HASH="QmVm3Da371opC3hpsCLuYSozdyM6wRvu9UoUqoyW8u4LRq" &&
|
HASH="QmWXysX1oysyjTqd5xGM2T1maBaVXnk5svQv4GKo5PsGPo" &&
|
||||||
echo "added $HASH $(pwd)/mountdir/bigfile" >expected &&
|
echo "added $HASH $(pwd)/mountdir/bigfile" >expected &&
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
@ -67,7 +67,7 @@ test_expect_success "ipfs cat succeeds" '
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success "ipfs cat output looks good" '
|
test_expect_success "ipfs cat output looks good" '
|
||||||
echo "ae986dd159e4f014aee7409cdc2001ea74f618d1 -" >sha1_expected &&
|
echo "885b197b01e0f7ff584458dc236cb9477d2e736d -" >sha1_expected &&
|
||||||
test_cmp sha1_expected sha1_actual
|
test_cmp sha1_expected sha1_actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -73,9 +73,8 @@ func SetupLogging() {
|
|||||||
// SetAllLoggers changes the logging.Level of all loggers to lvl
|
// SetAllLoggers changes the logging.Level of all loggers to lvl
|
||||||
func SetAllLoggers(lvl logging.Level) {
|
func SetAllLoggers(lvl logging.Level) {
|
||||||
logging.SetLevel(lvl, "")
|
logging.SetLevel(lvl, "")
|
||||||
for n, log := range loggers {
|
for n, _ := range loggers {
|
||||||
logging.SetLevel(lvl, n)
|
logging.SetLevel(lvl, n)
|
||||||
log.Noticef("setting logger: %q to %v", n, lvl)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,9 @@ func TestKey(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestByteChanReader(t *testing.T) {
|
func TestByteChanReader(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.SkipNow()
|
||||||
|
}
|
||||||
|
|
||||||
var data bytes.Buffer
|
var data bytes.Buffer
|
||||||
var data2 bytes.Buffer
|
var data2 bytes.Buffer
|
||||||
|
Reference in New Issue
Block a user