Skip to content

Commit

Permalink
[FAB-5105] unused code in events packages
Browse files Browse the repository at this point in the history
This patch set deletes unused code in events packages.

Change-Id: I330831a56709b4fd0a672f37e7d8c5193b02e4b5
Signed-off-by: Nao Nishijima <nao.nishijima@hal.hitachi.com>
  • Loading branch information
Nao Nishijima committed Jun 29, 2017
1 parent dc7c40b commit 783ba55
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 71 deletions.
10 changes: 0 additions & 10 deletions events/consumer/consumer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,24 @@ import (
type MockAdapter struct {
sync.RWMutex
notify chan struct{}
count int
}

type ZeroAdapter struct {
sync.RWMutex
notify chan struct{}
count int
}

type BadAdapter struct {
sync.RWMutex
notify chan struct{}
count int
}

var peerAddress = "0.0.0.0:7303"
var ehServer *producer.EventsServer
var ies = []*ehpb.Interest{{EventType: ehpb.EventType_CHAINCODE, RegInfo: &ehpb.Interest_ChaincodeRegInfo{ChaincodeRegInfo: &ehpb.ChaincodeReg{ChaincodeId: "0xffffffff", EventName: "event1"}}}}

var adapter *MockAdapter
var obcEHClient *EventsClient

var zeroAdapter *ZeroAdapter
var zeroObcEHClient *EventsClient

var badAdapter *BadAdapter
var badObcEHClient *EventsClient

func (a *ZeroAdapter) GetInterestedEvents() ([]*ehpb.Interest, error) {
return []*ehpb.Interest{}, nil
}
Expand Down
61 changes: 0 additions & 61 deletions events/producer/producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"

"github.com/golang/protobuf/ptypes/timestamp"
"github.com/hyperledger/fabric/common/ledger/testutil"
mmsp "github.com/hyperledger/fabric/common/mocks/msp"
"github.com/hyperledger/fabric/common/util"
Expand All @@ -44,7 +43,6 @@ import (
"github.com/hyperledger/fabric/msp"
"github.com/hyperledger/fabric/msp/mgmt"
"github.com/hyperledger/fabric/msp/mgmt/testtools"
"github.com/hyperledger/fabric/protos/common"
"github.com/hyperledger/fabric/protos/peer"
ehpb "github.com/hyperledger/fabric/protos/peer"
"github.com/hyperledger/fabric/protos/utils"
Expand Down Expand Up @@ -185,65 +183,7 @@ func TestSignedEvent(t *testing.T) {
return
}
}
func createTestBlock(t *testing.T) *common.Block {
chdr := &common.ChannelHeader{
Type: int32(common.HeaderType_ENDORSER_TRANSACTION),
Version: 1,
Timestamp: &timestamp.Timestamp{
Seconds: time.Now().Unix(),
Nanos: 0,
},
ChannelId: "test"}
hdr := &common.Header{ChannelHeader: utils.MarshalOrPanic(chdr)}
payload := &common.Payload{Header: hdr}
cea := &ehpb.ChaincodeEndorsedAction{}
ccaPayload := &ehpb.ChaincodeActionPayload{Action: cea}
env := &common.Envelope{}
taa := &ehpb.TransactionAction{}
taas := make([]*ehpb.TransactionAction, 1)
taas[0] = taa
tx := &ehpb.Transaction{Actions: taas}
ccid := &ehpb.ChaincodeID{Name: "ccid", Version: "v1"}

events := &ehpb.ChaincodeEvent{
ChaincodeId: "ccid",
EventName: "EventName",
Payload: []byte("EventPayload"),
TxId: "TxID"}

pHashBytes := []byte("proposal_hash")
pResponse := &ehpb.Response{Status: 200}
results := []byte("results")
eventBytes, err := utils.GetBytesChaincodeEvent(events)
if err != nil {
t.Fatalf("Failure while marshalling the ProposalResponsePayload")
}
ccaPayload.Action.ProposalResponsePayload, err = utils.GetBytesProposalResponsePayload(pHashBytes, pResponse, results, eventBytes, ccid)
if err != nil {
t.Fatalf("Failure while marshalling the ProposalResponsePayload")
}
tx.Actions[0].Payload, err = utils.GetBytesChaincodeActionPayload(ccaPayload)
if err != nil {
t.Fatalf("Error marshalling tx action payload for block event: %s", err)
}
payload.Data, err = utils.GetBytesTransaction(tx)
if err != nil {
t.Fatalf("Failure while marshalling payload for block event: %s", err)
}
env.Payload, err = utils.GetBytesPayload(payload)
if err != nil {
t.Fatalf("Failure while marshalling tx envelope for block event: %s", err)
}
ebytes, err := utils.GetBytesEnvelope(env)
if err != nil {
t.Fatalf("Failure while marshalling transaction %s", err)
}

block := common.NewBlock(1, []byte{})
block.Data.Data = append(block.Data.Data, ebytes)
block.Header.DataHash = block.Data.Hash()
return block
}
func createTestChaincodeEvent(tid string, typ string) *ehpb.Event {
emsg := CreateChaincodeEvent(&ehpb.ChaincodeEvent{ChaincodeId: tid, EventName: typ})
return emsg
Expand All @@ -254,7 +194,6 @@ func TestReceiveMessage(t *testing.T) {
var err error

adapter.count = 1
//emsg := createTestBlock()
emsg := createTestChaincodeEvent("0xffffffff", "event1")
if err = Send(emsg); err != nil {
t.Fail()
Expand Down

0 comments on commit 783ba55

Please sign in to comment.