Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pause/resume, refactored code, improved command line interface, etc #514

Closed
wants to merge 21 commits into from
Closed
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

removed extraneous user stories

  • Loading branch information
whitef0x0 committed Dec 4, 2015
commit 341ed30f735ce218e3b8ade8f4ebc855cfeb935a
@@ -4,36 +4,6 @@ As a user, I want to be able to pause my torrent while seeding or downloading an
#Webtorrent User Story 2 -- Search:
As a user, I want to be able to find and download a torrent by searching torrents online.

#Webtorrent User Story 3 -- SMS Notification on Finish:
As a user, I want to be able to get an SMS message sent to a phone number I provide when my torrent is finished downloading.


PM = A x Size^b x EM

PM = 1.2*(0.10)^0.95*5 = .63months

###Size

`Size = 0.05 KLoC`
___Justification___: Our lines of code have been justified by the relative size of other modules of similar complexity that have already been written for this project.

###Scale Factor

`b= 0.95`
___Justification___: Our scale factor b is 0.95 which is a nearly global scale factor because we believe that much of the work will be almost linear as our project scales up in size. We will need to create an module to add to the project.

###Calibration Factor (A)

`A=1.7`

___Justification___: We think our calibration factor is this as it is an average of our self reflected skill and familiarity with the codebase, Javascript and with PDF conversion.

###Effort Multiplier (EM)

`EM=7`

___Justification___: We think our team will put a lot of effort due to the interest in the project and interest in Javascript.

