-
Notifications
You must be signed in to change notification settings - Fork 1
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
test: cross-version sync with @comapeo/core@2.0.1
#941
Conversation
Our tests currenly connect `MapeoManager`s in two ways: 1. By starting peer discovery servers and connecting. This is similar to what the real app does. 2. By manually creating streams and connecting them in tests. This is less realistic. This commit removes the second way because: - it is less realistic - it lets us remove some test-only code in the `src/` directory - it will make an upcoming change easier I also tried to fix a possible (test-only) race condition, which *could* have been a reason for the less realistic option: 1. Start connecting peers by calling `connectPeers()`. This begins the process of starting peer discovery servers. 2. Disconnect them by calling the callback returned by `connectPeers()`. 3. The peer discovery servers start, and begin connecting. *This is bad* because we already wanted to disconnect!
This tests that we can connect and sync between the current version and `@comapeo/core@2.0.1`. Notably, it required several changes to our test utilities to support the current `MapeoManager` and older ones. (One of these changes allowed us to remove a test-only method from `MapeoManager`.)
/** | ||
* MapeoRPC instance, used for tests | ||
*/ | ||
get [kRPC]() { | ||
return this.#localPeers | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer needed.
managers.every((manager) => { | ||
const unconnectedDeviceIds = new Set(deviceIds) | ||
unconnectedDeviceIds.delete(manager.deviceId) | ||
for (const peer of manager[kRPC].peers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to do a small amount of work to stop calling a private method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok looks good. For maintainability, it could be helpful to change this later to be an option of createManager
, e.g. createManager({ managerConstructor: MapeoManager2_0_1 })
. However to do this, we need to have defaults for the migrations folders. Having it as a constructor option allows us to write tests as we develop to test specific changes between versions, without needing to keep adding test utils.
I'll do that the moment we start testing with another older version. |
Depends on #856.
I recommend reviewing this with whitespace changes disabled.
This tests that we can connect and sync between the current version and
@comapeo/core@2.0.1
.Notably, it required several changes to our test utilities to support the current
MapeoManager
and older ones. (One of these changes allowed us to remove a test-only method fromMapeoManager
.)