This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from libotony/dev
use browser's WebSocket when running in the browser
- Loading branch information
Showing
12 changed files
with
4,527 additions
and
1,132 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Mocha Tests</title> | ||
<link href="https://unpkg.com/[email protected]/mocha.css" rel="stylesheet" /> | ||
<script src="https://unpkg.com/[email protected]/mocha.js"></script> | ||
</head> | ||
|
||
<body> | ||
<div id="mocha"></div> | ||
<script src="./dist/mocha.test.bundle.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict' | ||
|
||
mocha.setup('bdd') | ||
|
||
import '../web3/initialization.test' | ||
import './required-module.test' | ||
|
||
mocha.checkLeaks() | ||
mocha.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict' | ||
|
||
import { expect } from 'chai' | ||
import { thorify } from '../../src' | ||
const Web3 = require('web3') | ||
const web3 = thorify(new Web3(), 'http://localhost:8669', 0) | ||
|
||
describe('XHR2: localhost:8669 should not be listened', () => { | ||
it('call eth methods should throw error', (done) => { | ||
web3.eth.getChainTag().then(() => { | ||
done(new Error('no error thrown')) | ||
}).catch((e: Error) => { | ||
try { | ||
expect(() => { throw e || 'no error' }).to.throw('[thor-provider] Invalid response, check the host') | ||
done() | ||
} catch (err) { | ||
done(err) | ||
} | ||
}) | ||
}) | ||
}) | ||
|
||
describe('WebSocket: localhost:8669 should not be listened', () => { | ||
|
||
it('call subscribe throw error', (done) => { | ||
web3.eth.subscribe('newBlockHeaders', function(error: Error, result: any) { | ||
if (!error) { | ||
done(new Error('no error thrown')) | ||
} | ||
try { | ||
expect(() => { throw error || 'no error' }).to.throw('Error from upstream') | ||
done() | ||
} catch (err) { | ||
done(err) | ||
} | ||
|
||
}) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es5", | ||
"noImplicitAny": false, | ||
"esModuleInterop": true, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
'use strict' | ||
import path from 'path' | ||
import webpack from 'webpack' | ||
|
||
const config: webpack.Configuration = { | ||
mode: 'none', | ||
devtool: 'inline-source-map', | ||
entry: path.resolve(__dirname, './mocha.runner.ts'), | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.ts?$/, | ||
loader: 'ts-loader', | ||
exclude: /node_modules/, | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: ['.ts', '.js'], | ||
}, | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: 'mocha.test.bundle.js', | ||
}, | ||
node: { | ||
fs: 'empty', | ||
}, | ||
target: 'web', | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters