Skip to content

refactor: replaces events type const - #621

Merged
Ropes merged 2 commits into
masterfrom
ropes/607-replace-event-const
May 29, 2020
Merged

refactor: replaces events type const#621
Ropes merged 2 commits into
masterfrom
ropes/607-replace-event-const

Conversation

@Ropes

@Ropes Ropes commented May 28, 2020

Copy link
Copy Markdown
Contributor
  • Previously used the sdk.EventTypeMessage == "message" string to
    identify all of our messages. This provided little value.
  • Updated all ephemeral messages to be prefixed with
    "sdkutil.EventTypeMessage" == "akash.v1".
  • Added tests to assert successful event parsing, though they just check
    there are no parsing errors right now.

fixes #607

@Ropes
Ropes requested review from boz and troian May 28, 2020 20:31
@codecov

codecov Bot commented May 28, 2020

Copy link
Copy Markdown

Codecov Report

Merging #621 into master will increase coverage by 0.69%.
The diff coverage is 81.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #621      +/-   ##
==========================================
+ Coverage   21.40%   22.09%   +0.69%     
==========================================
  Files         127      127              
  Lines        6353     6353              
==========================================
+ Hits         1360     1404      +44     
+ Misses       4917     4872      -45     
- Partials       76       77       +1     
Impacted Files Coverage Δ
sdkutil/event.go 60.00% <ø> (+60.00%) ⬆️
x/deployment/types/event.go 72.46% <75.00%> (+42.02%) ⬆️
x/market/types/event.go 40.66% <85.71%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3128149...e27036d. Read the comment docs.

@Ropes
Ropes force-pushed the ropes/607-replace-event-const branch from 08fba9c to 1e677a5 Compare May 28, 2020 20:36
Comment thread x/deployment/types/events_test.go Outdated

@boz boz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for adding testing. I added some comments below - it's not clear to me why the tests are passing :-/

In addition to what you have, it'd be nice to test that encode/decode are inverse of one another if possible:

parse(event.ToSDKEvent()) == event

Comment thread sdkutil/event.go Outdated
Comment thread x/deployment/types/events_test.go Outdated
Type: sdkutil.EventTypeMessage,
Module: ModuleName,
},
expErr: nil,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this, I believe these things should cause an error:

  • Action is unpopulated
  • Action is neither evActionDeploymentCreate nor evActionDeploymentUpdate
  • DeploymentID attributes are not set.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I don't know how I missed that, and clearly the err assertion isn't working.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think LAMBDA BOWL is causing one of those annoying closure-in-a-loop bugs.

Comment thread x/deployment/types/events_test.go Outdated
@Ropes
Ropes force-pushed the ropes/607-replace-event-const branch 4 times, most recently from 1af6a80 to ddfe149 Compare May 28, 2020 23:59
)

var (
keyAcc, _ = sdk.AccAddressFromBech32("akash1qtqpdszzakz7ugkey7ka2cmss95z26ygar2mgr")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea. maybe can have a thing in testutil w/ like 100 hard-coded addresses.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I just pulled that out of local setup.


func (tep testEventParsing) testMessageType() func(t *testing.T) {
_, err := ParseEvent(tep.msg)
return func(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing that you're returning a closure so that t.Run() executes in parallel... but t.Parallel() is not called and ParseEvent() wouldn't be run in it anyways.

I think just putting all of this in the TestEventParsing function instead of as a method would make this a lot easier to understand.

Or if you really want to use a method, put the closure in TestEventParsing instead of here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern is purely due to the linter being tyranical about what state can be referenced in the main t.Run(...) function. Nothing to do with t.Parallel().

Linter is harsh...

* Previously used the sdk.EventTypeMessage == "message" string to
identify all of our messages. This provided little value.
* Updated all ephemeral messages to be prefixed with
"sdkutil.EventTypeMessage" == "akash.v1".
* Added tests to assert successful event parsing.

fixes #607

Signed-off-by: Josh Roppo <josh@akash.network>
@Ropes
Ropes force-pushed the ropes/607-replace-event-const branch from ddfe149 to ee8ba2d Compare May 29, 2020 00:31

@boz boz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@Ropes
Ropes merged commit f0a7096 into master May 29, 2020
@Ropes
Ropes deleted the ropes/607-replace-event-const branch May 29, 2020 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

events: replace event type

4 participants