package discover import ( "fmt" logpkg "log" "net" "os" "testing" "time" "github.com/ethereum/go-ethereum/logger" ) func init() { logger.AddLogSystem(logger.NewStdLogSystem(os.Stdout, logpkg.LstdFlags, logger.ErrorLevel)) } func TestUDP_ping(t *testing.T) { t.Parallel() n1, _ := ListenUDP(newkey(), "127.0.0.1:0", nil) n2, _ := ListenUDP(newkey(), "127.0.0.1:0", nil) defer n1.Close() defer n2.Close() if err := n1.net.ping(n2.self); err != nil { t.Fatalf("ping error: %v", err) } if find(n2, n1.self.ID) == nil { t.Errorf("node 2 does not contain id of node 1") } if e := find(n1, n2.self.ID); e != nil { t.Errorf("node 1 does contains id of node 2: %v", e) } } func find(tab *Table, id NodeID) *Node { for _, b := range tab.buckets { for _, e := range b.entries { if e.ID == id { return e } } } return nil } func TestUDP_findnode(t *testing.T) { t.Parallel() n1, _ := ListenUDP(newkey(), "127.0.0.1:0", nil) n2, _ := ListenUDP(newkey(), "127.0.0.1:0", nil) defer n1.Close() defer n2.Close() // put a few nodes into n2. the exact distribution shouldn't // matter much, altough we need to take care not to overflow // any bucket. target := randomID(n1.self.ID, 100) nodes := &nodesByDistance{target: target} for i := 0; i < bucketSize; i++ { n2.add([]*Node{&Node{ IP: net.IP{1, 2, 3, byte(i)}, DiscPort: i + 2, TCPPort: i + 2, ID: randomID(n2.self.ID, i+2), }}) } n2.add(nodes.entries) n2.bumpOrAdd(n1.self.ID, &net.UDPAddr{IP: n1.self.IP, Port: n1.self.DiscPort}) expected := n2.closest(target, bucketSize) err := runUDP(10, func() error { result, _ := n1.net.findnode(n2.self, target) if len(result) != bucketSize { return fmt.Errorf("wrong number of results: got %d, want %d", len(result), bucketSize) } for i := range result { if result[i].ID != expected.entries[i].ID { return fmt.Errorf("result mismatch at %d:\n got: %v\n want: %v", i, result[i], expected.entries[i]) } } return nil }) if err != nil { t.Error(err) } } func TestUDP_replytimeout(t *testing.T) { t.Parallel() // reserve a port so we don't talk to an existing service by accident addr, _ := net.ResolveUDPAddr("udp", "127.0.0.1:0") fd, err := net.ListenUDP("udp", addr) if err != nil { t.Fatal(err) } defer fd.Close() n1, _ := ListenUDP(newkey(), "127.0.0.1:0", nil) defer n1.Close() n2 := n1.bumpOrAdd(randomID(n1.self.ID, 10), fd.LocalAddr().(*net.UDPAddr)) if err := n1.net.ping(n2); err != errTimeout { t.Error("expected timeout error, got", err) } if result, err := n1.net.findnode(n2, n1.self.ID); err != errTimeout { t.Error("expected timeout error, got", err) } else if len(result) > 0 { t.Error("expected empty result, got", result) } } func TestUDP_findnodeMultiReply(t *testing.T) { t.Parallel() n1, _ := ListenUDP(newkey(), "127.0.0.1:0", nil) n2, _ := ListenUDP(newkey(), "127.0.0.1:0", nil) udp2 := n2.net.(*udp) defer n1.Close() defer n2.Close() err := runUDP(10, func() error { nodes := make([]*Node, bucketSize) for i := range nodes { nodes[i] = &Node{ IP: net.IP{1, 2, 3, 4}, DiscPort: i + 1, TCPPort: i + 1, ID: randomID(n2.self.ID, i+1), } } // ask N2 for neighbors. it will send an empty reply back. // the request will wait for up to bucketSize replies. resultc := make(chan []*Node) errc := make(chan error) go func() { ns, err := n1.net.findnode(n2.self, n1.self.ID) if err != nil { errc <- err } else { resultc <- ns } }() // send a few more neighbors packets to N1. // it should collect those. for end := 0; end < len(nodes); { off := end if end = end + 5; end > len(nodes) { end = len(nodes) } udp2.send(n1.self, neighborsPacket, neighbors{ Nodes: nodes[off:end], Expiration: uint64(time.Now().Add(10 * time.Second).Unix()), }) } // check that they are all returned. we cannot just check for // equality because they might not be returned in the order they // were sent. var result []*Node select { case result = <-resultc: case err := <-errc: return err } if hasDuplicates(result) { return fmt.Errorf("result slice contains duplicates") } if len(result) != len(nodes) { return fmt.Errorf("wrong number of nodes returned: got %d, want %d", len(result), len(nodes)) } matched := make(map[NodeID]bool) for _, n := range result { for _, expn := range nodes { if n.ID == expn.ID { // && bytes.Equal(n.Addr.IP, expn.Addr.IP) && n.Addr.Port == expn.Addr.Port { matched[n.ID] = true } } } if len(matched) != len(nodes) { return fmt.Errorf("wrong number of matching nodes: got %d, want %d", len(matched), len(nodes)) } return nil }) if err != nil { t.Error(err) } } // runUDP runs a test n times and returns an error if the test failed // in all n runs. This is necessary because UDP is unreliable even for // connections on the local machine, causing test failures. func runUDP(n int, test func() error) error { errcount := 0 errors := "" for i := 0; i < n; i++ { if err := test(); err != nil { errors += fmt.Sprintf("\n#%d: %v", i, err) errcount++ } } if errcount == n { return fmt.Errorf("failed on all %d iterations:%s", n, errors) } return nil } d>-0/+73 * you shouldn't use an integer to set the flag. You should use a string, andNot Zed2000-11-073-19/+33 * Changed for message api changes. Use camel_address_unformat to convert theNot Zed2000-11-072-78/+46 * God, I sure wish people would listen when i'm saying i'm changing and API.Not Zed2000-11-075-156/+165 * Implement a complete() function, now we need one. (filter): Upgraded toNot Zed2000-11-0720-543/+1703 * looks like I missed this the last time.Larry Ewing2000-11-071-0/+8 * Two segfault fixesPeter Williams2000-11-074-3/+13 * Updated Message menu.Jeffrey Stedfast2000-11-071-13/+17 * Fixed a couple of warnings.Ettore Perazzoli2000-11-072-5/+11 * gal/widgets/e-unicode.h: END_GNOME_DECLS, not BEGINJulian Missig2000-11-071-1/+1 * Updated Swedish translation.Christian Rose2000-11-072-257/+298 * Changed this to match the new EPopupMenu structre.Christopher James Lahey2000-11-071-16/+16 * Updated Spanish translationHector Garcia2000-11-072-1330/+1285 * Require gal 0.2.1.3Jeffrey Stedfast2000-11-072-3/+7 * Move filter stuff into a submenu of the popup menu.Jeffrey Stedfast2000-11-072-38/+47 * *gui/e-itip-control.c, gui/e-itip-control.glade: changed to GUI toJesse Pavel2000-11-075-57/+256 * used Camel to parse the full address before passing the email address toJesse Pavel2000-11-072-1/+18 * Add a submenu field to struct EPopupMenu.Jeffrey Stedfast2000-11-072-34/+46 * Remove mail-local-storage.cDan Winship2000-11-072-1/+4 * Remove mail-local-storage.h includeDan Winship2000-11-072-2/+2 * Make the shell pop-up a warning dialog per component when a componentEttore Perazzoli2000-11-074-5/+81 * Fixed the argument comment. Removed an old enum that's not used here.Christopher James Lahey2000-11-073-18/+13 * First draft of folder tree unread message indication for /localDan Winship2000-11-078-378/+491 * Switched from EAddressbookSearch to ESearchBar.Christopher James Lahey2000-11-076-445/+66 * Added e-search-bar.c and e-search-bar.h.Christopher James Lahey2000-11-076-0/+777 * Fix the addressbook crash that happened when the ESelectNames controlEttore Perazzoli2000-11-072-1/+7 * Applied build patch from Mathieu Lacage.Hans Petter2000-11-071-0/+2 * ${prefix} doesn't get defaulted until the end of configure, so check ifDan Winship2000-11-072-3/+14 * Fixed a missing `CORBA_Object_duplicate()' problem. This should fixEttore Perazzoli2000-11-072-1/+6 * Added #include <config.h>Kjartan Maraas2000-11-072-0/+8 * set the content type on the plain part of outgoing messages.Larry Ewing2000-11-071-6/+36 * Fix up #include <config.h> Same here. Here too. Fix indentation of #ifdefKjartan Maraas2000-11-076-5/+15 * Don't invert the flag. (undelete_msg): Same (when multiple messages areJeffrey Stedfast2000-11-072-8/+9 * Added #include <config.h> s/_HAVE_CONFIG_H/HAVE_CONFIG_H for working i18n.Kjartan Maraas2000-11-073-1/+8 * Updated to have the same menu items as the new right-click menu -Jeffrey Stedfast2000-11-075-15/+65 * Updated Message menu.Jeffrey Stedfast2000-11-072-4/+15 * Removed the old recurrence page. Wheeeeeeeeee!Federico Mena Quintero2000-11-076-473/+342 * Handle both the position and weekday in the by_day field.Federico Mena Quintero2000-11-072-2/+12 * added some checks for the type of an incoming iCal component beforeJesse Pavel2000-11-073-6/+38 * also look for HTMLEditor.idl in ${prefix}/share/gtkhtmlRadek Doulik2000-11-062-2/+12 * Updated Swedish translation.Christian Rose2000-11-062-105/+133 * Removed unnecessary .cvsignore files.Christopher James Lahey2000-11-064-9/+5 * Removed unnecessary .cvsignore files.Christopher James Lahey2000-11-063-4/+5 * New files for the new define views dialog.Christopher James Lahey2000-11-063-0/+573 * Added print envelope menus. Added ...s.Christopher James Lahey2000-11-062-5/+14 * Add menus items to the envelope printing stuff.Christopher James Lahey2000-11-0611-10/+432 * Added an "Undelete" option to the right-click menu and also set a mask soJeffrey Stedfast2000-11-064-35/+100 * Updated Galician translationJesus Bravo Alvarez2000-11-062-1413/+3803 * Updated russian translation.Valek Frob2000-11-062-570/+904 * Added stuff for `bonobox'.Martin Baulig2000-11-052-2/+7 * Put this back; I suppose Elliot reverted it by accident sinceMartin Baulig2000-11-051-2/+2 * Updated Swedish translation.Christian Rose2000-11-052-575/+918 * kill all the bonob-ui-extract crud.Michael Meeks2000-11-0513-560/+5 * update all of ui/*.h to ui/*.xmlMichael Meeks2000-11-055-80/+462 * Updated Slovenian translationAndraz Tori2000-11-051-1/+1 * Updated Polish translationChyla Zbigniew2000-11-052-414/+440 * Block signals from the toggle button. (date_changed_cb): MergedFederico Mena Quintero2000-11-054-86/+63 * Translations from KeldKenneth Christiansen2000-11-041-793/+810 * Translations from KeldKenneth Christiansen2000-11-041-1004/+2004 * raise required version number to 0.8 added check for HTMLEditor.idl fileRadek Doulik2000-11-042-2/+19 * fix test for regular file to !S_ISREG (statbuf.st_mode)Radek Doulik2000-11-042-1/+4 * Updated russian translation.Valek Frob2000-11-041-299/+303 * use inline images hash tableRadek Doulik2000-11-0410-85/+126 * new function, generates simple message/content idRadek Doulik2000-11-043-0/+21 * Set the preface/postface from the parser into the multipart object.Not Zed2000-11-0410-33/+249 * Updated Swedish translation.Christian Rose2000-11-042-322/+337 * Undo my incorrect fix - I misunderstood danw - sorry!Jeffrey Stedfast2000-11-042-26/+9 * oops, return NULL not voidJeffrey Stedfast2000-11-041-2/+2 * Don't allow attaching anything but regular files.Jeffrey Stedfast2000-11-042-15/+25 * Updated Norwegian translation.Kjartan Maraas2000-11-042-293/+312 * don't free the MessageList search when it's being reusedDan Winship2000-11-042-1/+6 * Unbreak this.Dan Winship2000-11-042-2/+7 * Added a `--no-splash' option to the shell.Ettore Perazzoli2000-11-044-20/+60 * Updated Slovenian translationAndraz Tori2000-11-041-1070/+1005 * Fix the name of the signal passed to gtk_signal_new so that this actuallyDan Winship2000-11-042-1/+6 * Don't show the passwd in the url string. (mail_tool_local_uri_to_folder):Jeffrey Stedfast2000-11-042-6/+13 * Made it compile again.Chris Lahey2000-11-041-2/+2 * Turned on proper handling of insert and delete.Christopher James Lahey2000-11-041-1/+1 * If show_pass, then base64 the password before writing it to the outputJeffrey Stedfast2000-11-042-6/+41 * fix bug in previousDan Winship2000-11-041-3/+1 * Added new header files.Jeffrey Stedfast2000-11-0415-112/+274 * url_flags are now on CamelProvider, not CamelServiceDan Winship2000-11-045-12/+28 * Add an "url_flags" field to CamelProvider. Move the CAMEL_SERVICE_URL_*Dan Winship2000-11-0419-79/+79 * Clean the idl-generated files properly.Federico Mena Quintero2000-11-044-0/+14 * Clean the idl-generated files properly.Federico Mena Quintero2000-11-042-0/+7 * Removed the "time_changed" signal, since it was never being emitted in theFederico Mena Quintero2000-11-043-59/+81 * Clean the idl-generated sources properly. Likewise.Federico Mena Quintero2000-11-045-33/+37 * Added mail-display.h.Not Zed2000-11-0313-307/+373 * Updated Spanish translationHector Garcia2000-11-032-1236/+2593 * Since we insert at the parent->child position, we need to account forNot Zed2000-11-031-39/+117 * Updated russian translation.Valek Frob2000-11-032-205/+252 * Updated Norwegian translation.Kjartan Maraas2000-11-032-296/+377 * Sync with message menu. Addresses bugzilla bug #778.Jeffrey Stedfast2000-11-032-0/+8 * Fix for when 'desc' is NULL. (filter_driver_filter_message): Use a moreJeffrey Stedfast2000-11-031-2/+2 * Turn on draw grid for the main ETable (this may not be working in ETableChristopher James Lahey2000-11-032-1/+6 * Removed QuickSearch widget.Christopher James Lahey2000-11-032-2/+4 * Removed these unnecessary .cvsignores.Christopher James Lahey2000-11-038-71/+403 * o2000-11-02 Christopher James Lahey <clahey@helixcode.com>Chris Lahey2000-11-032-3/+7 * Updated these unused glade files to better match the versions in the code.Christopher James Lahey2000-11-035-100/+130 * Most of these are already in ../../art. Don't need to duplicate themDan Winship2000-11-037-0/+0 * icons for the mail config druid. we will probably need tigert to spruce these...Anna Dirks2000-11-037-0/+0 * New mail config druid. This file also contains a dialog for editting existing...Anna Dirks2000-11-031-36/+2769 * Fixed a missing ".Christopher James Lahey2000-11-022-1/+5 * fi.po: Updated Finnish translationjjranta2000-11-022-907/+2605 * Require Bonobo-0.27+Michael Meeks2000-11-022-2/+6 * Fix for when 'desc' is NULL. (filter_driver_filter_message): Use a moreJeffrey Stedfast2000-11-022-1/+3 * The big api rename ...Michael Meeks2000-11-0220-48/+417 * Fix for when 'desc' is NULL.Jeffrey Stedfast2000-11-022-4/+12 * Quote foldernames when sending to the IMAP server because the folder nameJeffrey Stedfast2000-11-022-1/+7 * fmt argument should be const.Jeffrey Stedfast2000-11-023-3/+8 * Make "Get Mail" even more functional on IMAP (scans all folders),Dan Winship2000-11-027-108/+190 * Don't call the default logging function. (do_fetch_mail): Set the logfileJeffrey Stedfast2000-11-022-12/+16 * Use filter_driver_log() where appropriate. (do_copy): Use the service urlJeffrey Stedfast2000-11-023-50/+106 * Add "highlighted" flag to evolution_storage_new_folderDan Winship2000-11-022-2/+10 * Make this take "highlighted" as well.Dan Winship2000-11-026-4/+20 * ** Merged in camel-incremental-branch.Not Zed2000-11-0211-218/+956 * Merged in camel-incremental-branch.Not Zed2000-11-0213-107/+532 * Remove old subbed folders from hash table after freeing them.Dan Winship2000-11-022-3/+14 * Fixed validation errors.Aaron Weber2000-11-0216-434/+1220 * Updated Swedish translation.Christian Rose2000-11-022-942/+2786 * add fields search_entry and search_top.Chris Toshok2000-11-023-66/+386 * Moving the executive summarys now :)Iain Holmes2000-11-0222-101/+843 * Moving the executive summarys now :)Iain Holmes2000-11-025-0/+100 * Add "highligted" field to Folder. Add update_folder method toDan Winship2000-11-0218-61/+373 * Hmmm, someone can't spell Filder, er...I mean Filter ;-)Jeffrey Stedfast2000-11-022-2/+7 * Don't create the To, Cc, and Bcc lists based only on the address, use bothJeffrey Stedfast2000-11-022-9/+33 * Fix the CTE kludge, calculate the best mime transfer encoding for the mimeJeffrey Stedfast2000-11-022-15/+65 * Check to make sure the user has entered a valid date.Jeffrey Stedfast2000-11-022-189/+223 * Makefile.am: renamed GNOMELOCALEDIR to EVOLUTION_LOCALEDIRGediminas Paulauskas2000-11-021-1/+1 * Deal correctly with namespace == ""Dan Winship2000-11-022-1/+6 * If the name is NULL or empty, then set the title to "Mail from <address>".Jeffrey Stedfast2000-11-022-114/+132 * added composer keybindings descriptionRadek Doulik2000-11-024-0/+26 * added accel="*Control*Return" to FileSend replace FileSendNow withRadek Doulik2000-11-022-2/+8 * added property bag support for BonoboJesse Pavel2000-11-022-1/+34 * Lots of fixes and simplifications. Should get rid of the "missing icon"Dan Winship2000-11-022-107/+110 * Updated Slovenian translationAndraz Tori2000-11-021-1932/+5128 * Add Keybindings, please populateMiguel de Icaza2000-11-022-0/+8 * Updated russian translation.Valek Frob2000-11-012-124/+204 * *** empty log message ***Gediminas Paulauskas2000-11-011-0/+2 * modified or added a bunch of .cvsignore to ignore generated files, whichGediminas Paulauskas2000-11-0118-4/+57 * Updated Ukrainian translationYuri Syrota2000-11-011-81/+71 * calendar: made all gui show localizedGediminas Paulauskas2000-11-019-1543/+4076 * updated catalan filePablo Saratxaga2000-11-012-909/+783 * Shouldn't we be strdup'ing the content? This seems to fix the memoryJeffrey Stedfast2000-11-013-24/+32 * Hmmm. SHRT_MAX changed to ICAL_RECURRENCE_ARRAY_MAX in libical. Deal withFederico Mena Quintero2000-11-012-6/+21 * Update for camel_service_disconnect change.Dan Winship2000-11-012-1/+6 * Add a new argument, clean, that says whether or not to try to disconnectDan Winship2000-11-018-80/+62 * Updated to allow the user to select "sounds like" or "does not sound like"Jeffrey Stedfast2000-11-014-6/+149 * this is a generated file. remove itDan Winship2000-11-011-369/+0 * Override the default validate function to only return TRUE if a folder hasJeffrey Stedfast2000-11-013-92/+183 * Updated italian translation from Clara Tattoni <clara.tattoni@libero.it>Christopher R. Gabriel2000-11-012-395/+1166 * Updated to add an action to set message flags.Jeffrey Stedfast2000-11-017-8/+111 * Let the warning make sense (compute_pid): removeJP Rosevear2000-11-0113-374/+600 * Updated russian translation.Valek Frob2000-11-012-66/+801 * Match "is" rather than "contains" now that we have the "is"-rule.Jeffrey Stedfast2000-11-012-1/+6 * Do not pad around the Name hbox; its parent already has spacing. Do notFederico Mena Quintero2000-11-012-4/+11 * New function. We split it from the radio callback so that we can call itFederico Mena Quintero2000-11-012-7/+28 * better reply editing, uses new HTMLEditor::Engine,Listener interfacesRadek Doulik2000-11-018-15/+386 * Updated Dutch translation.Almer S. Tigelaar2000-10-312-1854/+4100 * More updatesKjartan Maraas2000-10-312-11/+21 * updated this. Updated this too.Kjartan Maraas2000-10-313-289/+948 * #include <string.h> to quench warning. #include <stdlib.h> for sameKjartan Maraas2000-10-313-0/+7 * #include <string.h> to get rid of warning. Same here.Kjartan Maraas2000-10-313-0/+7 * Updated russian translation.Valek Frob2000-10-311-20/+47 * If a regex option is selected, change the FilterElement data to TRUE elseJeffrey Stedfast2000-10-319-15/+139 * Mark two strings correctlyKjartan Maraas2000-10-311-2/+2 * Pure formatting changes, no actual code changes. Since I know I'm going toJeffrey Stedfast2000-10-316-259/+316 * Fixed marking of strings for translation. Use "_(" instead of "_ (". AddKjartan Maraas2000-10-314-36/+49 * Updated Norwegian (bokmål) translation.Kjartan Maraas2000-10-312-537/+591 * #include <stdlib.h> to remove warning. #include <stdlib.h> and <string.h>.Kjartan Maraas2000-10-313-0/+8 * Updated russian translation.Valek Frob2000-10-312-514/+338 * Updated russian translation.Valek Frob2000-10-311-839/+1889 * Camel IMAP authentication includes (forgotten in last commit)Dan Winship2000-10-311-0/+39 * Removed the geometry and hidden arguments. This code is ancient.Federico Mena Quintero2000-10-314-54/+20 * fix up printing of kerberos configuration statusDan Winship2000-10-312-6/+11 * New file with code for IMAP authentication mechanisms. (Currently justDan Winship2000-10-315-84/+384 * Take an additional argument, "break_lines", saying whether or not to addDan Winship2000-10-314-10/+11 * Redo this so that it works for all pages, not just the first page. (NowDan Winship2000-10-312-15/+20 * more updates from Clara Tattoni <clara.tattoni@libero.it>Christopher R. Gabriel2000-10-312-250/+231 * Do not take in an extra data pointer. (summary_changed_cb): Use a singleFederico Mena Quintero2000-10-312-25/+45 * Removed spurious character that kept it from building.Federico Mena Quintero2000-10-302-1/+4 * Updated Polish translationChyla Zbigniew2000-10-302-121/+134 * Updating some pt_BR translations. (Update-Gnome.sh script)Jorge Godoy2000-10-301-724/+1732 * Did some regexp nicefications of the code. And added the timeout field.Eskil Heyn Olsen2000-10-301-3/+16 * Simplify this a lot by making IMAP and NNTP use the same code, now thatDan Winship2000-10-30