Skip to content

Commit

Permalink
Merge pull request #29 from mysteriumnetwork/tokens-earned-session-state
Browse files Browse the repository at this point in the history
Enrich service session with `tokensEarned` (provider)
  • Loading branch information
tadaskay authored Feb 11, 2020
2 parents 7d13735 + 0b9db62 commit 3730e4c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/provider/provider-sessions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ import { ProviderSessions } from './provider-sessions'

class ProviderServiceTequilapiClientMock extends EmptyTequilapiClientMock {
public serviceSessionsMock: ServiceSession[] = [
{ id: 'id1', consumerId: '0x1', createdAt: '2019-01-01', bytesIn: 10, bytesOut: 11 },
{
id: 'id1',
consumerId: '0x1',
createdAt: '2019-01-01',
bytesIn: 10,
bytesOut: 11,
tokensEarned: 1000,
},
]

public async serviceSessions(): Promise<ServiceSession[]> {
Expand Down
1 change: 1 addition & 0 deletions src/provider/service-session.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('TequilapiClient DTO', () => {
createdAt: '2019-01-01',
bytesIn: 10,
bytesOut: 11,
tokensEarned: 4_000,
}

describe('.parseServiceInfo', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/provider/service-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface ServiceSession {
createdAt: string
bytesIn: number
bytesOut: number
tokensEarned: number
}

export function parseServiceSession(data: any): ServiceSession {
Expand All @@ -32,6 +33,7 @@ export function parseServiceSession(data: any): ServiceSession {
{ name: 'createdAt', type: 'string' },
{ name: 'bytesIn', type: 'number' },
{ name: 'bytesOut', type: 'number' },
{ name: 'tokensEarned', type: 'number' },
])
return data
}
Expand Down
2 changes: 2 additions & 0 deletions src/tequilapi-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -722,13 +722,15 @@ describe('HttpTequilapiClient', () => {
createdAt: '2019-01-01 00:00:00',
bytesIn: 1000,
bytesOut: 100,
tokensEarned: 1000,
},
{
id: '76fca3dc-28d0-4f00-b06e-a7d6050699ae',
consumerId: '0x2000FACE',
createdAt: '2019-01-02 00:00:00',
bytesIn: 1100,
bytesOut: 101,
tokensEarned: 1000,
},
],
}
Expand Down

0 comments on commit 3730e4c

Please sign in to comment.