1
1
import test from 'ava'
2
2
import { ClientAccountGetminedblocks } from '../../src/client/ClientAccountGetminedblocks'
3
3
import { ApiKey } from '../../src/entities/Apikey' ;
4
+ import { Address } from '../../src/entities/Address' ;
5
+ import { decode } from 'querystring'
4
6
// import { decode } from 'querystring'
5
7
// const nock = require('nock')
6
- // import { parse } from 'url'
8
+ import { parse } from 'url'
7
9
// import { readFile } from 'fs'
8
10
// import { promisify } from 'util'
9
11
//const _readFile = promisify(readFile)
10
12
11
13
const type = 'block'
12
- const apiKey = 'TRU5Z5MNWIEYP4F6DPH2T53IJWZIZ5GT1W'
14
+ const address = new Address ( '0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b' )
15
+ const tag = 'latest'
16
+ const apiKey = new ApiKey ( 'TRU5Z5MNWIEYP4F6DPH2T53IJWZIZ5GT1W' )
17
+
18
+ const expectedUrl = 'https://api.etherscan.io/api?module=account&action=getminedblocks&address=0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b&blocktype=blocks&page=1&offset=10&apikey=TRU5Z5MNWIEYP4F6DPH2T53IJWZIZ5GT1W'
19
+
13
20
14
21
test ( 'exists' , t => {
15
22
t . truthy ( ClientAccountGetminedblocks )
16
23
} )
17
24
18
25
test ( 'can be instantiated' , t => {
19
- const oApiKey = new ApiKey ( apiKey )
26
+ new ClientAccountGetminedblocks ( apiKey , 'account' , 'getminedblocks' , address , tag )
20
27
t . pass ( )
21
- } )
28
+ } )
29
+
30
+ test ( 'generates the right url' , t => {
31
+ const c = new ClientAccountGetminedblocks ( apiKey , 'account' , 'balancemulti' , address , tag )
32
+ const url = c . toUrl ( )
33
+ const parsedUrl = parse ( url , true ) . query
34
+ const parsedExpectedUrl = parse ( expectedUrl , true ) . query
35
+ t . is ( parsedUrl . action , parsedExpectedUrl . action )
36
+ t . is ( parsedUrl . module , parsedExpectedUrl . module )
37
+ t . is ( parsedUrl . address , parsedExpectedUrl . address )
38
+ t . is ( parsedUrl . tag , parsedExpectedUrl . tag )
39
+ } )
0 commit comments