func TestAuth(t *testing.T) { // Do it a few times... for i := 0; i < 3; i++ { c1, c2 := nchan.NewConnPipe(5) ec := make(chan error, 1) go func() { _, err := AtClient(c1, "", "foo") ec <- err }() if _, err := AtServer(c2, "", "foo"); err != nil { t.Fatal(err) } if err := <-ec; err != nil { t.Fatal(err) } c1.Out <- []byte("hi") c2.Out <- []byte("there") d := <-c2.In if string(d) != "hi" { t.Fatal("bad msg") } d = <-c1.In if string(d) != "there" { t.Fatal("bad msg") } } }
func testfs(t fstest.Fataler) (*lfs.Lfs, *Rfs) { fs, err := lfs.New(tdir, tdir, lfs.RW) if err != nil { t.Fatalf("new: %s", err) } c1, c2 := nchan.NewConnPipe(0) srv := Serve("srv", c1, nil, RW, fs) srv.Debug = testing.Verbose() && moreverb rfs, err := New(nchan.NewMux(c2, true), "") if err != nil { t.Fatalf("%s", err) } rfs.Tag = "cli" rfs.Dbg = testing.Verbose() VerbDebug = moreverb return fs, rfs }
func TestBadAuth(t *testing.T) { c1, c2 := nchan.NewConnPipe(5) go func() { var nb [8]byte binary.LittleEndian.PutUint64(nb[0:], 33) c1.Out <- nb[:] c1.Out <- nb[:] }() _, err := AtClient(c2, "", "foo") if err == nil { t.Fatal(err) } printf("err is %v\n", err) if cerror(c2.In) == nil || cerror(c2.Out) == nil { t.Fatal("chans are ok") } }