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