Use bencode.List over []interface{}

This commit is contained in:
Justin Li 2014-07-15 20:45:18 -04:00
parent 019c87182e
commit c36974d515
2 changed files with 7 additions and 7 deletions

View file

@ -29,17 +29,17 @@ func TestPublicAnnounce(t *testing.T) {
// Add one seeder. // Add one seeder.
peer := basePeer("peer1", true) peer := basePeer("peer1", true)
expected := baseResponse(1, 0, []interface{}{}) expected := baseResponse(1, 0, bencode.List{})
checkResponse(peer, expected, srv, t) checkResponse(peer, expected, srv, t)
// Add another seeder. // Add another seeder.
peer = basePeer("peer2", true) peer = basePeer("peer2", true)
expected = baseResponse(2, 0, []interface{}{}) expected = baseResponse(2, 0, bencode.List{})
checkResponse(peer, expected, srv, t) checkResponse(peer, expected, srv, t)
// Add a leecher. // Add a leecher.
peer = basePeer("peer3", false) peer = basePeer("peer3", false)
expected = baseResponse(2, 1, []interface{}{ expected = baseResponse(2, 1, bencode.List{
bencode.Dict{ bencode.Dict{
"ip": "127.0.0.1", "ip": "127.0.0.1",
"peer id": "peer1", "peer id": "peer1",
@ -62,7 +62,7 @@ func TestPublicAnnounce(t *testing.T) {
// Check seeders. // Check seeders.
peer = basePeer("peer3", false) peer = basePeer("peer3", false)
expected = baseResponse(1, 1, []interface{}{ expected = baseResponse(1, 1, bencode.List{
bencode.Dict{ bencode.Dict{
"ip": "127.0.0.1", "ip": "127.0.0.1",
"peer id": "peer2", "peer id": "peer2",
@ -91,7 +91,7 @@ func basePeer(id string, seed bool) params {
} }
} }
func baseResponse(seeders, leechers int64, peers []interface{}) bencode.Dict { func baseResponse(seeders, leechers int64, peers bencode.List) bencode.Dict {
dict := bencode.Dict{ dict := bencode.Dict{
"complete": seeders, "complete": seeders,
"incomplete": leechers, "incomplete": leechers,

View file

@ -138,7 +138,7 @@ func TestPrivateAnnounce(t *testing.T) {
"incomplete": int64(2), "incomplete": int64(2),
"interval": int64(1800), "interval": int64(1800),
"min interval": int64(900), "min interval": int64(900),
"peers": []interface{}{ "peers": bencode.List{
bencode.Dict{ bencode.Dict{
"ip": "127.0.0.1", "ip": "127.0.0.1",
"peer id": "-TR2820-l71jtqkl8xx1", "peer id": "-TR2820-l71jtqkl8xx1",
@ -164,7 +164,7 @@ func TestPrivateAnnounce(t *testing.T) {
"incomplete": int64(2), "incomplete": int64(2),
"interval": int64(1800), "interval": int64(1800),
"min interval": int64(900), "min interval": int64(900),
"peers": []interface{}{ "peers": bencode.List{
bencode.Dict{ bencode.Dict{
"ip": "127.0.0.1", "ip": "127.0.0.1",
"peer id": "-TR2820-l71jtqkl8xx1", "peer id": "-TR2820-l71jtqkl8xx1",