Skip to content

Commit

Permalink
Fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
thpani committed Aug 1, 2023
1 parent e105a6b commit f7c4912
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions quint/src/quintVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,26 @@ async function loadProtoDefViaReflection(): Promise<VerifyResult<ProtoPackageDef
const reflectionClient = new serverReflectionService(APALACHE_SERVER_URI, grpc.credentials.createInsecure())

// Query reflection endpoint
const response: VerifyResult<ServerReflectionResponse[]> = await new Promise<ServerReflectionResponse[]>((resolve, reject) => {
let responses: ServerReflectionResponse[] = []
const response: VerifyResult<ServerReflectionResponse[]> = await new Promise<ServerReflectionResponse[]>(
(resolve, reject) => {
let responses: ServerReflectionResponse[] = []

const call = reflectionClient.ServerReflectionInfo()
call.on('data', (r: ServerReflectionResponse) => responses.push(r))
call.on('end', () => resolve(responses))
call.on('error', (e: grpc.StatusObject) => reject(e))
const call = reflectionClient.ServerReflectionInfo()
call.on('data', (r: ServerReflectionResponse) => responses.push(r))
call.on('end', () => resolve(responses))
call.on('error', (e: grpc.StatusObject) => reject(e))

call.write({ file_containing_symbol: 'shai.cmdExecutor.CmdExecutor' })
}).then(right).catch(e => err(`Apalache gRPC endpoint is corrupted. Error reading from streaming API: ${e.details}`))
call.write({ file_containing_symbol: 'shai.cmdExecutor.CmdExecutor' })
}
)
.then(right)
.catch(e => err(`Apalache gRPC endpoint is corrupted. Error reading from streaming API: ${e.details}`))

return response.chain((protoDefResponses: ServerReflectionResponse[]) => {
if (protoDefResponses.length === 0) {
return err(`Apalache gRPC endpoint is corrupted. Could not extract proto file: no response from reflection service`)
return err(
`Apalache gRPC endpoint is corrupted. Could not extract proto file: no response from reflection service`
)
} else if (protoDefResponses.length > 1) {
return err(
`Apalache gRPC endpoint is corrupted. Could not extract proto file: multiple responses from reflection service`
Expand Down Expand Up @@ -334,7 +340,9 @@ async function connect(cmdExecutor: AsyncCmdExecutor): Promise<VerifyResult<Apal
*/
export async function verify(config: any): Promise<VerifyResult<void>> {
// Attempt to load proto definition from Apalache distribution, else via reflection
const protoDefResult = process.env.APALACHE_DIST ? findApalacheDistribution().chain(dist => loadProtoDefViaDistribution(dist)) : await loadProtoDefViaReflection()
const protoDefResult = process.env.APALACHE_DIST
? findApalacheDistribution().chain(dist => loadProtoDefViaDistribution(dist))
: await loadProtoDefViaReflection()
const connectionResult = await protoDefResult.chain(loadGrpcClient).asyncChain(connect)
return connectionResult.asyncChain(conn => conn.check(config))
}

0 comments on commit f7c4912

Please sign in to comment.