Skip to content

Commit

Permalink
feat(data-stream): simple connection test (#39)
Browse files Browse the repository at this point in the history
* feat: introduce FuelCore trait

This trait describes the interface required for `fuel-core-nats` to extend `fuel-core`.
Equally, it will be useful for mocking fuel-core related components in our integration
tests.

* feat: add test for simple nats connections

* feat: introduce NatsConnection

Houses NATS connection streams, messages, and other connection details. This would
eventually expose custom functions for interacting with the NATS server on a need-to
-modularize basis.

* feat: further scope nats' connection testing

* fix: use nats configuration

* feat: test nkey authorization when connecting to nats

---------

Co-authored-by: Pedro Nauck <pedronauck@gmail.com>
  • Loading branch information
Jurshsmith and pedronauck committed Jul 8, 2024
1 parent 82f54ab commit 3b8cb5a
Show file tree
Hide file tree
Showing 8 changed files with 235 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ RELAYER_V2_LISTENING_CONTRACTS=0x768f9459E3339A1F7d59CcF24C80Eb4A711a01FB
RELAYER_DA_DEPLOY_HEIGHT=5791365
RELAYER_LOG_PAGE_SIZE=2000
SYNC_HEADER_BATCH_SIZE=100
NATS_NKEY=generated-nats-secret
NATS_NKEY=generated-nats-nkey-seed
105 changes: 105 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ version = "0.0.1"
[workspace.dependencies]
anyhow = "1.0"
clap = { version = "4.5", features = ["derive"] }
dotenvy = "0.15"
futures = "0.3"
tokio = { version = "1.38", features = ["full"] }
fuel-core-bin = { version = "0.30", features = [
Expand All @@ -26,9 +27,9 @@ fuel-core-bin = { version = "0.30", features = [
"relayer",
"rocksdb",
] }
fuel-core = { version = "0.30", features = ["p2p", "relayer", "rocksdb"] }
fuel-core = { version = "0.30", features = ["p2p", "relayer", "rocksdb", "test-helpers"] }
fuel-core-client = { version = "0.30" }
fuel-core-types = { version = "0.30" }
fuel-core-types = { version = "0.30", features = ["test-helpers"] }
fuel-core-services = "0.30"

[profile.release]
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ stop:

start.nats: COMMANDS=docker
start.nats: check-commands
docker run -p 4222:4222 -p 8222:8222 -p 6222:6222 --name fuel-core-nats-server -ti nats:latest --js
docker run -p 4222:4222 -p 8222:8222 -p 6222:6222 \
--mount type=bind,source="$$(pwd)"/crates/fuel-core-nats/nats.conf,target=/etc/nats/nats.conf \
--name fuel-core-nats-server \
-ti nats:latest --js --config /etc/nats/nats.conf

stop.nats:
docker stop $$(docker ps -q --filter ancestor=nats:latest)
docker rm $$(docker ps -a -q --filter ancestor=nats:latest)
docker rm -f $$(docker ps -a -q --filter ancestor=nats:latest)

# Starts fuel-core-nats service
start.fuel-core-nats:
Expand Down
1 change: 1 addition & 0 deletions crates/fuel-core-nats/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ anyhow = "1.0.86"
async-nats = "0.35.1"
bytes = "1.6.0"
clap = "4.5.4"
dotenvy = { workspace = true }
fuel-core = { workspace = true }
fuel-core-bin = { workspace = true }
fuel-core-client = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/fuel-core-nats/nats.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
authorization: {
users: [
{ nkey: UDMBGUBEOCJVCOXHSQGYRX4SGS3QEAEDIVNHDBD63YEKHSGPVO53I2NU }
{ nkey: UAWFS7BJM4WF3SEEGDX42EGTEC2VPLERMAUYFVUXIPIV664IANONDJR5 }
]
}
jetstream = {
Expand Down
Loading

0 comments on commit 3b8cb5a

Please sign in to comment.