What is Nostr?
Mtg /
npub1zug…dx38
2023-04-24 19:54:30
in reply to nevent1q…e8en

Mtg on Nostr: @Johns Yes, that's an option. But in general, if it's possible to mock an external ...

@Johns
Yes, that's an option.
But in general, if it's possible to mock an external module locally, then that's better.

Actually, just today, I had a discussion with a few people on the nostr Telegram group regarding this thing, so I'll put here the reasons why I think an in-memory simple mock relay is better than hosting a real "testing" relay:

1- Simpler to run

When you are introducing an external component to your testing flow like a Relay,

you (or anyone else) won't be able to run your tests unless they also have a running relay on their machine.

2- Speed

A mock relay would just be a very simple class that holds a list of events objects in memory & returns them.

An actual relay will likely have many more functionalites that you likely don't need in a "web-app testing " environment.

3- Running it on a CI/CD environment

Like if you want to always run all your tests on your CI/CD after each push.

If your tests require an actual running relay, you need to host one yourself online


Even if it's considered a "testing" relay, it is still a new live component that needs updates, maintainence, and has costs.

So if we can get around that by using a mock relay, I'd prefer that.
(But that's in the case that it works eventually 🥲🥲)
Author Public Key
npub1zug85tns97cfxafjpa2rh28d45d6h4txgxt3vr8rxe9czr85j47qntdx38