From 935de8d471681c504892e86dd059bba288927e6d Mon Sep 17 00:00:00 2001
From: Silas Davis <silas@monax.io>
Date: Tue, 26 Jun 2018 22:38:50 +0100
Subject: [PATCH] Don't panic on nil Bounds

Signed-off-by: Silas Davis <silas@monax.io>
---
 execution/events/pbevents/blocks.go      |  3 +++
 execution/events/pbevents/blocks_test.go | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)
 create mode 100644 execution/events/pbevents/blocks_test.go

diff --git a/execution/events/pbevents/blocks.go b/execution/events/pbevents/blocks.go
index 5856e64b..5513ec34 100644
--- a/execution/events/pbevents/blocks.go
+++ b/execution/events/pbevents/blocks.go
@@ -12,6 +12,9 @@ func (b *Bound) Key(latestBlockHeight uint64) events.Key {
 }
 
 func (b *Bound) Bound(latestBlockHeight uint64) uint64 {
+	if b == nil {
+		return latestBlockHeight
+	}
 	switch b.Type {
 	case Bound_ABSOLUTE:
 		return b.GetIndex()
diff --git a/execution/events/pbevents/blocks_test.go b/execution/events/pbevents/blocks_test.go
new file mode 100644
index 00000000..62641f87
--- /dev/null
+++ b/execution/events/pbevents/blocks_test.go
@@ -0,0 +1,17 @@
+package pbevents
+
+import (
+	"testing"
+
+	"github.com/hyperledger/burrow/execution/events"
+	"github.com/stretchr/testify/assert"
+)
+
+func TestBlockRange_Bounds(t *testing.T) {
+	latestHeight := uint64(2344)
+	br := &BlockRange{}
+	start, end, streaming := br.Bounds(latestHeight)
+	assert.Equal(t, events.NewKey(latestHeight, 0), start)
+	assert.Equal(t, events.NewKey(latestHeight, 0), end)
+	assert.False(t, streaming)
+}
-- 
GitLab