fix: encode enums correctly (#1210)

Updates protons and regenerates protobuf code to encode enums correctly
This commit is contained in:
Alex Potsides
2022-05-10 12:35:33 +01:00
committed by GitHub
parent da3d19b309
commit 4837430d8b
11 changed files with 95 additions and 45 deletions

View File

@ -20,6 +20,7 @@ import { DefaultConnectionManager } from '../../src/connection-manager/index.js'
import { Plaintext } from '../../src/insecure/index.js'
import { WebSockets } from '@libp2p/websockets'
import { Mplex } from '@libp2p/mplex'
import type { PeerProtocolsChangeData } from '@libp2p/interfaces/peer-store'
const protocol = '/test/1.0.0'
@ -145,6 +146,15 @@ describe('registrar', () => {
detail: conn
}))
// identify completes
await libp2p.components.getPeerStore().dispatchEvent(new CustomEvent<PeerProtocolsChangeData>('change:protocols', {
detail: {
peerId: conn.remotePeer,
protocols: [protocol],
oldProtocols: []
}
}))
// remote peer disconnects
await conn.close()
await libp2p.components.getUpgrader().dispatchEvent(new CustomEvent<Connection>('connectionEnd', {
@ -186,10 +196,20 @@ describe('registrar', () => {
// Add protocol to peer and update it
await libp2p.peerStore.protoBook.add(remotePeerId, [protocol])
// remote peer connects
await libp2p.components.getUpgrader().dispatchEvent(new CustomEvent<Connection>('connection', {
detail: conn
}))
// identify completes
await libp2p.components.getPeerStore().dispatchEvent(new CustomEvent<PeerProtocolsChangeData>('change:protocols', {
detail: {
peerId: conn.remotePeer,
protocols: [protocol],
oldProtocols: []
}
}))
await onConnectDefer.promise
// Peer no longer supports the protocol our topology is registered for

View File

@ -47,7 +47,7 @@ describe('Transport Manager (WebSockets)', () => {
tm.add(transport)
expect(tm.getTransports()).to.have.lengthOf(1)
await tm.remove(transport.constructor.name)
await tm.remove(transport[Symbol.toStringTag])
expect(tm.getTransports()).to.have.lengthOf(0)
})