fix_: clean up tests with ResetMobileSignalHandler (#5793)
This commit is contained in:
parent
970119af78
commit
c9b777a218
|
@ -842,7 +842,7 @@ func TestLoginAccount(t *testing.T) {
|
|||
c <- struct{}{}
|
||||
}
|
||||
})
|
||||
defer signal.SetMobileSignalHandler(nil)
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
waitForLogin := func(chan interface{}) {
|
||||
select {
|
||||
case <-c:
|
||||
|
@ -1403,6 +1403,7 @@ func TestCreateWallet(t *testing.T) {
|
|||
c <- struct{}{}
|
||||
}
|
||||
})
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
account, err := b.CreateAccountAndLogin(createAccountRequest)
|
||||
require.NoError(t, err)
|
||||
|
@ -1463,6 +1464,7 @@ func TestSetFleet(t *testing.T) {
|
|||
c <- struct{}{}
|
||||
}
|
||||
})
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
newAccount, err := b.CreateAccountAndLogin(createAccountRequest)
|
||||
require.NoError(t, err)
|
||||
|
@ -1531,6 +1533,7 @@ func TestWalletConfigOnLoginAccount(t *testing.T) {
|
|||
c <- struct{}{}
|
||||
}
|
||||
})
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
newAccount, err := b.CreateAccountAndLogin(createAccountRequest)
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -135,6 +135,7 @@ func TestPersonalSignWithSignalAccepted(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
}
|
||||
}))
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
response, err := cmd.Execute(request)
|
||||
assert.NoError(t, err)
|
||||
|
@ -177,6 +178,7 @@ func TestPersonalSignWithSignalRejected(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
}
|
||||
}))
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
_, err = cmd.Execute(request)
|
||||
assert.Equal(t, ErrPersonalSignRejectedByUser, err)
|
||||
|
|
|
@ -88,6 +88,7 @@ func TestRequestAccountsAcceptedAndRequestAgain(t *testing.T) {
|
|||
dAppPermissionGranted = true
|
||||
}
|
||||
}))
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
expectedResponse := FormatAccountAddressToResponse(accountAddress)
|
||||
response, err := cmd.Execute(request)
|
||||
|
@ -142,6 +143,7 @@ func TestRequestAccountsRejected(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
}
|
||||
}))
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
_, err = cmd.Execute(request)
|
||||
assert.Equal(t, ErrRequestAccountsRejectedByUser, err)
|
||||
|
|
|
@ -56,6 +56,7 @@ func TestRevokePermissionsSucceeded(t *testing.T) {
|
|||
dAppPermissionRevoked = true
|
||||
}
|
||||
}))
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
err := PersistDAppData(db, testDAppData, sharedAccount, 0x123)
|
||||
assert.NoError(t, err)
|
||||
|
|
|
@ -129,6 +129,7 @@ func TestSendTransactionWithSignalAccepted(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
}
|
||||
}))
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
response, err := cmd.Execute(request)
|
||||
assert.NoError(t, err)
|
||||
|
@ -169,6 +170,7 @@ func TestSendTransactionWithSignalRejected(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
}
|
||||
}))
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
_, err = cmd.Execute(request)
|
||||
assert.Equal(t, ErrSendTransactionRejectedByUser, err)
|
||||
|
|
|
@ -102,6 +102,7 @@ func TestSwitchEthereumChainSuccess(t *testing.T) {
|
|||
chainIdSwitched = true
|
||||
}
|
||||
}))
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
cmd := &SwitchEthereumChainCommand{
|
||||
Db: db,
|
||||
|
|
|
@ -86,6 +86,7 @@ func TestRequestAccountsSwitchChainAndSendTransactionFlow(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
}
|
||||
}))
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
// Request accounts, now for real
|
||||
request := "{\"method\": \"eth_requestAccounts\", \"params\": [], \"url\": \"http://testDAppURL123\", \"name\": \"testDAppName\", \"iconUrl\": \"http://testDAppIconUrl\" }"
|
||||
|
@ -221,6 +222,7 @@ func TestRequestAccountsAfterPermisasionsRevokeTest(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
}
|
||||
}))
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
for range [10]int{} {
|
||||
dAppPermissionRevoked = false
|
||||
|
|
|
@ -91,6 +91,7 @@ func TestTransactionNotification(t *testing.T) {
|
|||
})
|
||||
|
||||
signal.SetMobileSignalHandler(signalHandler)
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
feed := &event.Feed{}
|
||||
require.NoError(t, s.SubscribeWallet(feed))
|
||||
|
|
|
@ -144,10 +144,10 @@ func setupSignalHandler(t *testing.T) (chan SuggestedRoutesV2Response, func()) {
|
|||
}
|
||||
})
|
||||
signal.SetMobileSignalHandler(signalHandler)
|
||||
t.Cleanup(signal.ResetMobileSignalHandler)
|
||||
|
||||
closeFn := func() {
|
||||
close(suggestedRoutesCh)
|
||||
signal.SetMobileSignalHandler(nil)
|
||||
}
|
||||
|
||||
return suggestedRoutesCh, closeFn
|
||||
|
|
|
@ -111,6 +111,10 @@ func SetMobileSignalHandler(handler MobileSignalHandler) {
|
|||
mobileSignalHandler = handler
|
||||
}
|
||||
|
||||
func ResetMobileSignalHandler() {
|
||||
mobileSignalHandler = nil
|
||||
}
|
||||
|
||||
// SetSignalEventCallback set callback
|
||||
// this function uses C implementation (see `signals.c` file)
|
||||
func SetSignalEventCallback(cb unsafe.Pointer) {
|
||||
|
|
Loading…
Reference in New Issue