github.com/annchain/OG@v0.0.9/poc/tendermint/waiter_test.go (about) 1 package tendermint 2 3 import ( 4 "fmt" 5 "testing" 6 "time" 7 ) 8 9 func callback(w WaiterContext) { 10 fmt.Println(w.(*TendermintContext).HeightRound.Height) 11 } 12 13 func TestWait(t *testing.T) { 14 c := make(chan *WaiterRequest) 15 w := NewWaiter(c) 16 go w.StartEventLoop() 17 w.UpdateRequest(&WaiterRequest{ 18 WaitTime: time.Second * 5, 19 TimeoutCallback: callback, 20 Context: &TendermintContext{ 21 HeightRound: HeightRound{ 22 Height: 2, 23 Round: 3, 24 }, 25 }, 26 }) 27 w.UpdateContext(&TendermintContext{ 28 HeightRound: HeightRound{ 29 Height: 2, 30 Round: 3, 31 }, 32 }) 33 34 time.Sleep(time.Second * 100) 35 }