diff options
author | Janoš Guljaš <janos@users.noreply.github.com> | 2019-02-26 17:02:05 +0800 |
---|---|---|
committer | Viktor Trón <viktor.tron@gmail.com> | 2019-02-26 17:02:05 +0800 |
commit | c83ba9e7941a0a97e20922e04ef403e52d885017 (patch) | |
tree | 1a5bf28232f3939953dbe34effee292f6edf546b /swarm/storage | |
parent | 340a53a98bd760fab229ea9daa70adddf7460a78 (diff) | |
download | go-tangerine-c83ba9e7941a0a97e20922e04ef403e52d885017.tar go-tangerine-c83ba9e7941a0a97e20922e04ef403e52d885017.tar.gz go-tangerine-c83ba9e7941a0a97e20922e04ef403e52d885017.tar.bz2 go-tangerine-c83ba9e7941a0a97e20922e04ef403e52d885017.tar.lz go-tangerine-c83ba9e7941a0a97e20922e04ef403e52d885017.tar.xz go-tangerine-c83ba9e7941a0a97e20922e04ef403e52d885017.tar.zst go-tangerine-c83ba9e7941a0a97e20922e04ef403e52d885017.zip |
swarm/storage/localstore: fix tests for windows os (#19161)
Diffstat (limited to 'swarm/storage')
-rw-r--r-- | swarm/storage/localstore/localstore_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/swarm/storage/localstore/localstore_test.go b/swarm/storage/localstore/localstore_test.go index 6b48d54e9..6954b139a 100644 --- a/swarm/storage/localstore/localstore_test.go +++ b/swarm/storage/localstore/localstore_test.go @@ -22,6 +22,7 @@ import ( "io/ioutil" "math/rand" "os" + "runtime" "sort" "strconv" "sync" @@ -34,6 +35,26 @@ import ( "github.com/syndtr/goleveldb/leveldb" ) +func init() { + // Some of the tests in localstore package rely on the same ordering of + // items uploaded or accessed compared to the ordering of items in indexes + // that contain StoreTimestamp or AccessTimestamp in keys. In tests + // where the same order is required from the database as the order + // in which chunks are put or accessed, if the StoreTimestamp or + // AccessTimestamp are the same for two or more sequential items + // their order in database will be based on the chunk address value, + // in which case the ordering of items/chunks stored in a test slice + // will not be the same. To ensure the same ordering in database on such + // indexes on windows systems, an additional short sleep is added to + // the now function. + if runtime.GOOS == "windows" { + setNow(func() int64 { + time.Sleep(time.Microsecond) + return time.Now().UTC().UnixNano() + }) + } +} + // TestDB validates if the chunk can be uploaded and // correctly retrieved. func TestDB(t *testing.T) { |