diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-01-01 22:53:44 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-01-01 22:53:44 +0300 |
commit | ec8cd2ca6a09ecb84ff2b5602ec6f6c909a90f7c (patch) | |
tree | 1388921d74f646a574e33d3caa391c33ab7a4d91 /test | |
parent | b2ea3e43021d6a83036696128cb35cdc6ec4eb42 (diff) |
test: add test for client.add invalid buffer
Diffstat (limited to 'test')
-rw-r--r-- | test/basic.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/basic.js b/test/basic.js index 26b543b..968c0b3 100644 --- a/test/basic.js +++ b/test/basic.js @@ -343,3 +343,18 @@ test('client.add: invalid torrent id: empty string', function (t) { client.add('') }) +test('client.add: invalid torrent id: short buffer', function (t) { + t.plan(3) + + var client = new WebTorrent({ dht: false, tracker: false }) + + client.on('error', function (err) { + t.ok(err instanceof Error) + t.ok(err.message.indexOf('Invalid torrent identifier') >= 0) + + client.destroy(function (err) { t.error(err, 'client destroyed') }) + }) + client.on('warning', function (err) { t.fail(err) }) + + client.add(new Buffer('abc')) +}) |