Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[E2E relay test] Update to #178 #184

Merged
merged 156 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 139 commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
29b9bdf
refactor: `MapFn`s receive context arg
bryanchriswhite Nov 9, 2023
b6c9c71
chore: add `ForEach` map shorthand operator
bryanchriswhite Nov 9, 2023
f257b46
chore: add `/pkg/observable/filter`
bryanchriswhite Nov 9, 2023
194cee5
chore: add `/pkg/observable/logging`
bryanchriswhite Nov 9, 2023
cca55c2
chore: add `/pkg/relayer/protocol`
bryanchriswhite Nov 9, 2023
c666542
chore: add `Miner` interface
bryanchriswhite Nov 9, 2023
ea8d848
feat: add `Miner` implementation
bryanchriswhite Nov 9, 2023
38329bb
test: `Miner` implementation
bryanchriswhite Nov 9, 2023
d2f9cb4
chore: fix comment
bryanchriswhite Nov 9, 2023
d502b75
chore: add godoc comments
bryanchriswhite Nov 9, 2023
48cef80
feat: Add Relayer struct
red-0ne Nov 9, 2023
f85a381
Merge remote-tracking branch 'pokt/main' into issues/13/feat/miner
bryanchriswhite Nov 9, 2023
cba145e
chore: Rename to RelayMiner
red-0ne Nov 9, 2023
c81c274
chore: Rename relay miner file
red-0ne Nov 9, 2023
0e38e7d
chore: Remove unused
red-0ne Nov 9, 2023
f9e1cbc
[Test] First step for automated E2E Relay test (#167)
Olshansk Nov 9, 2023
0e72490
[Relayer] refactor: simplify `RelayerSessionsManager` (#169)
bryanchriswhite Nov 9, 2023
107f6dd
chore: review feedback improvements
bryanchriswhite Nov 9, 2023
ccad087
chore: review feedback improvements
bryanchriswhite Nov 9, 2023
8737024
Merge remote-tracking branch 'pokt/main' into issues/13/feat/miner
bryanchriswhite Nov 9, 2023
e041472
chore: update start mining comment
red-0ne Nov 9, 2023
8cf0784
fix: Update Miner interface
red-0ne Nov 9, 2023
85a49b7
fix: import cycle & goimports
bryanchriswhite Nov 9, 2023
0788e1d
chore: review feedback improvements
bryanchriswhite Nov 9, 2023
e6a558b
chore: cleanup TODO_THIS_COMMIT comments
bryanchriswhite Nov 9, 2023
d04ea2a
Merge branch 'main' into issues/13/feat/miner
bryanchriswhite Nov 9, 2023
9c75b2c
chore: improve var & func names for clarity and consistency
bryanchriswhite Nov 10, 2023
286e1b2
Merge remote-tracking branch 'pokt/main' into issues/13/feat/miner
bryanchriswhite Nov 10, 2023
a0ffe9d
refactor: move claim/proof lifecycle concerns to `relayerSessionsMana…
bryanchriswhite Nov 10, 2023
2019637
chore: review feedback improvements
bryanchriswhite Nov 10, 2023
709f661
chore: review feedback improvements
bryanchriswhite Nov 10, 2023
394575b
refactor: `miner#hash()` method
bryanchriswhite Nov 10, 2023
1eae9d2
chore: tidy up
bryanchriswhite Nov 10, 2023
efb8a4e
chore: simplify
bryanchriswhite Nov 10, 2023
b38aa81
wip: relayer CLI
bryanchriswhite Nov 10, 2023
c1be2b5
chore: finish first pass
bryanchriswhite Nov 10, 2023
3b2022a
chore: review feedback improvements
bryanchriswhite Nov 10, 2023
967dddc
chore: review feedback improvements
bryanchriswhite Nov 10, 2023
f9a6fb2
chore: review feedback improvements
bryanchriswhite Nov 10, 2023
7d23bd4
chore: review feedback improvements
bryanchriswhite Nov 10, 2023
916c0dd
chore: review feedback improvements
bryanchriswhite Nov 10, 2023
04a79b2
chore: tidy up cmd creation
h5law Nov 10, 2023
55c8118
fix: incomplete refactor
bryanchriswhite Nov 10, 2023
c1784f5
chore: simplify
bryanchriswhite Nov 10, 2023
92925eb
Merge branch 'issues/13/feat/miner' into relayer/cli
bryanchriswhite Nov 10, 2023
0bfdc80
chore: add log lines
h5law Nov 10, 2023
c49394e
Merge remote-tracking branch 'pokt/relayer/cli' into relayer/cli
bryanchriswhite Nov 10, 2023
9efde4f
wip: react to miner, refactor, construct miner, refactor
bryanchriswhite Nov 10, 2023
3de8b3e
chore: cleanup
bryanchriswhite Nov 10, 2023
323b074
Merge remote-tracking branch 'origin/issues/13/feat/miner' into feat/…
red-0ne Nov 10, 2023
059b7df
chore: Reflect responsibility changes of session manager
red-0ne Nov 10, 2023
6460fa9
Merge remote-tracking branch 'origin/main' into feat/relayer
red-0ne Nov 10, 2023
9dfe585
Merge branch 'feat/relayer' into relayer/cli
red-0ne Nov 10, 2023
5f9bd5f
feat: Use relay miner to start
red-0ne Nov 10, 2023
0c4e353
[WIP] Updating relay.feature to run curl command
Olshansk Nov 10, 2023
1dcdbbe
chore: Improve comment about startig relayer proxy
red-0ne Nov 10, 2023
da46de7
wip: debugging
bryanchriswhite Nov 10, 2023
6835ce9
Merge remote-tracking branch 'origin/main' into relayer/cli
red-0ne Nov 10, 2023
4f9a74f
Continued implementation but still failing
Olshansk Nov 10, 2023
cc05bac
Getting an invalid request right now but figuring it out...
Olshansk Nov 10, 2023
f074f97
Merge branch 'main' into e2e_test/relay
Olshansk Nov 10, 2023
51bccfe
Merge remote-tracking branch 'origin/main' into relayer/cli
red-0ne Nov 10, 2023
47d8685
wip: debugging
bryanchriswhite Nov 11, 2023
a69b5f3
Merge remote-tracking branch 'pokt/relayer/cli' into relayer/cli
bryanchriswhite Nov 11, 2023
34e52f7
Added service and switched to AppGate
Olshansk Nov 11, 2023
beb0757
wip: debugging
bryanchriswhite Nov 11, 2023
ec1910f
chore: Rename falg variables
red-0ne Nov 11, 2023
ded793f
wip: debugging
bryanchriswhite Nov 11, 2023
9ba2dc1
Merge remote-tracking branch 'origin/relayer/cli' into relayer/cli
red-0ne Nov 11, 2023
bf936e6
revertme: disable tilt relayer service
bryanchriswhite Nov 11, 2023
c96e5c5
Merge remote-tracking branch 'origin/relayer/cli' into relayer/cli
red-0ne Nov 11, 2023
0d9edb9
chore: use arg not flag
h5law Nov 11, 2023
5c5eace
chore: rename command
red-0ne Nov 11, 2023
ee397d3
Debugging checkpoint
Olshansk Nov 11, 2023
a3a3635
wip: debugging - improvments
bryanchriswhite Nov 11, 2023
641d60a
Merge remote-tracking branch 'pokt/relayer/cli' into relayer/cli
bryanchriswhite Nov 11, 2023
71052b7
wip: debugging
bryanchriswhite Nov 11, 2023
fa8c2eb
wip: debugging
bryanchriswhite Nov 11, 2023
0638e8d
wip: debugging
bryanchriswhite Nov 11, 2023
bb87722
revert-or-fixme: add error log lines
bryanchriswhite Nov 12, 2023
bcfbef1
revert-or-fixme: add debug log lines
bryanchriswhite Nov 12, 2023
4019a17
fix: set relay server handle function
bryanchriswhite Nov 12, 2023
9c3cfb5
revert-or-fixme: add debug log lines
bryanchriswhite Nov 12, 2023
2c130ce
chore: rename some chan vars
bryanchriswhite Nov 12, 2023
8493b2c
feat: fix all bugs, e2e relay works
h5law Nov 12, 2023
c85f75b
Merge branch 'refactor_appgate' into relayer/cli
h5law Nov 12, 2023
dfd28f8
chore: add some todo comments
h5law Nov 12, 2023
5ab0e4c
wip: debugging
bryanchriswhite Nov 12, 2023
ff4997a
fix: use remote helm charts again
bryanchriswhite Nov 13, 2023
ac54c24
fix: put adequate proxied services endpoitns, prevent session republi…
red-0ne Nov 13, 2023
efc2ab5
chore: Refactor JSONRPCServer and server builder
red-0ne Nov 13, 2023
9c32675
Upate a couple small comments in the maketfile
Olshansk Nov 14, 2023
17597c4
revert: comment relayers out of tiltfile
bryanchriswhite Nov 14, 2023
23ac551
chore: fix subcmd name `relayerminer` -> `relayminer`
bryanchriswhite Nov 14, 2023
e13211e
chore: improve logging
bryanchriswhite Nov 14, 2023
cf5910f
chore: cleanup error messaging & logging in appgate server
bryanchriswhite Nov 14, 2023
eb56997
refactor: rename misnamed `jsonRPCServer` receiver var
bryanchriswhite Nov 14, 2023
5e60381
chore: remove appgate server debug log
bryanchriswhite Nov 14, 2023
0bd05ae
chore: unexport `relayMiner` struct
bryanchriswhite Nov 14, 2023
a031b92
refactor: interrupt signal handling
bryanchriswhite Nov 14, 2023
c05ba2b
chore: improve comments
bryanchriswhite Nov 14, 2023
aeb4ee8
chore: improve comments
bryanchriswhite Nov 14, 2023
6648a38
revert: tiltfile hot-reload dirs
bryanchriswhite Nov 14, 2023
e5a4d73
refactor: re-consolidate client contexts
bryanchriswhite Nov 14, 2023
95fc559
fix: typo
bryanchriswhite Nov 14, 2023
c3898e0
chore: remove todo
bryanchriswhite Nov 14, 2023
c61abaf
chore: add todo comment
bryanchriswhite Nov 14, 2023
839a3dc
revert: comment change
bryanchriswhite Nov 14, 2023
ff8fc6a
fix: error format strings
bryanchriswhite Nov 14, 2023
66bfba5
chore: remove comment
bryanchriswhite Nov 14, 2023
15948a8
Merge branch 'main' into relayer/cli
bryanchriswhite Nov 14, 2023
95a6dc9
fix: error format strings
bryanchriswhite Nov 14, 2023
890370d
Merge remote-tracking branch 'pokt/main' into wip/e2e_test/relay
bryanchriswhite Nov 14, 2023
9cfd8ff
Merge branch 'relayer/cli' into wip/e2e_test/relay
bryanchriswhite Nov 14, 2023
65ff2e4
chore: add `-features-path` flag to cucumber tests
bryanchriswhite Nov 14, 2023
5ec4514
fix: set the relayminer URL in the curl cmd
bryanchriswhite Nov 14, 2023
1160c0a
chore: remove redundant `-X` curl arg (says curl)
bryanchriswhite Nov 14, 2023
b7a66de
squash: fix relayminer url: reword: s/relayminer/appgateserver/
bryanchriswhite Nov 14, 2023
49ba416
chore: improve error messaging
bryanchriswhite Nov 14, 2023
7e400e4
fix: curl invocation
bryanchriswhite Nov 14, 2023
b52f046
test: implement step definition to assert agains relay response
bryanchriswhite Nov 14, 2023
7bc6a26
chore: improve error name & messaging
bryanchriswhite Nov 14, 2023
9d86294
Merge branch 'main' into e2e_test/relay
Olshansk Nov 14, 2023
700fd06
Self review
Olshansk Nov 14, 2023
3887759
Merge branch 'e2e_test/relay' into e2e_test/relay-update
bryanchriswhite Nov 15, 2023
122bec0
fixup: merge upstream
bryanchriswhite Nov 15, 2023
8c1f5b9
chore: review feedback improvements
bryanchriswhite Nov 15, 2023
5bfe151
chore: update anvil service port in make targets
bryanchriswhite Nov 15, 2023
86255b3
chore: review feedback improvements
bryanchriswhite Nov 15, 2023
0aaddc8
refactor: relayminer depinject helpers & godoc comments on all constr…
bryanchriswhite Nov 15, 2023
6ad6abe
refactor: separate tx and query client contexts 🙄
bryanchriswhite Nov 15, 2023
88e046d
fix: sessiontree store path check
bryanchriswhite Nov 15, 2023
9b83691
fix: sessiontree store path check
bryanchriswhite Nov 15, 2023
c865eb0
chore: review feedback improvements
bryanchriswhite Nov 15, 2023
fe9db58
chore: review feedback improvements
bryanchriswhite Nov 15, 2023
8d7e577
chore: add long command description
bryanchriswhite Nov 15, 2023
f945513
fix: supplier client test
bryanchriswhite Nov 15, 2023
0a53626
Merge branch 'main' into relayer/cli
bryanchriswhite Nov 15, 2023
3a178b2
Merge branch 'relayer/cli' into merge/e2e_test/relay_x_relayer_cli
bryanchriswhite Nov 15, 2023
98a1854
Merge branch 'merge/e2e_test/relay_x_relayer_cli' into e2e_test/relay…
bryanchriswhite Nov 15, 2023
4ce831b
chore: cleanup flags and dependencies for appgateserver cmd
h5law Nov 15, 2023
d83c1e7
chore: move shared dependency setup logic to shared pkg
h5law Nov 15, 2023
e58c848
chore: update comment
h5law Nov 15, 2023
75343bb
Update .gitignore
Olshansk Nov 15, 2023
1cc7085
Update OpenAPI spec
Olshansk Nov 15, 2023
a04ebfc
Updated comments for post 177+179 work for okdas
Olshansk Nov 15, 2023
59f863c
Update pkg/relayer/cmd/cmd.go
Olshansk Nov 15, 2023
753c27a
Update the names and references to queryNode/sequencerNode/fullNode etc
Olshansk Nov 15, 2023
966b874
Update some comments and TODOs
Olshansk Nov 15, 2023
c726dfc
Added a couple more comments
Olshansk Nov 15, 2023
b9c0d62
Merge with main
Olshansk Nov 15, 2023
c36db92
More tiny comment updates
Olshansk Nov 15, 2023
b885583
Merge branch 'relayer/cli' into merge/e2e_test/relay_x_relayer_cli
bryanchriswhite Nov 16, 2023
09de036
Merge remote-tracking branch 'pokt/main' into merge/e2e_test/relay_x_…
bryanchriswhite Nov 16, 2023
0498318
Merge branch 'merge/e2e_test/relay_x_relayer_cli' into e2e_test/relay…
bryanchriswhite Nov 16, 2023
27ddcff
chore: review feedback improvements
bryanchriswhite Nov 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,13 @@ localnet_config.yaml
# Relase artifacts produced by `ignite chain build --release`
release

# SMT KVStore files
smt

# Do not allow a multi-moduled projected
go.work.sum

# TODO_IN_THIS_COMMIT: Why did we start generating .dot files?
# **/*.dot


19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
APPGATE_SERVER = http://localhost:42069
POCKET_ADDR_PREFIX = pokt

####################
Expand Down Expand Up @@ -136,6 +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 APPGATE_SERVER=$(APPGATE_SERVER) && \
POKTROLLD_HOME=../../$(POKTROLLD_HOME) && \
go test -v ./e2e/tests/... -tags=e2e

Expand Down Expand Up @@ -281,7 +283,7 @@ app_stake: ## Stake tokens for the application specified (must specify the APP a
poktrolld --home=$(POKTROLLD_HOME) tx application stake-application 1000upokt $(SERVICES) --keyring-backend test --from $(APP) --node $(POCKET_NODE)

.PHONY: app1_stake
app1_stake: ## Stake app1
app1_stake: ## Stake app1 (also staked in genesis)
APP=app1 SERVICES=anvil,svc1,svc2 make app_stake

.PHONY: app2_stake
Expand Down Expand Up @@ -361,16 +363,23 @@ supplier_stake: ## Stake tokens for the supplier specified (must specify the APP
poktrolld --home=$(POKTROLLD_HOME) tx supplier stake-supplier 1000upokt "$(SERVICES)" --keyring-backend test --from $(SUPPLIER) --node $(POCKET_NODE)

.PHONY: supplier1_stake
supplier1_stake: ## Stake supplier1
SUPPLIER=supplier1 SERVICES="anvil;http://anvil:8547,svc1;http://localhost:8081" make supplier_stake
supplier1_stake: ## Stake supplier1 (also staked in genesis)
# TODO_TECHDEBT(#179): once `relayminer` service is added to tilt, this hostname should point to that service.
# I.e.: replace `localhost` with `relayminer` (or whatever the service's hostname is).
# TODO_IMPROVE(#180): Make sure genesis-staked actors are available via AccountKeeper
SUPPLIER=supplier1 SERVICES="anvil;http://localhost:8545,svc1;http://localhost:8081" make supplier_stake

.PHONY: supplier2_stake
supplier2_stake: ## Stake supplier2
SUPPLIER=supplier2 SERVICES="anvil;http://anvil:8547,svc2;http://localhost:8082" make supplier_stake
# TODO_TECHDEBT(#179): once `relayminer` service is added to tilt, this hostname should point to that service.
# I.e.: replace `localhost` with `relayminer` (or whatever the service's hostname is).
SUPPLIER=supplier2 SERVICES="anvil;http://localhost:8545,svc2;http://localhost:8082" make supplier_stake

.PHONY: supplier3_stake
supplier3_stake: ## Stake supplier3
SUPPLIER=supplier3 SERVICES="anvil;http://anvil:8547,svc3;http://localhost:8083" make supplier_stake
# TODO_TECHDEBT(#179): once `relayminer` service is added to tilt, this hostname should point to that service.
# I.e.: replace `localhost` with `relayminer` (or whatever the service's hostname is).
SUPPLIER=supplier3 SERVICES="anvil;http://localhost:8545,svc3;http://localhost:8083" make supplier_stake

.PHONY: supplier_unstake
supplier_unstake: ## Unstake an supplier (must specify the SUPPLIER env var)
Expand Down
6 changes: 6 additions & 0 deletions cmd/pocketd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/pokt-network/poktroll/app"
appparams "github.com/pokt-network/poktroll/app/params"
appgateservercmd "github.com/pokt-network/poktroll/pkg/appgateserver/cmd"
relayercmd "github.com/pokt-network/poktroll/pkg/relayer/cmd"
)

// NewRootCmd creates a new root command for a Cosmos SDK application
Expand Down Expand Up @@ -142,6 +143,11 @@ func initRootCmd(
addModuleInitFlags,
)

// add relayer command
rootCmd.AddCommand(
relayercmd.RelayerCmd(),
)

// add keybase, auxiliary RPC, query, and tx child commands
rootCmd.AddCommand(
rpc.StatusCommand(),
Expand Down
23 changes: 23 additions & 0 deletions cmd/signals/on_exit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package signals

import (
"os"
"os/signal"
)

// GoOnExitSignal calls the given callback when the process receives an interrupt
// or kill signal.
func GoOnExitSignal(onInterrupt func()) {
go func() {
// Set up sigCh to receive when this process receives an interrupt or
// kill signal.
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, os.Interrupt, os.Kill)

// Block until we receive an interrupt or kill signal (OS-agnostic)
<-sigCh

// Call the onInterrupt callback.
onInterrupt()
}()
}
3 changes: 2 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ genesis:
- endpoints:
- configs: []
rpc_type: JSON_RPC
url: http://anvil:8547
# TODO_TECHDEBT(#179): once `relayminer` service is added to tilt, this hostname should point to it instead of `localhost`.
url: http://localhost:8545
service:
id: anvil
name: ""
Expand Down
30 changes: 16 additions & 14 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46480,7 +46480,7 @@ paths:
service:
title: >-
The Service for which the application is
configured
configured for
type: object
properties:
id:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -47176,7 +47178,7 @@ paths:
service:
title: >-
The Service for which the application is
configured
configured for
type: object
properties:
id:
Expand Down Expand Up @@ -47243,7 +47245,7 @@ paths:
service:
title: >-
The Service for which the supplier is
configured
configured for
type: object
properties:
id:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
43 changes: 38 additions & 5 deletions e2e/tests/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
package e2e

import (
"flag"
"fmt"
"log"
"regexp"
"strconv"
"strings"
Expand All @@ -22,6 +24,12 @@ import (
suppliertypes "github.com/pokt-network/poktroll/x/supplier/types"
)

// TODO_TECHDEBT(#179): Once relayminer and appgateserver are running in tilt,
bryanchriswhite marked this conversation as resolved.
Show resolved Hide resolved
// use their respective in-tilt hostnames and run E2E tests in tilt. This
// should match the on-chain advertised endpoint for the service with the
// given serviceId.
const localnetAppGateServerUrl = "http://localhost:42069"

var (
addrRe *regexp.Regexp
amountRe *regexp.Regexp
Expand All @@ -31,12 +39,21 @@ var (
accNameToAppMap = make(map[string]apptypes.Application)
accNameToSupplierMap = make(map[string]sharedtypes.Supplier)

keyRingFlag = "--keyring-backend=test"
flagFeaturesPath string
keyRingFlag = "--keyring-backend=test"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flagKeyRingDefault?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm reluctant to align the naming between these two "flag vars". This is categorically different than the features path flag, it is not registered as a go flag but is instead both the key and value of a flag which is passed to binaries called by the go command API.

)

func init() {
addrRe = regexp.MustCompile(`address:\s+(\S+)\s+name:\s+(\S+)`)
amountRe = regexp.MustCompile(`amount:\s+"(.+?)"\s+denom:\s+upokt`)

flag.StringVar(&flagFeaturesPath, "features-path", "*.feature", "Specifies glob paths for the runner to look up .feature files")
}

func TestMain(m *testing.M) {
flag.Parse()
log.Printf("features path: %s", flagFeaturesPath)
m.Run()
}

type suite struct {
Expand All @@ -58,7 +75,7 @@ func (s *suite) Before() {
// TestFeatures runs the e2e tests specified in any .features files in this directory
// * This test suite assumes that a LocalNet is running
func TestFeatures(t *testing.T) {
gocuke.NewRunner(t, &suite{}).Path("*.feature").Run()
gocuke.NewRunner(t, &suite{}).Path(flagFeaturesPath).Run()
}

func (s *suite) TheUserHasThePocketdBinaryInstalled() {
Expand Down Expand Up @@ -242,12 +259,22 @@ 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) {
res, err := s.pocketd.RunCurl(localnetAppGateServerUrl, 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)
}

relayKey := relayReferenceKey(appName, supplierName)
s.scenarioState[relayKey] = res.Stdout
}

func (s *suite) TheApplicationReceivesASuccessfulRelayResponseSignedBy(appName string, supplierName string) {
// TODO(#126, @Olshansk): Implement this step
relayKey := relayReferenceKey(appName, supplierName)
stdout, ok := s.scenarioState[relayKey]

require.Truef(s, ok, "no relay response found for %s", relayKey)
require.Contains(s, stdout, `"result":"0x`)
}

func (s *suite) getStakedAmount(actorType, accName string) (bool, int) {
Expand Down Expand Up @@ -358,3 +385,9 @@ func (s *suite) getAccBalance(accName string) int {
require.NoError(s, err)
return found
}

// TODO_IMPROVE: use `sessionId` and `supplierName` since those are the two values
// used to create the primary composite key on-chain to uniquely distinguish relays.
func relayReferenceKey(appName, supplierName string) string {
return fmt.Sprintf("%s/%s", appName, supplierName)
}
Loading