Skip to content

Commit

Permalink
fix fix
Browse files Browse the repository at this point in the history
  • Loading branch information
otherview committed Sep 22, 2023
1 parent f9a78b8 commit f752a93
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 37 deletions.
72 changes: 36 additions & 36 deletions integration/manualtests/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,51 @@ import (
"context"
"encoding/hex"
"fmt"
"io"
"log"
"net/http"
"strings"
"testing"

"github.com/ethereum/go-ethereum"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/obscuronet/go-obscuro/tools/walletextension/common"
"github.com/stretchr/testify/require"
"io"
"log"
"net/http"
"strings"
"testing"
"time"
"github.com/valyala/fasthttp"

gethcommon "github.com/ethereum/go-ethereum/common"
)

func TestSubscribeToOG(t *testing.T) {
//if os.Getenv(_IDEFlag) == "" {
// t.Skipf("set flag %s to run this test in the IDE", _IDEFlag)
//}
t.Skip("skip manual tests")

// Using http
//ogHTTPAddress := "dev-testnet.obscu.ro:443"
ogWSAddress := "dev-testnet.obscu.ro:81"
//ogWSAddress := "51.132.131.47:81"

//// join the network
//statusCode, userID, err := fasthttp.Get(nil, fmt.Sprintf("https://%s/v1/join/", ogHTTPAddress))
//require.NoError(t, err) // dialing to the given TCP address timed out
//fmt.Println(statusCode)
//fmt.Println(userID)
//
//// sign the message
//messagePayload := signMessage(string(userID))
//
//// register an account
//var regAccountResp []byte
//regAccountResp, err = registerAccount(ogHTTPAddress, string(userID), messagePayload)
//require.NoError(t, err)
//fmt.Println(regAccountResp)
ogHTTPAddress := "https://dev-testnet.obscu.ro:443"
ogWSAddress := "wss://dev-testnet.obscu.ro:81"
//ogWSAddress := "ws://51.132.131.47:81"

// join the network
statusCode, userID, err := fasthttp.Get(nil, fmt.Sprintf("%s/v1/join/", ogHTTPAddress))
require.NoError(t, err) // dialing to the given TCP address timed out
fmt.Println(statusCode)
fmt.Println(userID)

// sign the message
messagePayload := signMessage(string(userID))

// register an account
var regAccountResp []byte
regAccountResp, err = registerAccount(ogHTTPAddress, string(userID), messagePayload)
require.NoError(t, err)
fmt.Println(string(regAccountResp))
fmt.Println(hex.EncodeToString(regAccountResp))

// Using WS ->

for i := 0; i < 50; i++ {
ethclient.Dial("ws://" + ogWSAddress)
time.Sleep(100 * time.Millisecond)
}

// Connect to WebSocket server using the standard geth client
client, err := ethclient.Dial("ws://" + ogWSAddress)
client, err := ethclient.Dial(ogWSAddress)
require.NoError(t, err)

// Create a simple request
Expand Down Expand Up @@ -90,7 +86,7 @@ func registerAccount(baseAddress, userID, payload string) ([]byte, error) {
req, err := http.NewRequestWithContext(
context.Background(),
http.MethodPost,
"https://"+baseAddress+"/authenticate/?u="+userID,
baseAddress+"/v1/authenticate/?u="+userID,
strings.NewReader(payload),
)
if err != nil {
Expand Down Expand Up @@ -125,5 +121,9 @@ func signMessage(userID string) string {
if err != nil {
log.Fatalf("Failed to sign message: %v", err)
}
return fmt.Sprintf("{\"signature\": \"%s\", \"message\": \"%s\"}", hex.EncodeToString(sig), message)
sig[64] += 27
signature := "0x" + hex.EncodeToString(sig)
payload := fmt.Sprintf("{\"signature\": \"%s\", \"message\": \"%s\"}", signature, message)
fmt.Println(payload)
return payload
}
1 change: 0 additions & 1 deletion integration/obscurogateway/obscurogateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const (
)

func TestObscuroGateway(t *testing.T) {
t.Skip("Commented it out until more testing is driven from this test")
t.Skip("Commented it out until more testing is driven from this test")
startPort := integration.StartPortObscuroGatewayUnitTest
wallets := createObscuroNetwork(t, startPort)
Expand Down

0 comments on commit f752a93

Please sign in to comment.