From f752a93d803604fa399af1e0e66e013ce96ba8b4 Mon Sep 17 00:00:00 2001 From: otherview Date: Fri, 22 Sep 2023 18:10:56 +0100 Subject: [PATCH] fix fix --- integration/manualtests/connection_test.go | 72 +++++++++---------- .../obscurogateway/obscurogateway_test.go | 1 - 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/integration/manualtests/connection_test.go b/integration/manualtests/connection_test.go index 00bf8d46ec..987d144b48 100644 --- a/integration/manualtests/connection_test.go +++ b/integration/manualtests/connection_test.go @@ -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 @@ -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 { @@ -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 } diff --git a/integration/obscurogateway/obscurogateway_test.go b/integration/obscurogateway/obscurogateway_test.go index d724717025..02d1967878 100644 --- a/integration/obscurogateway/obscurogateway_test.go +++ b/integration/obscurogateway/obscurogateway_test.go @@ -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)