diff --git a/integration/obscurogateway/obscurogateway_test.go b/integration/obscurogateway/obscurogateway_test.go index 0c3d874c11..a23b23d3ca 100644 --- a/integration/obscurogateway/obscurogateway_test.go +++ b/integration/obscurogateway/obscurogateway_test.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "fmt" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/ethclient" "io" "math/big" "net/http" @@ -61,6 +62,7 @@ func TestObscuroGateway(t *testing.T) { NodeRPCWebsocketAddress: fmt.Sprintf("127.0.0.1:%d", startPort+integration.DefaultHostRPCWSOffset), LogPath: "sys_out", VerboseFlag: false, + DBType: "sqlite", } obscuroGwContainer := container.NewWalletExtensionContainerFromConfig(obscuroGatewayConf, testlog.Logger()) @@ -120,6 +122,7 @@ func TestObscuroGatewaySubscriptionsWithMultipleAccounts(t *testing.T) { NodeRPCWebsocketAddress: fmt.Sprintf("127.0.0.1:%d", startPort+integration.DefaultHostRPCWSOffset), LogPath: "sys_out", VerboseFlag: false, + DBType: "sqlite", } obscuroGwContainer := container.NewWalletExtensionContainerFromConfig(obscuroGatewayConf, testlog.Logger()) @@ -134,10 +137,11 @@ func TestObscuroGatewaySubscriptionsWithMultipleAccounts(t *testing.T) { time.Sleep(5 * time.Second) // make sure the server is ready to receive requests - serverAddress := fmt.Sprintf("http://%s:%d", obscuroGatewayConf.WalletExtensionHost, obscuroGatewayConf.WalletExtensionPortHTTP) + serverAddressHTTP := fmt.Sprintf("http://%s:%d", obscuroGatewayConf.WalletExtensionHost, obscuroGatewayConf.WalletExtensionPortHTTP) + serverAddressWS := fmt.Sprintf("ws://%s:%d", obscuroGatewayConf.WalletExtensionHost, obscuroGatewayConf.WalletExtensionPortHTTP) // make sure the server is ready to receive requests - err := waitServerIsReady(serverAddress) + err := waitServerIsReady(serverAddressHTTP) require.NoError(t, err) // Server is now ready and we can create requests @@ -146,15 +150,15 @@ func TestObscuroGatewaySubscriptionsWithMultipleAccounts(t *testing.T) { // join Obscuro Gateway as three different users (user0, user1, user2) // user0 deploys smart contracts - userID0, err := joinObscuroGateway(serverAddress) + userID0, err := joinObscuroGateway(serverAddressHTTP) require.NoError(t, err) fmt.Println(fmt.Sprintf("user0 joined Obscuro Gateway with userID: %s", userID0)) - userID1, err := joinObscuroGateway(serverAddress) + userID1, err := joinObscuroGateway(serverAddressHTTP) require.NoError(t, err) fmt.Println(fmt.Sprintf("user1 joined Obscuro Gateway with userID: %s", userID1)) - userID2, err := joinObscuroGateway(serverAddress) + userID2, err := joinObscuroGateway(serverAddressHTTP) require.NoError(t, err) fmt.Println(fmt.Sprintf("user2 joined Obscuro Gateway with userID: %s", userID2)) @@ -162,33 +166,45 @@ func TestObscuroGatewaySubscriptionsWithMultipleAccounts(t *testing.T) { // register one address with user0 pk := w.PrivateKey() address := w.Address().Hex() - resp, err := registerAccount(serverAddress, userID0, pk, address) + resp, err := registerAccount(serverAddressHTTP, userID0, pk, address) require.NoError(t, err) fmt.Printf("Successfully registered address %s for user: %s with response: %s \n", address, userID0, resp) + // TODO: w.PrivateKey() always returns the same private key... + // let's try to get balance and know if we have funds in it.. + + httpConnectionURL := serverAddressHTTP + "/v1/" + "?u=" + userID0 + httpClient, err := ethclient.Dial(httpConnectionURL) + fmt.Println(httpClient) + r, err := httpClient.BlockNumber(context.Background()) + fmt.Printf("Block number is: %d\n", r) + //at, err := httpClient.BalanceAt(context.Background(), w.Address(), nil) + //require.NoError(t, err) + //fmt.Println("Balance for account ", w.Address().Hex(), " - ", at.String()) + // register two addresses with user1 pkU1A0 := w.PrivateKey() addressU1A0 := w.Address().Hex() - resp, err = registerAccount(serverAddress, userID1, pkU1A0, addressU1A0) + resp, err = registerAccount(serverAddressHTTP, userID1, pkU1A0, addressU1A0) require.NoError(t, err) fmt.Printf("Successfully registered address %s for user: %s with response: %s \n", addressU1A0, userID1, resp) pkU1A1 := w.PrivateKey() addressU1A1 := w.Address().Hex() - resp, err = registerAccount(serverAddress, userID1, pkU1A1, addressU1A1) + resp, err = registerAccount(serverAddressHTTP, userID1, pkU1A1, addressU1A1) require.NoError(t, err) fmt.Printf("Successfully registered address %s for user: %s with response: %s \n", addressU1A1, userID1, resp) // register two addresses with user2 pkU2A0 := w.PrivateKey() addressU2A0 := w.Address().Hex() - resp, err = registerAccount(serverAddress, userID2, pkU2A0, addressU2A0) + resp, err = registerAccount(serverAddressHTTP, userID2, pkU2A0, addressU2A0) require.NoError(t, err) fmt.Printf("Successfully registered address %s for user: %s with response: %s \n", addressU2A0, userID2, resp) pkU2A1 := w.PrivateKey() addressU2A1 := w.Address().Hex() - resp, err = registerAccount(serverAddress, userID1, pkU2A1, addressU2A1) + resp, err = registerAccount(serverAddressHTTP, userID1, pkU2A1, addressU2A1) require.NoError(t, err) fmt.Printf("Successfully registered address %s for user: %s with response: %s \n", addressU2A1, userID2, resp)