Skip to content

Commit 8e88b8b

Browse files
committed
add simple first test
1 parent e5b29d1 commit 8e88b8b

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

LICENSE

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 caktux
3+
Copyright (c) 2015 AJoseph, caktux
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Ethereum Bitcoin Swap library",
55
"main": "lib/btcswap.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "mocha"
88
},
99
"repository": {
1010
"type": "git",
@@ -15,7 +15,7 @@
1515
"Ethereum",
1616
"Bitcoin"
1717
],
18-
"author": "jchow",
18+
"author": "AJoseph",
1919
"license": "MIT",
2020
"private": true,
2121
"bugs": {
@@ -30,6 +30,7 @@
3030
"dependencies": {
3131
"bignumber.js": "^2.0.7",
3232
"bs58": "^2.0.1",
33+
"mocha": "^2.2.5",
3334
"web3": "^0.8.1"
3435
}
3536
}

src/btcswap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var btcSwap = function(params) {
3939
else
4040
this.btcTestnet = params.btcTestnet;
4141

42-
web3.setProvider(new web3.providers.HttpProvider('//' + params.host));
42+
web3.setProvider(new web3.providers.HttpProvider(params.host));
4343

4444
web3.eth.getCode(params.address, function(err, result) {
4545
if (err) {

test/btcswap.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const btcswap = require('../src/btcswap.js'),
2+
assert = require('assert');
3+
4+
var btcSwap;
5+
6+
before(function() {
7+
init();
8+
});
9+
10+
describe('lookupTicket', function() {
11+
it('simple', function(done) {
12+
btcSwap.lookupTicket(2, function(result) {
13+
assert.equal(result.id, 2);
14+
assert.equal(result.price, 0.0017);
15+
// TODO result.amount
16+
// assert.equal(result.address, 'mvBWJFv8Uc84YEyZKBm8HZQ7qrvmBiH7zR');
17+
assert.equal(result.expiry, 1);
18+
assert.equal(result.claimer, '');
19+
assert.equal(result.txhash, '');
20+
done();
21+
});
22+
});
23+
});
24+
25+
function init() {
26+
console.log('init')
27+
28+
const host = 'http://localhost:8549';
29+
const address = '0xc214fd7067d32ffd79cfa7b425317f7194fc5546'; // Olympic with PoW disabled
30+
const btcTestnet = true;
31+
btcSwap = new btcswap({
32+
host: host,
33+
address: address,
34+
btcTestnet: btcTestnet
35+
});
36+
}

0 commit comments

Comments
 (0)