diff --git a/execution/events/pbevents/blocks.go b/execution/events/pbevents/blocks.go index 5856e64b90a7e12c849da2f060400179aa70ea95..5513ec34c6310f815f7ad7ab57128431c79fd7e5 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 0000000000000000000000000000000000000000..62641f876048dbe8ec9f24d30cb452433347153c --- /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) +}