aboutsummaryrefslogtreecommitdiffstats
path: root/blockpool/test/util.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-02-25 20:34:12 +0800
committerzelig <viktor.tron@gmail.com>2015-02-25 20:34:12 +0800
commit422490d75cf9a2406430f2d7c0d7dd77ede18f7c (patch)
tree63860f0914370bec71cac6f1708476da4f7533cc /blockpool/test/util.go
parentd46c7bcaf9268a191f0156d36abf394df5374795 (diff)
downloaddexon-422490d75cf9a2406430f2d7c0d7dd77ede18f7c.tar.gz
dexon-422490d75cf9a2406430f2d7c0d7dd77ede18f7c.tar.zst
dexon-422490d75cf9a2406430f2d7c0d7dd77ede18f7c.zip
major rewrite, reorg of blockpool + new features
- blockpool moves to its own package - uses errs pkg for its own coded errors - publicly settable config of params (time intervals and batchsizes) - test helpers in subpackage - optional TD in blocks used now to update peers chain info - major improvement in algorithm - fix fragility and sync/parallelisation bugs - implement status for reporting on sync status (peers/hashes/blocks etc) - several tests added and further corner cases covered
Diffstat (limited to 'blockpool/test/util.go')
-rw-r--r--blockpool/test/util.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/blockpool/test/util.go b/blockpool/test/util.go
new file mode 100644
index 000000000..e183bf1d1
--- /dev/null
+++ b/blockpool/test/util.go
@@ -0,0 +1,35 @@
+package test
+
+import (
+ "fmt"
+ "testing"
+ "time"
+)
+
+func CheckInt(name string, got int, expected int, t *testing.T) (err error) {
+ if got != expected {
+ t.Errorf("status for %v incorrect. expected %v, got %v", name, expected, got)
+ err = fmt.Errorf("")
+ }
+ return
+}
+
+func CheckDuration(name string, got time.Duration, expected time.Duration, t *testing.T) (err error) {
+ if got != expected {
+ t.Errorf("status for %v incorrect. expected %v, got %v", name, expected, got)
+ err = fmt.Errorf("")
+ }
+ return
+}
+
+func ArrayEq(a, b []int) bool {
+ if len(a) != len(b) {
+ return false
+ }
+ for i := range a {
+ if a[i] != b[i] {
+ return false
+ }
+ }
+ return true
+}