diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-11-24 20:48:47 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-11-24 20:48:47 +0800 |
commit | 5490437942967638bcc6198035315f6811febaa8 (patch) | |
tree | ec4fbee454bacbf2b80b5a7ff402fb48dd2c10cf /event | |
parent | e5532154a50114d5ffb1ffd850b746cab00cb899 (diff) | |
parent | b0fb48c389460193d9fc0a5118d79ff6dec48ce0 (diff) | |
download | go-tangerine-5490437942967638bcc6198035315f6811febaa8.tar go-tangerine-5490437942967638bcc6198035315f6811febaa8.tar.gz go-tangerine-5490437942967638bcc6198035315f6811febaa8.tar.bz2 go-tangerine-5490437942967638bcc6198035315f6811febaa8.tar.lz go-tangerine-5490437942967638bcc6198035315f6811febaa8.tar.xz go-tangerine-5490437942967638bcc6198035315f6811febaa8.tar.zst go-tangerine-5490437942967638bcc6198035315f6811febaa8.zip |
Merge branch 'develop' into release/1.3.2v1.3.2
Conflicts:
VERSION
cmd/geth/main.go
Diffstat (limited to 'event')
-rw-r--r-- | event/filter/filter_test.go | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/event/filter/filter_test.go b/event/filter/filter_test.go index 0cd26bfc9..dcc911245 100644 --- a/event/filter/filter_test.go +++ b/event/filter/filter_test.go @@ -21,35 +21,40 @@ import ( "time" ) +// Simple test to check if baseline matching/mismatching filtering works. func TestFilters(t *testing.T) { - var success bool - var failure bool - fm := New() fm.Start() + + // Register two filters to catch posted data + first := make(chan struct{}) fm.Install(Generic{ Str1: "hello", Fn: func(data interface{}) { - success = data.(bool) + first <- struct{}{} }, }) + second := make(chan struct{}) fm.Install(Generic{ Str1: "hello1", Str2: "hello", Fn: func(data interface{}) { - failure = true + second <- struct{}{} }, }) + // Post an event that should only match the first filter fm.Notify(Generic{Str1: "hello"}, true) fm.Stop() - time.Sleep(10 * time.Millisecond) // yield to the notifier - - if !success { - t.Error("expected 'hello' to be posted") + // Ensure only the mathcing filters fire + select { + case <-first: + case <-time.After(100 * time.Millisecond): + t.Error("matching filter timed out") } - - if failure { - t.Error("hello1 was triggered") + select { + case <-second: + t.Error("mismatching filter fired") + case <-time.After(100 * time.Millisecond): } } |