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
Jail.RemoveCells before logout and switching account #382
Conversation
… call of method RemoveCells at begin of Logout action and begin of SelectAccount action of geth API
@oleg-raev thanks for terrific work. This code is not easy to grasp quickly. For now, marking this as blocked by #376 |
@divan Thank you for your update and quick merging your PR.
Yes, it looks better and easier. I should resolve conflicts and update the pull request, right? |
Umm, not yet, the changes were huge (including file renames). We're about to merge another PR, related to tests. Once it's done, we'll revisit this PR and probably will manually cherry pick some changes (like logout API, and especially tests). |
Thank you very much for the contribution, @oleg-raev! We may either cherry-pick needed commits from your branch manually, or you can groom this branch yourself after #375 is merged if you have time. Which one is preferred for you? Added a zenhub dependency on #371 as per @divan's comment. |
@oleg-raev please, proceed. |
@tiabc conflicts resolved |
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.
Everything's great, just a number of minor fixes or questions. Can you fix or answer them, please?
e2e/api/api_test.go
Outdated
) | ||
|
||
var ( | ||
TestConfig *common.TestConfig |
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.
It's already here:
Line 16 in 281b304
TestConfig *common.TestConfig |
We use it like this:
status-go/e2e/accounts/accounts_test.go
Line 12 in 281b304
. "github.com/status-im/status-go/testing" |
e2e/api/api_test.go
Outdated
@@ -25,8 +35,15 @@ type APITestSuite struct { | |||
} | |||
|
|||
func (s *APITestSuite) SetupTest() { | |||
var err error |
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.
Let's more it closer to where it's actually used. To line 43.
(if it won't be removed due to the first comment, of course)
e2e/api/api_test.go
Outdated
@@ -118,3 +135,85 @@ func (s *APITestSuite) TestRaceConditions() { | |||
time.Sleep(2 * time.Second) // so that we see some logs | |||
s.api.StopNode() // just in case we have a node running | |||
} | |||
|
|||
func (s *APITestSuite) TestJailStop() { |
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.
TestCellsRemovedAfterSwitchAccount
e2e/api/api_test.go
Outdated
|
||
for i := 0; i < itersCount; i++ { | ||
wg.Add(1) | ||
go func(id int) { |
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.
Why doing it in a goroutine?
e2e/api/api_test.go
Outdated
s.api.JailManager().Parse(testChatID, ``) | ||
|
||
_, err = s.api.JailManager().NewCell(testChatID) | ||
require.NoError(err) |
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.
Sorry, what's the meaning of this assertion?
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.
Exactly, you are right. Cell created by previous call s.api.JailManager().Parse(...
e2e/jail/jail_test.go
Outdated
|
||
func (s *JailTestSuite) TestJailStop() { | ||
const loopLen = 5 | ||
var wg sync.WaitGroup |
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.
Again: why goroutines?
e2e/jail/jail_test.go
Outdated
|
||
c := make(chan struct{}) | ||
go func() { | ||
defer close(c) |
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.
Won't it be easier to read without defer
?
e2e/jail/jail_test.go
Outdated
@@ -157,3 +159,49 @@ func (s *JailTestSuite) TestEventSignal() { | |||
expectedResponse := `{"jsonrpc":"2.0","result":true}` | |||
s.Equal(expectedResponse, response) | |||
} | |||
|
|||
func (s *JailTestSuite) TestJailStop() { |
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.
TestJailCellsRemovedAfterStop
geth/api/api.go
Outdated
@@ -146,11 +146,13 @@ func (api *StatusAPI) VerifyAccountPassword(keyStoreDir, address, password strin | |||
// using provided password. Once verification is done, decrypted key is injected into Whisper (as a single identity, | |||
// all previous identities are removed). | |||
func (api *StatusAPI) SelectAccount(address, password string) error { | |||
api.b.jailManager.Stop() |
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.
Hm. Currently JailManager.Stop
doesn't stop Jail, it just resets it to an initial state. Can you make a comment above the original method like // FIXME(oleg-raev): This method doesn't make stop, it rather resets its cells to an initial state and should be properly renamed, for example: ResetCells
?
@@ -19,6 +20,10 @@ var ( | |||
baseStatusJSCode = string(static.MustAsset("testdata/jail/status.js")) | |||
) | |||
|
|||
func TestCellTestSuite(t *testing.T) { | |||
suite.Run(t, new(CellTestSuite)) | |||
} |
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.
+1
@tiabc fixed |
@@ -146,11 +146,15 @@ func (api *StatusAPI) VerifyAccountPassword(keyStoreDir, address, password strin | |||
// using provided password. Once verification is done, decrypted key is injected into Whisper (as a single identity, | |||
// all previous identities are removed). | |||
func (api *StatusAPI) SelectAccount(address, password string) error { | |||
// FIXME(oleg-raev): This method doesn't make stop, it rather resets its cells to an initial state | |||
// and should be properly renamed, for example: ResetCells |
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 meant to the method declaration. But never mind, it's fine.
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.
LGTM!
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.
LGTM
Merging without another review as this PR has been hanging too long. |
@oleg-raev thanks one more time for the successful contribution! We'll have a conversation about you joining core contributors and I'll get back to you with the result. |
Added methods:
Added call of method RemoveCells at begin of Logout action and begin of SelectAccount action of geth API
Added tests:
Issue #260 - setInterval keeps on posting updates after the account has been switched