1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-07-02 11:43:40 +02:00

api/channel.go: Change Action struct name to ActionChannel

This commit is contained in:
Henrik Hautakoski 2023-04-21 12:28:21 +02:00
parent 220f1976f0
commit 967de3260f
4 changed files with 12 additions and 12 deletions

View file

@ -41,12 +41,12 @@ var (
) )
// Action Channel // Action Channel
type Action struct { type ActionChannel struct {
Name string Name string
Contract string Contract string
} }
func (a Action) Channel() Channel { func (a ActionChannel) Channel() Channel {
ch := Channel{"actions"} ch := Channel{"actions"}
if len(a.Contract) > 0 { if len(a.Contract) > 0 {

View file

@ -93,13 +93,13 @@ func TestChannel_String(t *testing.T) {
func TestAction_Channel(t *testing.T) { func TestAction_Channel(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
action Action action ActionChannel
want Channel want Channel
}{ }{
{"Empty", Action{}, Channel{"actions"}}, {"Empty", ActionChannel{}, Channel{"actions"}},
{"Contract", Action{Contract: "mycontract"}, Channel{"actions", "contract", "mycontract"}}, {"Contract", ActionChannel{Contract: "mycontract"}, Channel{"actions", "contract", "mycontract"}},
{"Action", Action{Name: "myaction"}, Channel{"actions", "name", "myaction"}}, {"Action", ActionChannel{Name: "myaction"}, Channel{"actions", "name", "myaction"}},
{"ContractAndName", Action{Contract: "mycontract", Name: "myaction"}, Channel{"actions", "contract", "mycontract", "name", "myaction"}}, {"ContractAndName", ActionChannel{Contract: "mycontract", Name: "myaction"}, Channel{"actions", "contract", "mycontract", "name", "myaction"}},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {

View file

@ -19,7 +19,7 @@ func TestKey_String(t *testing.T) {
{"Empty", fields{NS: Namespace{}, Channel: api.Channel{}}, "ship::0000000000000000000000000000000000000000000000000000000000000000::"}, {"Empty", fields{NS: Namespace{}, Channel: api.Channel{}}, "ship::0000000000000000000000000000000000000000000000000000000000000000::"},
{"Transactions", fields{NS: Namespace{ChainID: "id"}, Channel: api.Channel{"transactions"}}, "ship::id::transactions"}, {"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"}, {"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 { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {

View file

@ -140,10 +140,10 @@ func (processor *ShipProcessor) processTraces(traces []*ship.TransactionTraceV0)
} }
channels := []api.Channel{ channels := []api.Channel{
api.Action{}.Channel(), api.ActionChannel{}.Channel(),
api.Action{Name: act.Name}.Channel(), api.ActionChannel{Name: act.Name}.Channel(),
api.Action{Contract: act.Contract}.Channel(), api.ActionChannel{Contract: act.Contract}.Channel(),
api.Action{Name: act.Name, Contract: act.Contract}.Channel(), api.ActionChannel{Name: act.Name, Contract: act.Contract}.Channel(),
} }
for _, channel := range channels { for _, channel := range channels {