####Scenario S1.1: After I have created a new Torrent, and it has started downloading,
When I call the pause() function
Then my torrent will pause
@@ -165,4 +165,4 @@ function nextTick (cb, err, val) {
process.nextTick(function () {
if (cb) cb(err, val)
})
}
}
@@ -523,7 +523,7 @@ Torrent.prototype.addPeer = function (peer) {

// TODO: extract IP address from peer object and check blocklist
if (typeof peer === 'string' && self.client.blocked &&
self.client.blocked.contains(addrToIPPort(peer)[0])) {
self.client.blocked.contains(addrToIPPort(peer)[0])) {
self.numBlockedPeers += 1
self.emit('blockedPeer', peer)
return false
@@ -696,7 +696,8 @@ Torrent.prototype._onWire = function (wire, addr) {
}

Torrent.prototype.disableSeeding = function () {
if(self.paused || self.destroyed || !self.swarm) return
var self = this
if (self.paused || self.destroyed || !self.swarm) return

self.shouldSeed = false
self.swarm.wires.forEach(function (wire) {
@@ -709,7 +710,8 @@ Torrent.prototype.disableSeeding = function () {
}

Torrent.prototype.enableSeeding = function () {
if(self.paused || self.destroyed || !self.swarm) return
var self = this
if (self.paused || self.destroyed || !self.swarm) return

self.shouldSeed = true
self.swarm.wires.forEach(function (wire) {
@@ -923,8 +925,8 @@ Torrent.prototype._updateWire = function (wire) {
}
}

// TODO: wire failed to validate as useful; should we close it?
// probably not, since 'have' and 'bitfield' messages might be coming
// TODO: wire failed to validate as useful; should we close it?
// probably not, since 'have' and 'bitfield' messages might be coming
}

function speedRanker () {
@@ -75,6 +75,7 @@
"brfs": "^1.2.0",
"browserify": "^12.0.1",
"finalhandler": "^0.4.0",
"http-server": "^0.8.5",
"istanbul-combine": "^0.3.0",
"istanbul-coveralls": "^1.0.3",
"jsdom": "^7.1.1",
@@ -117,7 +118,7 @@
"size": "npm run build && cat webtorrent.min.js | gzip | wc -c",
"test-local": "standard && node ./bin/test.js",
"coverage": "istanbul cover -- tape test/*.js && istanbul-coveralls",
"coverage-local": "istanbul cover -- tape test/*.js && http-server coverage/client/report-html/ -p 6000 && echo 'Istanbul coverage report available at 127.0.0.1:6000'",
"coverage-local": "istanbul cover -- tape test/*.js && http-server coverage/client/report-html/ -p 6000 -a 127.0.0.1 && echo 'Istanbul coverage report served at 127.0.0.1:6000'",
"test": "standard && node ./bin/test.js && coverage",
"test-browser": "zuul -- test/browser/*.js",
"test-browser-local": "zuul --local 4000 -- test/browser/*.js",
@@ -6,22 +6,17 @@ var AppendTo = require('../../lib/append-to')
var bigBuckFile = fs.readFileSync(__dirname + '/big-buck-bunny.mp4')

test('AppendTo should append and stream if file is video', function (t) {
t.plan(4)
t.plan(3)

//Start Seeding file
// Start Seeding file
var client = new WebTorrent()
client.seed(bigBuckFile, { name: 'big-buck-bunny.mp4' }, function(_seedTorrent) {

client.seed(bigBuckFile, { name: 'big-buck-bunny.mp4' }, function (_seedTorrent) {
client.add(_seedTorrent, function (torrent) {
torrent.files.forEach(function (file) {

console.log(file.name)
AppendTo(file, window.document.getElementsByTagName('body')[0], function (err, currElem) {
if(err) t.fail(err)
if (err) t.fail(err)
currElem.style.visibility = 'hidden'
console.log(currElem)

t.pass('appended video to html element')
t.equal(window.document.getElementsByTagName('video')[0], currElem)
t.equal(window.document.getElementsByTagName('video').length, 1)

@@ -2,7 +2,6 @@ var path = require('path')
var fs = require('fs')
var parseTorrent = require('parse-torrent')
var test = require('tape')
var Torrent = require('../lib/torrent')
var WebTorrent = require('../')
var sinon = require('sinon')

@@ -15,14 +14,12 @@ test('Torrent.progress shoud be 100% when torrent is done', function (t) {
t.plan(2)

var torrent_client = new WebTorrent({ tracker: false, dht: false })
var currTorrent = torrent_client.add(leavesTorrent, function(_torrent){

var currTorrent = torrent_client.add(leavesTorrent, function (_torrent) {
t.equal(currTorrent.progress, 1)
t.equal(currTorrent.downloaded, currTorrent.length)
torrent_client.destroy()
t.end()
})

})

test('Torrent.progress shoud be 0% when torrent has not started', function (t) {
@@ -68,16 +65,15 @@ test('Torrent._onMetadata should do nothing if torrent has metadata and is not b
})

currTorrent.on('ready', function () {
var onStoreSpy = sinon.spy(currTorrent, "_onStore")
var onStoreSpy = sinon.spy(currTorrent, '_onStore')
t.ok(currTorrent.metadata)
t.notOk(currTorrent.resumed)

currTorrent._onMetadata(currTorrent)
t.notOk(onStoreSpy.called, '_onStore should not have been called')
t.notOk(onStoreSpy.called, '_onStore should not have been called')
torrent_client.destroy()
t.end()
})

})

test('Torrent._onMetadata should reinitialize torrent if torrent was paused and resumed', function (t) {
@@ -90,9 +86,9 @@ test('Torrent._onMetadata should reinitialize torrent if torrent was paused and
})

currTorrent.once('ready', function (_torrent) {
var checkDoneSpy = sinon.spy(currTorrent, "_checkDone")
var onStoreSpy = sinon.spy(currTorrent, "_onStore")
var onErrorSpy = sinon.spy(currTorrent, "_onError")
var checkDoneSpy = sinon.spy(currTorrent, '_checkDone')
var onStoreSpy = sinon.spy(currTorrent, '_onStore')
var onErrorSpy = sinon.spy(currTorrent, '_onError')

currTorrent.pause()
currTorrent.resume()
@@ -144,8 +140,8 @@ test('Torrent._onMetadata should reinitialize torrent if metadata is deleted', f
})

currTorrent.once('ready', function () {
var onStoreSpy = sinon.spy(currTorrent, "_onStore")
var onErrorSpy = sinon.spy(currTorrent, "_onError")
var onStoreSpy = sinon.spy(currTorrent, '_onStore')
var onErrorSpy = sinon.spy(currTorrent, '_onError')

currTorrent.metadata = null

@@ -161,4 +157,3 @@ test('Torrent._onMetadata should reinitialize torrent if metadata is deleted', f
})
})
})

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.