Commit Graph

76 Commits

Author SHA1 Message Date
Emmanuel Odeke 85be26c675
common: BitArray: feedback from @adrianbrink to simplify tests 2018-01-28 22:02:51 -07:00
Emmanuel Odeke 84afef20f5
common: fix BitArray.Update to avoid nil dereference
Update previously only checked that the receiver was
non-nil but didn't check that the input parameter to update
"o" was non-nil causing a nil dereference in cases such as
fe632ea32a/consensus/reactor.go (L306)

Fixes https://github.com/tendermint/tendermint/issues/1169
2018-01-28 10:39:42 -07:00
Ethan Buchman 2bb538b150 cmn: fix HexBytes.MarshalJSON 2018-01-02 11:05:53 -05:00
Ethan Buchman a991e2fe9c
Merge branch 'develop' into sdk2 2018-01-02 10:29:04 -05:00
Ethan Buchman 92c17f3f25 give test more time 2017-12-29 10:49:49 -05:00
Jae Kwon a171d90611 Fix possibly incorrect usage of conversion 2017-12-29 10:28:00 -05:00
Ethan Buchman 558f8e7769 fix recursion 2017-12-29 10:28:00 -05:00
Ethan Buchman 76433d9040 little things 2017-12-29 10:28:00 -05:00
Jae Kwon 6b5d08f7da RepeatTimer fix 2017-12-29 10:27:54 -05:00
Jae Kwon 93c05aa8c0 Add back on HexBytes 2017-12-27 13:52:32 -08:00
Jae Kwon b25df389db Remove Bytes, just use []byte; Use protobuf for KVPair/KI64Pair 2017-12-26 04:40:35 -08:00
Jae Kwon bf644b0984 Do not shadow assert 2017-12-26 00:36:58 -08:00
Jae Kwon 797bcdd9e0 Remove common/http 2017-12-25 17:46:21 -08:00
Jae Kwon f2a8e95248 Add KI64Pair(s) 2017-12-25 11:40:05 -08:00
Ethan Buchman e2d7f1aa41 cmn: fix race 2017-12-21 14:21:15 -05:00
Ethan Buchman b0b740210c cmn: fix repeate timer test with manual ticker 2017-12-21 11:15:17 -05:00
Ethan Buchman a25ed5ba1b cmn: fix race condition in prng 2017-12-21 10:02:25 -05:00
Anton Kaliaev e17e8e425f
Revert "Refactor throttle timer" 2017-12-19 16:23:20 -06:00
Anton Kaliaev 70e30f74e6
Revert "Refactor repeat timer" 2017-12-19 16:16:16 -06:00
Jae Kwon aab2d70dd3
Sdk2 kvpair (#102)
* Canonical KVPair in common
* Simplify common/Bytes to just hex encode
2017-12-17 13:04:15 -08:00
Emmanuel Odeke 8638961f02
common: Rand* warnings about cryptographic unsafety
Lesson articulated by @jaekwon on why we need 80 bits
of entropy at least before we can think of cryptographic
safety. math/rand's seed is a max of 64 bits so can never
be cryptographically secure.

Also added some benchmarks for RandBytes
2017-12-15 22:41:36 -07:00
Emmanuel Odeke cdc7988823
common: use genius simplification of tests from @ebuchman
Massive test simplication for more reliable tests from @ebuchman
2017-12-15 02:14:08 -07:00
Ethan Buchman b5f465b4ec common: use names prng and mrand 2017-12-15 00:23:25 -05:00
Emmanuel Odeke 29471d75cb
common: no more relying on math/rand.DefaultSource
Fixes https://github.com/tendermint/tmlibs/issues/99
Updates https://github.com/tendermint/tendermint/issues/973

Removed usages of math/rand.DefaultSource in favour of our
own source that's seeded with a completely random source
and is safe for use in concurrent in multiple goroutines.
Also extend some functionality that the stdlib exposes such as
* RandPerm
* RandIntn
* RandInt31
* RandInt63

Also added an integration test whose purpose is to be run as
a consistency check to ensure that our results never repeat
hence that our internal PRNG is uniquely seeded each time.
This integration test can be triggered by setting environment variable:
`TENDERMINT_INTEGRATION_TESTS=true`
for example
```shell
TENDERMINT_INTEGRATION_TESTS=true go test
```
2017-12-14 00:18:30 -07:00
Jae Kwon a0b692c86d Add PushBytes to Heap 2017-12-10 14:23:27 -08:00
Jae Kwon 03dfb724c7 Change heap.Push to mean int priority 2017-12-10 10:18:35 -08:00
Jae Kwon 988e190ef7 Deprecated Panic* 2017-12-09 09:26:03 -08:00
Anton Kaliaev ff2fd63bf7
rename trySend to send 2017-12-08 11:17:07 -06:00
Ethan Frey ec4adf21e0 Cleanup from PR comments 2017-12-08 10:15:26 +01:00
Ethan Frey cc7a87e27c Use Ticker in Repeat again to avoid drift 2017-12-07 11:22:54 +01:00
Ethan Frey 8797197cdf No more blocking on multiple Stop() 2017-12-07 10:38:50 +01:00
Ethan Frey 887d766c86 Refactored RepeatTimer, tests hang 2017-12-07 10:15:38 +01:00
Anton Kaliaev 3779310c72
return back output internal channel (way go does with Timer) 2017-12-06 18:48:39 -06:00
Ethan Frey 8b518fadb2 Don't close throttle channel, explain why 2017-12-06 22:28:18 +01:00
Ethan Frey e430d3f844 One more attempt with a read-only channel 2017-12-06 21:51:23 +01:00
Ethan Frey 1ac4c5dd6d Made throttle output non-blocking 2017-12-06 21:20:30 +01:00
Ethan Frey 0a8721113a First pass of PR updates 2017-12-06 21:08:55 +01:00
Ethan Frey 4ec7883891 Cleanup 2017-12-06 11:21:01 +01:00
Ethan Frey dcb4395604 Refactor throttle timer 2017-12-06 11:17:50 +01:00
Ethan Frey 3d9113c16e Add a bit more padding to tests so they pass on osx with -race 2017-12-06 09:18:04 +01:00
Ethan Frey 26abd65e34 Add tests for repeat timer 2017-12-05 15:01:07 +01:00
Ethan Frey 53cdb6cf82 Demo throttle timer is broken 2017-12-05 14:49:16 +01:00
Anton Kaliaev 33abe87c5b
IntInSlice and StringInSlice functions
Refs https://github.com/tendermint/tendermint/pull/835
2017-11-29 12:18:03 -06:00
Ethan Buchman 4d991acae0 common: comments for Service 2017-11-29 05:16:15 +00:00
Anton Kaliaev c2fcc093b2
remove bool from Service#Reset 2017-11-27 23:42:36 -06:00
Anton Kaliaev e6164d4052
change service#Stop to be similar to Start 2017-11-06 12:47:23 -05:00
Anton Kaliaev 4123d54bf6
change service#Start to return just error (Refs #45)
```
@melekes
yeah, bool is superfluous
@ethanfrey
If I remember correctly when I was writing test code, if I call Start() on a Service that is already running, it returns (false, nil). Only if I try to legitimately start it, but it fails in startup do I get an error.
The distinction is quite important to make it safe for reentrant calls. The other approach would be to have a special error type like ErrAlreadyStarted, then check for that in your code explicitly. Kind of like if I make a db call in gorm, and get an error, I check if it is a RecordNotFound error, or whether there was a real error with the db query.
@melekes
Ah, I see. Thanks. I must say I like ErrAlreadyStarted approach more (not just in Golang)
```
2017-11-06 12:18:04 -05:00
Anton Kaliaev 49d75e223e
use os.Process#Kill (Fixes #73) 2017-11-04 08:14:47 -05:00
Anton Kaliaev b658294a13
use assert.Contains in cmap_test 2017-11-04 00:10:59 -05:00
Wolf 88481fc363 Make iterating over keys possible (#63)
* Make iterating over keys possible

* add test for cmap
- test Keys() and Values() respectively

* one cmap per test-case
2017-11-04 00:06:20 -05:00