Skip to content

Commit

Permalink
Fix session tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ScreamingHawk committed Nov 25, 2024
1 parent c518205 commit bb55001
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/auth/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export class Session {

if (services) {
servicesObj = new Services(account, services)
servicesObj.auth(1, referenceChainId) // fire and forget
servicesObj.auth(undefined, referenceChainId) // fire and forget

servicesObj.onAuth(result => {
if (result.status === 'fulfilled') {
Expand Down
21 changes: 19 additions & 2 deletions packages/auth/tests/session.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,11 @@ describe('Wallet integration', function () {

server = mockServer.getLocal()
server.start(8099)
server.forPost('/rpc/API/GetAuthToken').thenCallback(async request => {
const getAuthToken = async (request: mockServer.CompletedRequest, provider: ethers.Provider) => {
if (delayMs !== 0) await delay(delayMs)

const validator = ValidateSequenceWalletProof(
() => new commons.reader.OnChainReader(networks[0].provider!),
() => new commons.reader.OnChainReader(provider),
tracker,
contexts[2]
)
Expand Down Expand Up @@ -621,7 +621,24 @@ describe('Wallet integration', function () {
return {
statusCode: 401
}
}
}
server.forPost('/rpc/API/GetAuthToken').thenCallback(async request => {
return getAuthToken(request, networks[0].provider!)
})
server.forPost('/rpc/API/GetAuthToken2').thenCallback(async request => {
const requestBody = await request.body.getJson()
if (!requestBody) {
return { statusCode: 400 }
}

const provider = networks.find(n => n.chainId === Number(requestBody['chainID']))
if (!provider || !provider.provider) {
console.log('No provider found for chainID', requestBody['chainID'])
return { statusCode: 400 }
}

return getAuthToken(request, provider.provider!)
})
})

Expand Down

0 comments on commit bb55001

Please sign in to comment.