Skip to content

Commit

Permalink
Merge pull request #57 from vechain/headers_check
Browse files Browse the repository at this point in the history
Headers check
  • Loading branch information
leszek-vechain authored Nov 11, 2024
2 parents 8efb77f + f705433 commit ec55d40
Show file tree
Hide file tree
Showing 4 changed files with 10,894 additions and 7,609 deletions.
7 changes: 6 additions & 1 deletion src/thor-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,12 @@ class ThorClient {
async performRequest(request) {
try {
const res = await request()
return { body: res.data, success: true, httpCode: res.status }
return {
body: res.data,
headers: res.headers,
success: true,
httpCode: res.status,
}
} catch (e) {
const a = e
return {
Expand Down
8 changes: 7 additions & 1 deletion test/thorest-api/node/get-peers.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Client } from '../../../src/thor-client'
import { populatedData } from '../../../src/populated-data'

/**
* @group api
Expand All @@ -7,6 +8,11 @@ import { Client } from '../../../src/thor-client'
describe('GET /node/network/peers', () => {
it.e2eTest('should get peers', 'all', async () => {
const peers = await Client.raw.getPeers()
expect(peers.success, 'API Call should be a success').toBeTrue()

expect(peers.success).toEqual(true)
expect(peers.headers['x-thorest-ver']).toBeDefined()
expect(peers.headers['x-genesis-id']).toEqual(
populatedData.read().genesisId,
)
})
})
22 changes: 13 additions & 9 deletions test/thorest-api/subscriptions/ws-events.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,19 @@ describe('WS /subscriptions/event', () => {
)
})

it.e2eTest('should error for out of range position', 'all', async () => {
const nonExistentBlockId =
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'

await subscribeAndTestError(
{ pos: nonExistentBlockId },
'Unexpected server response: 403',
)
})
it.e2eTest(
'should error for out of range position',
['solo', 'default-private'],
async () => {
const nonExistentBlockId =
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'

await subscribeAndTestError(
{ pos: nonExistentBlockId },
'Unexpected server response: 403',
)
},
)

it.e2eTest('should error for invalid topic', 'all', async () => {
await subscribeAndTestError(
Expand Down
Loading

0 comments on commit ec55d40

Please sign in to comment.