Skip to content

Commit

Permalink
Add tests. Tests are good.
Browse files Browse the repository at this point in the history
  • Loading branch information
l1h3r committed Sep 4, 2017
1 parent 0811eed commit 6cbaf17
Show file tree
Hide file tree
Showing 39 changed files with 1,608 additions and 210 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[Official Documentation](https://etherscan.io/apis)

[Create API Key](https://etherscan.io/myapikey)
[Create API Key (optional)](https://etherscan.io/myapikey)

## Installation

Expand All @@ -12,7 +12,7 @@ by adding `etherscan` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:etherscan, "~> 0.1.0"}
{:etherscan, "~> 0.1.1"}
]
end
```
30 changes: 30 additions & 0 deletions fixture/vcr_cassettes/get_balance.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "",
"headers": [],
"method": "get",
"options": {
"recv_timeout": 20000,
"connect_timeout": 20000
},
"request_body": "",
"url": "https://api.etherscan.io/api?action=balance&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&apikey=&module=account&tag=latest"
},
"response": {
"body": "{\"status\":\"1\",\"message\":\"OK\",\"result\":\"40807168564070000000000\"}",
"headers": {
"Cache-Control": "private",
"Content-Type": "application/json; charset=utf-8",
"Server": "Microsoft-IIS/10.0",
"Access-Control-Allow-Origin": "*",
"X-Frame-Options": "SAMEORIGIN",
"Date": "Mon, 04 Sep 2017 01:58:14 GMT",
"Connection": "close",
"Content-Length": "64"
},
"status_code": 200,
"type": "ok"
}
}
]
30 changes: 30 additions & 0 deletions fixture/vcr_cassettes/get_balances.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "",
"headers": [],
"method": "get",
"options": {
"recv_timeout": 20000,
"connect_timeout": 20000
},
"request_body": "",
"url": "https://api.etherscan.io/api?action=balancemulti&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a%2C0x63a9975ba31b0b9626b34300f7f627147df1f526%2C0x198ef1ec325a96cc354c7266a038be8b5c558f67&apikey=&module=account&tag=latest"
},
"response": {
"body": "{\"status\":\"1\",\"message\":\"OK\",\"result\":[{\"account\":\"0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a\",\"balance\":\"40807168564070000000000\"},{\"account\":\"0x63a9975ba31b0b9626b34300f7f627147df1f526\",\"balance\":\"332567136222827062478\"},{\"account\":\"0x198ef1ec325a96cc354c7266a038be8b5c558f67\",\"balance\":\"136929866215627048268\"}]}",
"headers": {
"Cache-Control": "private",
"Content-Type": "application/json; charset=utf-8",
"Server": "Microsoft-IIS/10.0",
"Access-Control-Allow-Origin": "*",
"X-Frame-Options": "SAMEORIGIN",
"Date": "Mon, 04 Sep 2017 01:58:13 GMT",
"Connection": "close",
"Content-Length": "315"
},
"status_code": 200,
"type": "ok"
}
}
]
30 changes: 30 additions & 0 deletions fixture/vcr_cassettes/get_block_and_uncle_rewards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "",
"headers": [],
"method": "get",
"options": {
"recv_timeout": 20000,
"connect_timeout": 20000
},
"request_body": "",
"url": "https://api.etherscan.io/api?action=getblockreward&apikey=&blockno=2165403&module=block"
},
"response": {
"body": "{\"status\":\"1\",\"message\":\"OK\",\"result\":{\"blockNumber\":\"2165403\",\"timeStamp\":\"1472533979\",\"blockMiner\":\"0x13a06d3dfe21e0db5c016c03ea7d2509f7f8d1e3\",\"blockReward\":\"5314181600000000000\",\"uncles\":[{\"miner\":\"0xbcdfc35b86bedf72f0cda046a3c16829a2ef41d1\",\"unclePosition\":\"0\",\"blockreward\":\"3750000000000000000\"},{\"miner\":\"0x0d0c9855c722ff0c78f21e43aa275a5b8ea60dce\",\"unclePosition\":\"1\",\"blockreward\":\"3750000000000000000\"}],\"uncleInclusionReward\":\"312500000000000000\"}}",
"headers": {
"Cache-Control": "private",
"Content-Type": "application/json; charset=utf-8",
"Server": "Microsoft-IIS/10.0",
"Access-Control-Allow-Origin": "*",
"X-Frame-Options": "SAMEORIGIN",
"Date": "Mon, 04 Sep 2017 01:58:11 GMT",
"Connection": "close",
"Content-Length": "460"
},
"status_code": 200,
"type": "ok"
}
}
]
30 changes: 30 additions & 0 deletions fixture/vcr_cassettes/get_blocks_mined.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "",
"headers": [],
"method": "get",
"options": {
"recv_timeout": 20000,
"connect_timeout": 20000
},
"request_body": "",
"url": "https://api.etherscan.io/api?action=getminedblocks&address=0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b&apikey=&blocktype=blocks&module=account&offset=20&page=1"
},
"response": {
"body": "{\"status\":\"1\",\"message\":\"OK\",\"result\":[{\"blockNumber\":\"3462296\",\"timeStamp\":\"1491118514\",\"blockReward\":\"5194770940000000000\"},{\"blockNumber\":\"2691400\",\"timeStamp\":\"1480072029\",\"blockReward\":\"5086562212310617100\"},{\"blockNumber\":\"2687700\",\"timeStamp\":\"1480018852\",\"blockReward\":\"5003251945421042780\"},{\"blockNumber\":\"2683816\",\"timeStamp\":\"1479962557\",\"blockReward\":\"5001383656218938700\"},{\"blockNumber\":\"2679545\",\"timeStamp\":\"1479897472\",\"blockReward\":\"5020577105778940320\"},{\"blockNumber\":\"2672925\",\"timeStamp\":\"1479801652\",\"blockReward\":\"5036170186197654897\"},{\"blockNumber\":\"2672392\",\"timeStamp\":\"1479793756\",\"blockReward\":\"5040843500234248393\"},{\"blockNumber\":\"2671141\",\"timeStamp\":\"1479775525\",\"blockReward\":\"5006088055733760000\"},{\"blockNumber\":\"2664645\",\"timeStamp\":\"1479683057\",\"blockReward\":\"5008800961000000000\"},{\"blockNumber\":\"2664477\",\"timeStamp\":\"1479680540\",\"blockReward\":\"5014109439959925732\"},{\"blockNumber\":\"2660846\",\"timeStamp\":\"1479630668\",\"blockReward\":\"5000000000000000000\"},{\"blockNumber\":\"2642337\",\"timeStamp\":\"1479367908\",\"blockReward\":\"5004105076553280000\"},{\"blockNumber\":\"2641419\",\"timeStamp\":\"1479355280\",\"blockReward\":\"5000000000000000000\"},{\"blockNumber\":\"2640300\",\"timeStamp\":\"1479339496\",\"blockReward\":\"5023598697640000000\"},{\"blockNumber\":\"2639848\",\"timeStamp\":\"1479332907\",\"blockReward\":\"5005179590280000000\"},{\"blockNumber\":\"2637051\",\"timeStamp\":\"1479293429\",\"blockReward\":\"5002213960000000000\"},{\"blockNumber\":\"2635543\",\"timeStamp\":\"1479271781\",\"blockReward\":\"5014593209013280000\"},{\"blockNumber\":\"2635084\",\"timeStamp\":\"1479264735\",\"blockReward\":\"5029959474298725916\"},{\"blockNumber\":\"2631348\",\"timeStamp\":\"1479210692\",\"blockReward\":\"5000000000000000000\"},{\"blockNumber\":\"2630767\",\"timeStamp\":\"1479202668\",\"blockReward\":\"5003950697023093000\"}]}",
"headers": {
"Cache-Control": "private",
"Content-Type": "application/json; charset=utf-8",
"Server": "Microsoft-IIS/10.0",
"Access-Control-Allow-Origin": "*",
"X-Frame-Options": "SAMEORIGIN",
"Date": "Mon, 04 Sep 2017 01:58:09 GMT",
"Connection": "close",
"Content-Length": "1780"
},
"status_code": 200,
"type": "ok"
}
}
]
30 changes: 30 additions & 0 deletions fixture/vcr_cassettes/get_blocks_mined_offset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "",
"headers": [],
"method": "get",
"options": {
"recv_timeout": 20000,
"connect_timeout": 20000
},
"request_body": "",
"url": "https://api.etherscan.io/api?action=getminedblocks&address=0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b&apikey=&blocktype=blocks&module=account&offset=8&page=1"
},
"response": {
"body": "{\"status\":\"1\",\"message\":\"OK\",\"result\":[{\"blockNumber\":\"3462296\",\"timeStamp\":\"1491118514\",\"blockReward\":\"5194770940000000000\"},{\"blockNumber\":\"2691400\",\"timeStamp\":\"1480072029\",\"blockReward\":\"5086562212310617100\"},{\"blockNumber\":\"2687700\",\"timeStamp\":\"1480018852\",\"blockReward\":\"5003251945421042780\"},{\"blockNumber\":\"2683816\",\"timeStamp\":\"1479962557\",\"blockReward\":\"5001383656218938700\"},{\"blockNumber\":\"2679545\",\"timeStamp\":\"1479897472\",\"blockReward\":\"5020577105778940320\"},{\"blockNumber\":\"2672925\",\"timeStamp\":\"1479801652\",\"blockReward\":\"5036170186197654897\"},{\"blockNumber\":\"2672392\",\"timeStamp\":\"1479793756\",\"blockReward\":\"5040843500234248393\"},{\"blockNumber\":\"2671141\",\"timeStamp\":\"1479775525\",\"blockReward\":\"5006088055733760000\"}]}",
"headers": {
"Cache-Control": "private",
"Content-Type": "application/json; charset=utf-8",
"Server": "Microsoft-IIS/10.0",
"Access-Control-Allow-Origin": "*",
"X-Frame-Options": "SAMEORIGIN",
"Date": "Mon, 04 Sep 2017 01:58:18 GMT",
"Connection": "close",
"Content-Length": "736"
},
"status_code": 200,
"type": "ok"
}
}
]
30 changes: 30 additions & 0 deletions fixture/vcr_cassettes/get_blocks_mined_page.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[
{
"request": {
"body": "",
"headers": [],
"method": "get",
"options": {
"recv_timeout": 20000,
"connect_timeout": 20000
},
"request_body": "",
"url": "https://api.etherscan.io/api?action=getminedblocks&address=0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b&apikey=&blocktype=blocks&module=account&offset=4&page=3"
},
"response": {
"body": "{\"status\":\"1\",\"message\":\"OK\",\"result\":[{\"blockNumber\":\"2664645\",\"timeStamp\":\"1479683057\",\"blockReward\":\"5008800961000000000\"},{\"blockNumber\":\"2664477\",\"timeStamp\":\"1479680540\",\"blockReward\":\"5014109439959925732\"},{\"blockNumber\":\"2660846\",\"timeStamp\":\"1479630668\",\"blockReward\":\"5000000000000000000\"},{\"blockNumber\":\"2642337\",\"timeStamp\":\"1479367908\",\"blockReward\":\"5004105076553280000\"}]}",
"headers": {
"Cache-Control": "private",
"Content-Type": "application/json; charset=utf-8",
"Server": "Microsoft-IIS/10.0",
"Access-Control-Allow-Origin": "*",
"X-Frame-Options": "SAMEORIGIN",
"Date": "Mon, 04 Sep 2017 01:58:10 GMT",
"Connection": "close",
"Content-Length": "388"
},
"status_code": 200,
"type": "ok"
}
}
]
Loading

0 comments on commit 6cbaf17

Please sign in to comment.