mirror of
https://github.com/status-im/status-go.git
synced 2025-01-13 08:05:40 +00:00
4939268edf
* select account decrypting wallet and chat keys * adapt account tests to use chat and wallet account/keys * fix tests using chat address * changes after review * fix status service e2e tests * add account.Info struct returned when creating and recovering an account * use s.EqualValues to compare recovered accounts * return Info instead of *Info * add both address and walletAddress to responses * Update lib/types.go Co-Authored-By: gravityblast <andrea@gravityblast.com> * Update lib/types.go Co-Authored-By: gravityblast <andrea@gravityblast.com> * update comment to fix lint
69 lines
1.7 KiB
Go
69 lines
1.7 KiB
Go
package accounts
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/status-im/status-go/params"
|
|
"github.com/status-im/status-go/t/e2e"
|
|
. "github.com/status-im/status-go/t/utils"
|
|
"github.com/stretchr/testify/suite"
|
|
)
|
|
|
|
func TestAccountsRPCTestSuite(t *testing.T) {
|
|
suite.Run(t, new(AccountsRPCTestSuite))
|
|
}
|
|
|
|
type AccountsRPCTestSuite struct {
|
|
e2e.BackendTestSuite
|
|
}
|
|
|
|
func (s *AccountsTestSuite) TestRPCEthAccounts() {
|
|
s.StartTestBackend()
|
|
defer s.StopTestBackend()
|
|
|
|
// log into test account
|
|
err := s.Backend.SelectAccount(TestConfig.Account1.WalletAddress, TestConfig.Account1.ChatAddress, TestConfig.Account1.Password)
|
|
s.NoError(err)
|
|
|
|
rpcClient := s.Backend.StatusNode().RPCClient()
|
|
s.NotNil(rpcClient)
|
|
|
|
expectedResponse := `{"jsonrpc":"2.0","id":1,"result":["` + strings.ToLower(TestConfig.Account1.WalletAddress) + `"]}`
|
|
resp := rpcClient.CallRaw(`{
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"method": "eth_accounts",
|
|
"params": []
|
|
}`)
|
|
|
|
s.Equal(expectedResponse, resp)
|
|
}
|
|
|
|
func (s *AccountsTestSuite) TestRPCEthAccountsWithUpstream() {
|
|
if GetNetworkID() == params.StatusChainNetworkID {
|
|
s.T().Skip()
|
|
}
|
|
|
|
addr, err := GetRemoteURL()
|
|
s.NoError(err)
|
|
s.StartTestBackend(e2e.WithUpstream(addr))
|
|
defer s.StopTestBackend()
|
|
|
|
// log into test account
|
|
err = s.Backend.SelectAccount(TestConfig.Account1.WalletAddress, TestConfig.Account1.ChatAddress, TestConfig.Account1.Password)
|
|
s.NoError(err)
|
|
|
|
rpcClient := s.Backend.StatusNode().RPCClient()
|
|
s.NotNil(rpcClient)
|
|
|
|
expectedResponse := `{"jsonrpc":"2.0","id":1,"result":["` + strings.ToLower(TestConfig.Account1.WalletAddress) + `"]}`
|
|
resp := rpcClient.CallRaw(`{
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"method": "eth_accounts",
|
|
"params": []
|
|
}`)
|
|
s.Equal(expectedResponse, resp)
|
|
}
|