From 9e0e078b99b0b4352b745a776a8e9fa4c644e4e7 Mon Sep 17 00:00:00 2001
From: Silas Davis <silas@monax.io>
Date: Wed, 27 Jun 2018 12:02:51 +0100
Subject: [PATCH] Improve event test

Signed-off-by: Silas Davis <silas@monax.io>
---
 Makefile                                        | 3 +++
 rpc/rpcevents/integration/events_server_test.go | 8 +++++---
 rpc/test/strange_loop.go                        | 2 +-
 rpc/test/strange_loop.sol                       | 2 +-
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 2a40f335..fb80bce1 100644
--- a/Makefile
+++ b/Makefile
@@ -173,6 +173,9 @@ test: check
 test_keys: build_db
 	burrow_bin="${REPO}/bin/burrow" keys/test.sh
 
+rpc/test/strange_loop.go: rpc/test/strange_loop.sol
+	@rpc/test/strange_loop.sh
+
 .PHONY: test_integration
 test_integration: test_keys
 	@go test -tags integration ./rpc/rpcevents/integration
diff --git a/rpc/rpcevents/integration/events_server_test.go b/rpc/rpcevents/integration/events_server_test.go
index 4d2e3152..0e8aebb1 100644
--- a/rpc/rpcevents/integration/events_server_test.go
+++ b/rpc/rpcevents/integration/events_server_test.go
@@ -24,6 +24,8 @@ import (
 
 	"encoding/json"
 
+	"strings"
+
 	"github.com/hyperledger/burrow/binary"
 	"github.com/hyperledger/burrow/crypto"
 	"github.com/hyperledger/burrow/execution/events"
@@ -80,10 +82,10 @@ func TestEventSubscribeLog(t *testing.T) {
 		func(evs []*pbevents.Event) {
 			require.Len(t, evs, test.UpsieDownsieCallCount-2)
 			log := evs[0].GetExecutionEvent().GetEventDataLog()
-			depth := binary.Int64FromWord256(binary.LeftPadWord256(log.Topics[1]))
-			payload := string(log.Data)
+			depth := binary.Int64FromWord256(binary.LeftPadWord256(log.Topics[2]))
+			direction := strings.TrimRight(string(log.Topics[1]), "\x00")
 			assert.Equal(t, int64(18), depth)
-			assert.Contains(t, payload, "Upsie!")
+			assert.Equal(t, "Upsie!", direction)
 		})
 }
 
diff --git a/rpc/test/strange_loop.go b/rpc/test/strange_loop.go
index 10590c4f..230de1cc 100644
--- a/rpc/test/strange_loop.go
+++ b/rpc/test/strange_loop.go
@@ -1,3 +1,3 @@
 package test
 
-const strangeLoopBytecodeHex = "60606040526017600055602260015560116002556001600360006101000a81548160ff021916908315150217905550341561003957600080fd5b61039f806100486000396000f300606060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063ebb384dd14610046575b600080fd5b341561005157600080fd5b61005961006f565b6040518082815260200191505060405180910390f35b60006002549050600360009054906101000a900460ff161561023a576001546002541215610199576002600081548092919060010191905055506002547f6488c53a044f5cc88f6f830b84ae7a701762a11b40a91eb0451a870b0f560a4b6040518080602001828103825260068152602001807f557073696521000000000000000000000000000000000000000000000000000081525060200191505060405180910390a260025490503073ffffffffffffffffffffffffffffffffffffffff1663ebb384dd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b151561017c57600080fd5b5af1151561018957600080fd5b5050506040518051905050610235565b6000600360006101000a81548160ff02191690831515021790555060025490503073ffffffffffffffffffffffffffffffffffffffff1663ebb384dd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b151561021c57600080fd5b5af1151561022957600080fd5b50505060405180519050505b61036f565b600054600254131561034957600260008154809291906001900391905055506002547f6488c53a044f5cc88f6f830b84ae7a701762a11b40a91eb0451a870b0f560a4b6040518080602001828103825260088152602001807f446f776e7369652100000000000000000000000000000000000000000000000081525060200191505060405180910390a260025490503073ffffffffffffffffffffffffffffffffffffffff1663ebb384dd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b151561032c57600080fd5b5af1151561033957600080fd5b505050604051805190505061036e565b6001600360006101000a81548160ff0219169083151502179055506002549050610370565b5b5b905600a165627a7a7230582052e0533ea43cd4d1a18ebcfb80ad6d09e217a7615d9faf935ce110c467f7c0b80029"
+const strangeLoopBytecodeHex = "60606040526017600055602260015560116002556001600360006101000a81548160ff021916908315150217905550341561003957600080fd5b610369806100486000396000f300606060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063ebb384dd14610046575b600080fd5b341561005157600080fd5b61005961006f565b6040518082815260200191505060405180910390f35b60006002549050600360009054906101000a900460ff161561021f57600154600254121561017e576002600081548092919060010191905055506002547f55707369652100000000000000000000000000000000000000000000000000007f3ff0b1eac80ecf8e93d1a2d7982a9230f8ea7693439fd548687b08a5e292b09760405160405180910390a360025490503073ffffffffffffffffffffffffffffffffffffffff1663ebb384dd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b151561016157600080fd5b5af1151561016e57600080fd5b505050604051805190505061021a565b6000600360006101000a81548160ff02191690831515021790555060025490503073ffffffffffffffffffffffffffffffffffffffff1663ebb384dd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b151561020157600080fd5b5af1151561020e57600080fd5b50505060405180519050505b610339565b600054600254131561031357600260008154809291906001900391905055506002547f446f776e736965210000000000000000000000000000000000000000000000007f3ff0b1eac80ecf8e93d1a2d7982a9230f8ea7693439fd548687b08a5e292b09760405160405180910390a360025490503073ffffffffffffffffffffffffffffffffffffffff1663ebb384dd6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15156102f657600080fd5b5af1151561030357600080fd5b5050506040518051905050610338565b6001600360006101000a81548160ff021916908315150217905550600254905061033a565b5b5b905600a165627a7a723058204852911519ec7080301770f04ea7bf39ba1e2d71b4988eb1df310378ac767f350029"
diff --git a/rpc/test/strange_loop.sol b/rpc/test/strange_loop.sol
index 5c2d0bc4..33726d0b 100644
--- a/rpc/test/strange_loop.sol
+++ b/rpc/test/strange_loop.sol
@@ -7,7 +7,7 @@ contract StrangeLoop {
     bool down = true;
     // indexed puts it in topic
     event ChangeLevel(
-        string direction,
+        bytes32 indexed direction,
         int indexed newDepth);
 
     function UpsieDownsie() public returns (int i) {
-- 
GitLab