From 967de3260fa58f6cddb8580274f7715269c01146 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 21 Apr 2023 12:28:21 +0200 Subject: [PATCH] api/channel.go: Change Action struct name to ActionChannel --- api/channel.go | 4 ++-- api/channel_test.go | 10 +++++----- api/redis/key_test.go | 2 +- app/ship_processor.go | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/api/channel.go b/api/channel.go index 9167120..ceed10e 100644 --- a/api/channel.go +++ b/api/channel.go @@ -41,12 +41,12 @@ var ( ) // Action Channel -type Action struct { +type ActionChannel struct { Name string Contract string } -func (a Action) Channel() Channel { +func (a ActionChannel) Channel() Channel { ch := Channel{"actions"} if len(a.Contract) > 0 { diff --git a/api/channel_test.go b/api/channel_test.go index 5d8038c..b80dd5e 100644 --- a/api/channel_test.go +++ b/api/channel_test.go @@ -93,13 +93,13 @@ func TestChannel_String(t *testing.T) { func TestAction_Channel(t *testing.T) { tests := []struct { name string - action Action + action ActionChannel want Channel }{ - {"Empty", Action{}, Channel{"actions"}}, - {"Contract", Action{Contract: "mycontract"}, Channel{"actions", "contract", "mycontract"}}, - {"Action", Action{Name: "myaction"}, Channel{"actions", "name", "myaction"}}, - {"ContractAndName", Action{Contract: "mycontract", Name: "myaction"}, Channel{"actions", "contract", "mycontract", "name", "myaction"}}, + {"Empty", ActionChannel{}, Channel{"actions"}}, + {"Contract", ActionChannel{Contract: "mycontract"}, Channel{"actions", "contract", "mycontract"}}, + {"Action", ActionChannel{Name: "myaction"}, Channel{"actions", "name", "myaction"}}, + {"ContractAndName", ActionChannel{Contract: "mycontract", Name: "myaction"}, Channel{"actions", "contract", "mycontract", "name", "myaction"}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/api/redis/key_test.go b/api/redis/key_test.go index b5b31de..63a7bea 100644 --- a/api/redis/key_test.go +++ b/api/redis/key_test.go @@ -19,7 +19,7 @@ func TestKey_String(t *testing.T) { {"Empty", fields{NS: Namespace{}, Channel: api.Channel{}}, "ship::0000000000000000000000000000000000000000000000000000000000000000::"}, {"Transactions", fields{NS: Namespace{ChainID: "id"}, Channel: api.Channel{"transactions"}}, "ship::id::transactions"}, {"Nested", fields{NS: Namespace{ChainID: "id"}, Channel: api.Channel{"one.two"}}, "ship::id::one.two"}, - {"Action", fields{NS: Namespace{ChainID: "id"}, Channel: api.Action{Contract: "mycontract"}.Channel()}, "ship::id::actions/contract/mycontract"}, + {"Action", fields{NS: Namespace{ChainID: "id"}, Channel: api.ActionChannel{Contract: "mycontract"}.Channel()}, "ship::id::actions/contract/mycontract"}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/app/ship_processor.go b/app/ship_processor.go index dce7921..2229594 100644 --- a/app/ship_processor.go +++ b/app/ship_processor.go @@ -140,10 +140,10 @@ func (processor *ShipProcessor) processTraces(traces []*ship.TransactionTraceV0) } channels := []api.Channel{ - api.Action{}.Channel(), - api.Action{Name: act.Name}.Channel(), - api.Action{Contract: act.Contract}.Channel(), - api.Action{Name: act.Name, Contract: act.Contract}.Channel(), + api.ActionChannel{}.Channel(), + api.ActionChannel{Name: act.Name}.Channel(), + api.ActionChannel{Contract: act.Contract}.Channel(), + api.ActionChannel{Name: act.Name, Contract: act.Contract}.Channel(), } for _, channel := range channels {