-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing(dot/core): rewrite dot/core service tests (part 2) #2308
Conversation
s := NewTestService(t, cfg) | ||
s.transactionState = ts | ||
|
||
provides := common.MustHexToBytes("0xd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d00000000") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so you are expecting this Provides
tags to be added via the runtime? I would put a comment about it. It would be nice to have a link to the runtime code that appends these tags, and what these tags are.
dot/core/service_integration_test.go
Outdated
net.EXPECT().GossipMessage(gomock.AssignableToTypeOf(new(network.TransactionMessage))).AnyTimes() | ||
net.EXPECT().IsSynced().Return(true).AnyTimes() | ||
net.EXPECT().ReportPeer( | ||
gomock.AssignableToTypeOf(peerset.ReputationChange{}), | ||
gomock.AssignableToTypeOf(peer.ID("")), | ||
).AnyTimes() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have these more restrictive if it's not a helper test function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bunch of nits, but looks good otherwise 💯
transactionState: mockTxnStateOk, | ||
} | ||
execTest(t, service, testPrevHash, testCurrentHash, nil) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit this is fine, although it might a bit cleaner with mock configuration functions as test case fields (example)
@@ -901,7 +912,7 @@ func TestServiceHasKey(t *testing.T) { | |||
}, | |||
args: args{ | |||
pubKeyStr: aliceKeypair.Public().Hex(), | |||
keystoreType: "jimbo", | |||
keystoreType: "test", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could had left jimbo
😸
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i got scared haha
@@ -21,3 +21,11 @@ type AccountInfo struct { | |||
FreeFrozen *scale.Uint128 | |||
} | |||
} | |||
|
|||
// AccountData represents account data of an account. Currently is used in core tests | |||
type AccountData struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use this type instead of the anonymous struct in the Account struct in the types
package as well?
And then update the comment as well for this struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup good call!
@@ -187,6 +187,11 @@ func (in *Instance) GetCodeHash() common.Hash { | |||
return in.codeHash | |||
} | |||
|
|||
// GetContext returns the context of the instance | |||
func (in *Instance) GetContext() *runtime.Context { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems odd that we need to modify the context only in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I needed it to create valid extristics based on the current/correct runtime context. I think its modified elsewhere in the package, it just is not exported
Changes
Tests
Issues
Primary Reviewer