From 0c4e3533ac6156f9587f973bb002e0c77523475d Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Fri, 10 Nov 2023 14:44:06 -0800 Subject: [PATCH 1/6] [WIP] Updating relay.feature to run curl command --- docs/static/openapi.yml | 30 +++++++++++++++-------------- e2e/tests/init_test.go | 4 ++-- e2e/tests/node.go | 42 +++++++++++++++++++++++++++++++++++++---- e2e/tests/relay.feature | 2 +- 4 files changed, 57 insertions(+), 21 deletions(-) diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index d82f777d7..f55a851f2 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -46480,7 +46480,7 @@ paths: service: title: >- The Service for which the application is - configured + configured for type: object properties: id: @@ -46660,7 +46660,9 @@ paths: type: object properties: service: - title: The Service for which the application is configured + title: >- + The Service for which the application is configured + for type: object properties: id: @@ -47176,7 +47178,7 @@ paths: service: title: >- The Service for which the application is - configured + configured for type: object properties: id: @@ -47243,7 +47245,7 @@ paths: service: title: >- The Service for which the supplier is - configured + configured for type: object properties: id: @@ -76787,7 +76789,7 @@ definitions: type: object properties: service: - title: The Service for which the application is configured + title: The Service for which the application is configured for type: object properties: id: @@ -76871,7 +76873,7 @@ definitions: type: object properties: service: - title: The Service for which the application is configured + title: The Service for which the application is configured for type: object properties: id: @@ -76965,7 +76967,7 @@ definitions: type: object properties: service: - title: The Service for which the application is configured + title: The Service for which the application is configured for type: object properties: id: @@ -77016,7 +77018,7 @@ definitions: type: object properties: service: - title: The Service for which the application is configured + title: The Service for which the application is configured for type: object properties: id: @@ -77284,7 +77286,7 @@ definitions: type: object properties: service: - title: The Service for which the application is configured + title: The Service for which the application is configured for type: object properties: id: @@ -77348,7 +77350,7 @@ definitions: type: object properties: service: - title: The Service for which the supplier is configured + title: The Service for which the supplier is configured for type: object properties: id: @@ -77538,7 +77540,7 @@ definitions: type: object properties: service: - title: The Service for which the application is configured + title: The Service for which the application is configured for type: object properties: id: @@ -77600,7 +77602,7 @@ definitions: type: object properties: service: - title: The Service for which the supplier is configured + title: The Service for which the supplier is configured for type: object properties: id: @@ -77814,7 +77816,7 @@ definitions: type: object properties: service: - title: The Service for which the supplier is configured + title: The Service for which the supplier is configured for type: object properties: id: @@ -77943,7 +77945,7 @@ definitions: type: object properties: service: - title: The Service for which the supplier is configured + title: The Service for which the supplier is configured for type: object properties: id: diff --git a/e2e/tests/init_test.go b/e2e/tests/init_test.go index 6bd5aeb27..d6015f0e3 100644 --- a/e2e/tests/init_test.go +++ b/e2e/tests/init_test.go @@ -242,8 +242,8 @@ func (s *suite) TheSessionForApplicationAndServiceContainsTheSupplier(appName st s.Fatalf("session for app %s and service %s does not contain supplier %s", appName, serviceId, supplierName) } -func (s *suite) TheApplicationSendsTheSupplierARelayRequestForService(appName string, supplierName string, requestName string, serviceId string) { - // TODO(#126, @Olshansk): Implement this step +func (s *suite) TheApplicationSendsTheSupplierARequestForServiceWithData(appName, supplierName, serviceId, requestData string) { + s.pocketd.RunCurl(requestData) } func (s *suite) TheApplicationReceivesASuccessfulRelayResponseSignedBy(appName string, supplierName string) { diff --git a/e2e/tests/node.go b/e2e/tests/node.go index e8ed04dc1..ad2ba8b43 100644 --- a/e2e/tests/node.go +++ b/e2e/tests/node.go @@ -44,6 +44,7 @@ type commandResult struct { type PocketClient interface { RunCommand(...string) (*commandResult, error) RunCommandOnHost(string, ...string) (*commandResult, error) + RunCurl(string, ...string) (*commandResult, error) } // Ensure that pocketdBin struct fulfills PocketClient @@ -56,7 +57,7 @@ type pocketdBin struct { // RunCommand runs a command on the local machine using the pocketd binary func (p *pocketdBin) RunCommand(args ...string) (*commandResult, error) { - return p.runCmd(args...) + return p.runPocketCmd(args...) } // RunCommandOnHost runs a command on specified host with the given args @@ -65,11 +66,16 @@ func (p *pocketdBin) RunCommandOnHost(rpcUrl string, args ...string) (*commandRe rpcUrl = defaultRPCURL } args = append(args, "--node", rpcUrl) - return p.runCmd(args...) + return p.runPocketCmd(args...) } -// runCmd is a helper to run a command using the local pocketd binary with the flags provided -func (p *pocketdBin) runCmd(args ...string) (*commandResult, error) { +// RunCurl runs a curl command on the local machine +func (p *pocketdBin) RunCurl(data string, args ...string) (*commandResult, error) { + return p.runCurlPostCmd(data, args...) +} + +// runPocketCmd is a helper to run a command using the local pocketd binary with the flags provided +func (p *pocketdBin) runPocketCmd(args ...string) (*commandResult, error) { base := []string{"--home", defaultHome} args = append(base, args...) commandStr := "poktrolld " + strings.Join(args, " ") // Create a string representation of the command @@ -95,3 +101,31 @@ func (p *pocketdBin) runCmd(args ...string) (*commandResult, error) { return r, err } + +// runCurlPostCmd is a helper to run a command using the local pocketd binary with the flags provided +func (p *pocketdBin) runCurlPostCmd(data string, args ...string) (*commandResult, error) { + base := []string{"-X", "POST", "-H", "Content-Type: application/json", "--data", data} + args = append(base, args...) + commandStr := "curl " + strings.Join(args, " ") // Create a string representation of the command + cmd := exec.Command("curl", args...) + + var stdoutBuf, stderrBuf bytes.Buffer + cmd.Stdout = &stdoutBuf + cmd.Stderr = &stderrBuf + + err := cmd.Run() + r := &commandResult{ + Command: commandStr, // Set the command string + Stdout: stdoutBuf.String(), + Stderr: stderrBuf.String(), + Err: err, + } + p.result = r + + if err != nil { + // Include the command executed in the error message for context + err = fmt.Errorf("error running command [%s]: %v, stderr: %s", commandStr, err, stderrBuf.String()) + } + + return r, err +} diff --git a/e2e/tests/relay.feature b/e2e/tests/relay.feature index 4f071bfa6..629f3c5ec 100644 --- a/e2e/tests/relay.feature +++ b/e2e/tests/relay.feature @@ -5,7 +5,7 @@ Feature: Relay Namespace And the application "app1" is staked for service "anvil" And the supplier "supplier1" is staked for service "anvil" And the session for application "app1" and service "anvil" contains the supplier "supplier1" - When the application "app1" sends the supplier "supplier1" a "getBlock" relay request for service "anvil" + When the application "app1" sends the supplier "supplier1" a request for service "anvil" with data "{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":1}" Then the application "app1" receives a successful relay response signed by "supplier1" # TODO_TEST(@Olshansk): From 4f9a74f27dc671ac99a1efcf02992e8a90f323c2 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Fri, 10 Nov 2023 14:57:35 -0800 Subject: [PATCH 2/6] Continued implementation but still failing --- Makefile | 2 ++ e2e/tests/init_test.go | 6 +++++- e2e/tests/node.go | 19 ++++++++++++------- e2e/tests/relay.feature | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 1f06b4f68..54d126869 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ POKTROLLD_HOME := ./localnet/poktrolld POCKET_NODE = tcp://127.0.0.1:36657 # The pocket rollup node (full node and sequencer in the localnet context) +RELAYER_NODE = http://anvil:8547 # TODO_IN_THIS_COMMIT: UPDATE THIS URL POCKET_ADDR_PREFIX = pokt #################### @@ -137,6 +138,7 @@ go_imports: check_go_version ## Run goimports on all go files test_e2e: ## Run all E2E tests export POCKET_NODE=$(POCKET_NODE) && \ POKTROLLD_HOME=../../$(POKTROLLD_HOME) && \ + RELAYER_NODE=$(RELAYER_NODE) && \ go test -v ./e2e/tests/... -tags=e2e .PHONY: go_test diff --git a/e2e/tests/init_test.go b/e2e/tests/init_test.go index d6015f0e3..b1bf8128f 100644 --- a/e2e/tests/init_test.go +++ b/e2e/tests/init_test.go @@ -243,7 +243,11 @@ func (s *suite) TheSessionForApplicationAndServiceContainsTheSupplier(appName st } func (s *suite) TheApplicationSendsTheSupplierARequestForServiceWithData(appName, supplierName, serviceId, requestData string) { - s.pocketd.RunCurl(requestData) + res, err := s.pocketd.RunCurl("", requestData) + if err != nil { + s.Fatalf("error sending relay request from app %s to supplier %s for service %s: %v", appName, supplierName, serviceId, err) + } + fmt.Println("OLSH", res) } func (s *suite) TheApplicationReceivesASuccessfulRelayResponseSignedBy(appName string, supplierName string) { diff --git a/e2e/tests/node.go b/e2e/tests/node.go index ad2ba8b43..72d1045d9 100644 --- a/e2e/tests/node.go +++ b/e2e/tests/node.go @@ -21,6 +21,8 @@ var ( defaultRPCHost = "127.0.0.1" // defaultHome is the default home directory for pocketd defaultHome = os.Getenv("POKTROLLD_HOME") + // defaultRelayerURL used by curl commands to send relay requests + defaultRelayerURL = os.Getenv("RELAYER_NODE") ) func init() { @@ -42,9 +44,9 @@ type commandResult struct { // PocketClient is a single function interface for interacting with a node type PocketClient interface { - RunCommand(...string) (*commandResult, error) - RunCommandOnHost(string, ...string) (*commandResult, error) - RunCurl(string, ...string) (*commandResult, error) + RunCommand(args ...string) (*commandResult, error) + RunCommandOnHost(rpcUrl string, args ...string) (*commandResult, error) + RunCurl(rpcUrl string, data string, args ...string) (*commandResult, error) } // Ensure that pocketdBin struct fulfills PocketClient @@ -70,8 +72,11 @@ func (p *pocketdBin) RunCommandOnHost(rpcUrl string, args ...string) (*commandRe } // RunCurl runs a curl command on the local machine -func (p *pocketdBin) RunCurl(data string, args ...string) (*commandResult, error) { - return p.runCurlPostCmd(data, args...) +func (p *pocketdBin) RunCurl(rpcUrl string, data string, args ...string) (*commandResult, error) { + if rpcUrl == "" { + rpcUrl = defaultRelayerURL + } + return p.runCurlPostCmd(rpcUrl, data, args...) } // runPocketCmd is a helper to run a command using the local pocketd binary with the flags provided @@ -103,8 +108,8 @@ func (p *pocketdBin) runPocketCmd(args ...string) (*commandResult, error) { } // runCurlPostCmd is a helper to run a command using the local pocketd binary with the flags provided -func (p *pocketdBin) runCurlPostCmd(data string, args ...string) (*commandResult, error) { - base := []string{"-X", "POST", "-H", "Content-Type: application/json", "--data", data} +func (p *pocketdBin) runCurlPostCmd(rpcUrl string, data string, args ...string) (*commandResult, error) { + base := []string{"-X", "POST", "-H", "Content-Type: application/json", "--data", data, rpcUrl} args = append(base, args...) commandStr := "curl " + strings.Join(args, " ") // Create a string representation of the command cmd := exec.Command("curl", args...) diff --git a/e2e/tests/relay.feature b/e2e/tests/relay.feature index 629f3c5ec..484172092 100644 --- a/e2e/tests/relay.feature +++ b/e2e/tests/relay.feature @@ -5,7 +5,7 @@ Feature: Relay Namespace And the application "app1" is staked for service "anvil" And the supplier "supplier1" is staked for service "anvil" And the session for application "app1" and service "anvil" contains the supplier "supplier1" - When the application "app1" sends the supplier "supplier1" a request for service "anvil" with data "{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":1}" + When the application "app1" sends the supplier "supplier1" a request for service "anvil" with data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' Then the application "app1" receives a successful relay response signed by "supplier1" # TODO_TEST(@Olshansk): From cc05bac6729cb10606da416ae2bf45035c3b0c1c Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Fri, 10 Nov 2023 15:31:59 -0800 Subject: [PATCH 3/6] Getting an invalid request right now but figuring it out... --- Makefile | 2 +- e2e/tests/init_test.go | 2 +- e2e/tests/node.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 54d126869..6aa690a51 100644 --- a/Makefile +++ b/Makefile @@ -137,8 +137,8 @@ go_imports: check_go_version ## Run goimports on all go files .PHONY: test_e2e test_e2e: ## Run all E2E tests export POCKET_NODE=$(POCKET_NODE) && \ + export RELAYER_NODE=$(RELAYER_NODE) && \ POKTROLLD_HOME=../../$(POKTROLLD_HOME) && \ - RELAYER_NODE=$(RELAYER_NODE) && \ go test -v ./e2e/tests/... -tags=e2e .PHONY: go_test diff --git a/e2e/tests/init_test.go b/e2e/tests/init_test.go index b1bf8128f..2c7d398f3 100644 --- a/e2e/tests/init_test.go +++ b/e2e/tests/init_test.go @@ -247,7 +247,7 @@ func (s *suite) TheApplicationSendsTheSupplierARequestForServiceWithData(appName if err != nil { s.Fatalf("error sending relay request from app %s to supplier %s for service %s: %v", appName, supplierName, serviceId, err) } - fmt.Println("OLSH", res) + fmt.Println("OLSH Res", res) } func (s *suite) TheApplicationReceivesASuccessfulRelayResponseSignedBy(appName string, supplierName string) { diff --git a/e2e/tests/node.go b/e2e/tests/node.go index 72d1045d9..d610ef54c 100644 --- a/e2e/tests/node.go +++ b/e2e/tests/node.go @@ -109,7 +109,7 @@ func (p *pocketdBin) runPocketCmd(args ...string) (*commandResult, error) { // runCurlPostCmd is a helper to run a command using the local pocketd binary with the flags provided func (p *pocketdBin) runCurlPostCmd(rpcUrl string, data string, args ...string) (*commandResult, error) { - base := []string{"-X", "POST", "-H", "Content-Type: application/json", "--data", data, rpcUrl} + base := []string{"-v", "-X", "POST", "-H", "'Content-Type: application/json'", "--data", fmt.Sprintf("'%s'", data), rpcUrl} args = append(base, args...) commandStr := "curl " + strings.Join(args, " ") // Create a string representation of the command cmd := exec.Command("curl", args...) From 34e52f7d7a203429b525a64be0a9ffaa59fc3182 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Fri, 10 Nov 2023 16:19:45 -0800 Subject: [PATCH 4/6] Added service and switched to AppGate --- Makefile | 4 ++-- e2e/tests/init_test.go | 2 +- e2e/tests/node.go | 16 ++++++++-------- pkg/appgateserver/cmd/cmd.go | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 6aa690a51..104950507 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ POKTROLLD_HOME := ./localnet/poktrolld POCKET_NODE = tcp://127.0.0.1:36657 # The pocket rollup node (full node and sequencer in the localnet context) -RELAYER_NODE = http://anvil:8547 # TODO_IN_THIS_COMMIT: UPDATE THIS URL +APPGATE_SERVER = http://localhost:42069 POCKET_ADDR_PREFIX = pokt #################### @@ -137,7 +137,7 @@ go_imports: check_go_version ## Run goimports on all go files .PHONY: test_e2e test_e2e: ## Run all E2E tests export POCKET_NODE=$(POCKET_NODE) && \ - export RELAYER_NODE=$(RELAYER_NODE) && \ + export APPGATE_SERVER=$(APPGATE_SERVER) && \ POKTROLLD_HOME=../../$(POKTROLLD_HOME) && \ go test -v ./e2e/tests/... -tags=e2e diff --git a/e2e/tests/init_test.go b/e2e/tests/init_test.go index 2c7d398f3..6124f4d5a 100644 --- a/e2e/tests/init_test.go +++ b/e2e/tests/init_test.go @@ -243,7 +243,7 @@ func (s *suite) TheSessionForApplicationAndServiceContainsTheSupplier(appName st } func (s *suite) TheApplicationSendsTheSupplierARequestForServiceWithData(appName, supplierName, serviceId, requestData string) { - res, err := s.pocketd.RunCurl("", requestData) + res, err := s.pocketd.RunCurl("", serviceId, requestData) if err != nil { s.Fatalf("error sending relay request from app %s to supplier %s for service %s: %v", appName, supplierName, serviceId, err) } diff --git a/e2e/tests/node.go b/e2e/tests/node.go index d610ef54c..2aee2eba7 100644 --- a/e2e/tests/node.go +++ b/e2e/tests/node.go @@ -21,8 +21,8 @@ var ( defaultRPCHost = "127.0.0.1" // defaultHome is the default home directory for pocketd defaultHome = os.Getenv("POKTROLLD_HOME") - // defaultRelayerURL used by curl commands to send relay requests - defaultRelayerURL = os.Getenv("RELAYER_NODE") + // defaultAppGateServerURL used by curl commands to send relay requests + defaultAppGateServerURL = os.Getenv("APPGATE_SERVER") ) func init() { @@ -46,7 +46,7 @@ type commandResult struct { type PocketClient interface { RunCommand(args ...string) (*commandResult, error) RunCommandOnHost(rpcUrl string, args ...string) (*commandResult, error) - RunCurl(rpcUrl string, data string, args ...string) (*commandResult, error) + RunCurl(rpcUrl, service, data string, args ...string) (*commandResult, error) } // Ensure that pocketdBin struct fulfills PocketClient @@ -72,11 +72,11 @@ func (p *pocketdBin) RunCommandOnHost(rpcUrl string, args ...string) (*commandRe } // RunCurl runs a curl command on the local machine -func (p *pocketdBin) RunCurl(rpcUrl string, data string, args ...string) (*commandResult, error) { +func (p *pocketdBin) RunCurl(rpcUrl, service, data string, args ...string) (*commandResult, error) { if rpcUrl == "" { - rpcUrl = defaultRelayerURL + rpcUrl = defaultAppGateServerURL } - return p.runCurlPostCmd(rpcUrl, data, args...) + return p.runCurlPostCmd(rpcUrl, service, data, args...) } // runPocketCmd is a helper to run a command using the local pocketd binary with the flags provided @@ -108,8 +108,8 @@ func (p *pocketdBin) runPocketCmd(args ...string) (*commandResult, error) { } // runCurlPostCmd is a helper to run a command using the local pocketd binary with the flags provided -func (p *pocketdBin) runCurlPostCmd(rpcUrl string, data string, args ...string) (*commandResult, error) { - base := []string{"-v", "-X", "POST", "-H", "'Content-Type: application/json'", "--data", fmt.Sprintf("'%s'", data), rpcUrl} +func (p *pocketdBin) runCurlPostCmd(rpcUrl string, service string, data string, args ...string) (*commandResult, error) { + base := []string{"-v", "-X", "POST", "-H", "'Content-Type: application/json'", "--data", fmt.Sprintf("'%s'", data), fmt.Sprintf("%s/%s", rpcUrl, service)} args = append(base, args...) commandStr := "curl " + strings.Join(args, " ") // Create a string representation of the command cmd := exec.Command("curl", args...) diff --git a/pkg/appgateserver/cmd/cmd.go b/pkg/appgateserver/cmd/cmd.go index 21052e270..663562e98 100644 --- a/pkg/appgateserver/cmd/cmd.go +++ b/pkg/appgateserver/cmd/cmd.go @@ -142,6 +142,6 @@ func setupAppGateServerDependencies(cmd *cobra.Command, ctx context.Context, com return nil, fmt.Errorf("failed to create block client: %w", err) } - // Return the dependencie config. + // Return the dependencies config. return depinject.Supply(clientCtx, blockClient), nil } From ee397d3361d2b1f49d048a8417e32d6d449631fe Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Fri, 10 Nov 2023 17:02:23 -0800 Subject: [PATCH 5/6] Debugging checkpoint --- config.yml | 2 +- e2e/tests/init_test.go | 2 +- e2e/tests/relay.feature | 6 ++++++ pkg/appgateserver/jsonrpc.go | 11 ++++++++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/config.yml b/config.yml index f21fe2be6..f6e3c1e89 100644 --- a/config.yml +++ b/config.yml @@ -100,7 +100,7 @@ genesis: - endpoints: - configs: [] rpc_type: JSON_RPC - url: http://anvil:8547 + url: http://localhost:8545 service: id: anvil name: "" diff --git a/e2e/tests/init_test.go b/e2e/tests/init_test.go index 6124f4d5a..4532596d9 100644 --- a/e2e/tests/init_test.go +++ b/e2e/tests/init_test.go @@ -247,7 +247,7 @@ func (s *suite) TheApplicationSendsTheSupplierARequestForServiceWithData(appName if err != nil { s.Fatalf("error sending relay request from app %s to supplier %s for service %s: %v", appName, supplierName, serviceId, err) } - fmt.Println("OLSH Res", res) + fmt.Println("OLSH Res", res.Stdout) } func (s *suite) TheApplicationReceivesASuccessfulRelayResponseSignedBy(appName string, supplierName string) { diff --git a/e2e/tests/relay.feature b/e2e/tests/relay.feature index 484172092..f5b6af236 100644 --- a/e2e/tests/relay.feature +++ b/e2e/tests/relay.feature @@ -2,6 +2,12 @@ Feature: Relay Namespace Scenario: App can send relay to Supplier Given the user has the pocketd binary installed + + # TEMP: DELETE + When the user sends "1000" uPOKT from account "app2" to account "app1" + When the user sends "1000" uPOKT from account "app2" to account "supplier1" + # TEMP: DELETE + And the application "app1" is staked for service "anvil" And the supplier "supplier1" is staked for service "anvil" And the session for application "app1" and service "anvil" contains the supplier "supplier1" diff --git a/pkg/appgateserver/jsonrpc.go b/pkg/appgateserver/jsonrpc.go index 3be01cca7..0e3f9fe16 100644 --- a/pkg/appgateserver/jsonrpc.go +++ b/pkg/appgateserver/jsonrpc.go @@ -3,6 +3,7 @@ package appgateserver import ( "bytes" "context" + "fmt" "io" "log" "net/http" @@ -78,6 +79,7 @@ func (app *appGateServer) handleJSONRPCRelay( return err } relayRequestReader := io.NopCloser(bytes.NewReader(relayRequestBz)) + // relayRequestReader := io.NopCloser(bytes.NewReader(payloadBz)) // Create the HTTP request to send the request to the relayer. relayHTTPRequest := &http.Request{ @@ -87,8 +89,15 @@ func (app *appGateServer) handleJSONRPCRelay( Body: relayRequestReader, } + // TODO: relayminer is currently named relayers + // application (localhost) + // -> appgate (localhost:42069); configured by the gateway/application **off-chain** + // -> relayminer (supplierURL); advertised **on-chain** + // -> anvil (localhost:8547); configured **behind-the-scenes**; chains.json (v0); currently hard-coded + // Perform the HTTP request to the relayer. - log.Printf("DEBUG: Sending signed relay request to %s", supplierUrl) + log.Printf("DEBUG: Sending raw payload to signed relay request to %s", supplierUrl) + fmt.Printf("\n~~~~ OLSH %+v \n~~~~\n", relayHTTPRequest) relayHTTPResponse, err := http.DefaultClient.Do(relayHTTPRequest) if err != nil { return err From 700fd06c9f18b0571c5646e9e117dbaa7d4bf524 Mon Sep 17 00:00:00 2001 From: Daniel Olshansky Date: Tue, 14 Nov 2023 12:33:08 -0800 Subject: [PATCH 6/6] Self review --- e2e/tests/init_test.go | 3 ++- e2e/tests/relay.feature | 6 ------ pkg/appgateserver/jsonrpc.go | 12 +----------- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/e2e/tests/init_test.go b/e2e/tests/init_test.go index 4532596d9..454238264 100644 --- a/e2e/tests/init_test.go +++ b/e2e/tests/init_test.go @@ -247,7 +247,8 @@ func (s *suite) TheApplicationSendsTheSupplierARequestForServiceWithData(appName if err != nil { s.Fatalf("error sending relay request from app %s to supplier %s for service %s: %v", appName, supplierName, serviceId, err) } - fmt.Println("OLSH Res", res.Stdout) + // TODO(#184): store & use the result of res + fmt.Println(res) } func (s *suite) TheApplicationReceivesASuccessfulRelayResponseSignedBy(appName string, supplierName string) { diff --git a/e2e/tests/relay.feature b/e2e/tests/relay.feature index f5b6af236..484172092 100644 --- a/e2e/tests/relay.feature +++ b/e2e/tests/relay.feature @@ -2,12 +2,6 @@ Feature: Relay Namespace Scenario: App can send relay to Supplier Given the user has the pocketd binary installed - - # TEMP: DELETE - When the user sends "1000" uPOKT from account "app2" to account "app1" - When the user sends "1000" uPOKT from account "app2" to account "supplier1" - # TEMP: DELETE - And the application "app1" is staked for service "anvil" And the supplier "supplier1" is staked for service "anvil" And the session for application "app1" and service "anvil" contains the supplier "supplier1" diff --git a/pkg/appgateserver/jsonrpc.go b/pkg/appgateserver/jsonrpc.go index 0e3f9fe16..80784fb44 100644 --- a/pkg/appgateserver/jsonrpc.go +++ b/pkg/appgateserver/jsonrpc.go @@ -3,7 +3,6 @@ package appgateserver import ( "bytes" "context" - "fmt" "io" "log" "net/http" @@ -79,7 +78,6 @@ func (app *appGateServer) handleJSONRPCRelay( return err } relayRequestReader := io.NopCloser(bytes.NewReader(relayRequestBz)) - // relayRequestReader := io.NopCloser(bytes.NewReader(payloadBz)) // Create the HTTP request to send the request to the relayer. relayHTTPRequest := &http.Request{ @@ -89,15 +87,7 @@ func (app *appGateServer) handleJSONRPCRelay( Body: relayRequestReader, } - // TODO: relayminer is currently named relayers - // application (localhost) - // -> appgate (localhost:42069); configured by the gateway/application **off-chain** - // -> relayminer (supplierURL); advertised **on-chain** - // -> anvil (localhost:8547); configured **behind-the-scenes**; chains.json (v0); currently hard-coded - - // Perform the HTTP request to the relayer. - log.Printf("DEBUG: Sending raw payload to signed relay request to %s", supplierUrl) - fmt.Printf("\n~~~~ OLSH %+v \n~~~~\n", relayHTTPRequest) + log.Printf("DEBUG: Sending signed relay request to %s", supplierUrl) relayHTTPResponse, err := http.DefaultClient.Do(relayHTTPRequest) if err != nil { return err