5ebdeb56ca
## Checklist - [x] I have read the [contribution guidelines](https://github.com/ooni/probe-cli/blob/master/CONTRIBUTING.md) - [x] reference issue for this pull request: https://github.com/ooni/probe/issues/2158 - [x] if you changed anything related how experiments work and you need to reflect these changes in the ooni/spec repository, please link to the related ooni/spec pull request: https://github.com/ooni/spec/pull/250 ## Description This diff refactors the codebase to reimplement tlsping and tcpping to use the step-by-step measurements style. See docs/design/dd-003-step-by-step.md for more information on the step-by-step measurement style.
23 lines
362 B
Go
23 lines
362 B
Go
package testingx
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestTimeDeterministic(t *testing.T) {
|
|
td := &TimeDeterministic{}
|
|
t0 := td.Now()
|
|
if !t0.Equal(td.zeroTime) {
|
|
t.Fatal("invalid t0 value")
|
|
}
|
|
t1 := td.Now()
|
|
if t1.Sub(t0) != time.Second {
|
|
t.Fatal("invalid t1 value")
|
|
}
|
|
t2 := td.Now()
|
|
if t2.Sub(t1) != time.Second {
|
|
t.Fatal("invalid t2 value")
|
|
}
|
|
}
|