-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
packages/jellyfish-api-core/__tests__/category/net/getNetTotals.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { MasterNodeRegTestContainer, RegTestContainer } from '@defichain/testcontainers/dist/index' | ||
import { net } from '../../../src' | ||
import { ContainerAdapterClient } from '../../container_adapter_client' | ||
|
||
describe('Network without masternode', () => { | ||
const container = new RegTestContainer() | ||
const client = new ContainerAdapterClient(container) | ||
|
||
beforeAll(async () => { | ||
await container.start() | ||
}) | ||
|
||
afterAll(async () => { | ||
await container.stop() | ||
}) | ||
|
||
it('should getNetTotals', async () => { | ||
const info: net.NetTotals = await client.net.getNetTotals() | ||
|
||
expect(info).toStrictEqual({ | ||
totalbytesrecv: expect.any(Number), | ||
totalbytessent: expect.any(Number), | ||
timemillis: expect.any(Number), | ||
uploadtarget: { | ||
timeframe: expect.any(Number), | ||
target: expect.any(Number), | ||
target_reached: expect.any(Boolean), | ||
serve_historical_blocks: expect.any(Boolean), | ||
bytes_left_in_cycle: expect.any(Number), | ||
time_left_in_cycle: expect.any(Number) | ||
} | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Network on masternode', () => { | ||
const container = new MasterNodeRegTestContainer() | ||
const client = new ContainerAdapterClient(container) | ||
|
||
beforeAll(async () => { | ||
await container.start() | ||
await container.generate(1) | ||
}) | ||
|
||
afterAll(async () => { | ||
await container.stop() | ||
}) | ||
|
||
it('should getNetTotals', async () => { | ||
const info: net.NetTotals = await client.net.getNetTotals() | ||
|
||
expect(info).toStrictEqual({ | ||
totalbytesrecv: expect.any(Number), | ||
totalbytessent: expect.any(Number), | ||
timemillis: expect.any(Number), | ||
uploadtarget: { | ||
timeframe: expect.any(Number), | ||
target: expect.any(Number), | ||
target_reached: expect.any(Boolean), | ||
serve_historical_blocks: expect.any(Boolean), | ||
bytes_left_in_cycle: expect.any(Number), | ||
time_left_in_cycle: expect.any(Number) | ||
} | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters