Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Bring core-js into erdjs. Browser tests improvements. #97

Merged
merged 42 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
90cc104
Bit of cleanup in package.json.
andreibancioiu Dec 1, 2020
ec5f9d4
Sketch mocha tests for the browser.
andreibancioiu Dec 1, 2020
61ed5b4
Reference a new version of "buffer" (to be used by browserify). See h…
andreibancioiu Dec 1, 2020
b762b89
Increase timeouts for some tests.
andreibancioiu Dec 1, 2020
558eff5
Remove "import { describe }" - was confusing browserify.
andreibancioiu Dec 1, 2020
7bfc542
Make integration tests friendlier to mocha.
andreibancioiu Dec 1, 2020
f3cace4
Rename files with integration tests.
andreibancioiu Dec 1, 2020
e15d481
All browser tests.
andreibancioiu Dec 1, 2020
a16e426
Use async readFile() for contract code.
andreibancioiu Dec 1, 2020
ca51d12
Tests fixes, readme, symlinks.
andreibancioiu Dec 2, 2020
d6a2076
Simplify, fix. Make tests run both on Node and in Browser.
andreibancioiu Dec 2, 2020
b06e828
Merge branch 'tx-hash' into core-js
andreibancioiu Dec 2, 2020
3bc1307
Cleanup, simplification, use makefile.
andreibancioiu Dec 2, 2020
884400a
Extra dependencies.
andreibancioiu Dec 3, 2020
6f3c553
Merge branch 'development' into core-js
andreibancioiu Dec 3, 2020
5b48789
Sketch mnemonic class.
andreibancioiu Dec 3, 2020
7bd665d
Sketch private key class.
andreibancioiu Dec 3, 2020
a589a0c
Merge branch 'core-js' of github.com:ElrondNetwork/elrond-sdk into co…
andreibancioiu Dec 3, 2020
ba32b3b
Merge branch 'development' into core-js
andreibancioiu Dec 3, 2020
3d44219
Compute public keys.
andreibancioiu Dec 3, 2020
1c00e83
WIP - Migrate toKeyFileObject.
andreibancioiu Dec 3, 2020
e881dd7
JSON keyfiles - generate and load. Tests.
andreibancioiu Dec 7, 2020
6701e45
Bit of benchmarking for scryptsy.
andreibancioiu Dec 9, 2020
c11eaff
Sketch BLS migration.
andreibancioiu Dec 9, 2020
42c65ef
Merge branch 'development' into core-js
andreibancioiu Dec 10, 2020
5c6ed70
Merge branch 'development' into core-js
andreibancioiu Dec 10, 2020
e307ef6
Merge branch 'development' into core-js
andreibancioiu Dec 28, 2020
60a4456
Merge branch 'development' into core-js
andreibancioiu Jan 11, 2021
5a91d51
Fix, test signing.
andreibancioiu Jan 11, 2021
83367cc
Rename files, re-group.
andreibancioiu Jan 11, 2021
a3e12ec
Remove older implementations.
andreibancioiu Jan 11, 2021
f7de56f
PEM files. Signer components.
andreibancioiu Jan 11, 2021
7132b7a
Rename private -> secret.
andreibancioiu Jan 11, 2021
c41c0ae
Add tests, fix tests.
andreibancioiu Jan 11, 2021
e22663c
Browser version with / without wallet components.
andreibancioiu Jan 11, 2021
097cfd1
Remove dependency on corejs.
andreibancioiu Jan 11, 2021
289c66d
Merge branch 'development' into core-js
andreibancioiu Jan 11, 2021
433f13a
Fix npm prepare.
andreibancioiu Jan 11, 2021
20ae853
Merge branch 'development' into core-js
andreibancioiu Jan 12, 2021
5bc32cd
Merge branch 'development' into core-js
andreibancioiu Jan 15, 2021
613e5bc
Fix after review, part 1.
andreibancioiu Jan 15, 2021
ae7e0ff
Fix after review, part 2.
andreibancioiu Jan 15, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion erdjs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
out
out-node
out-tests
out-browser
out-browser-tests
3 changes: 1 addition & 2 deletions erdjs/.mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
"extension": [
"ts"
],
"spec": "src/**/*.spec.ts",
"require": "ts-node/register"
}
}
22 changes: 22 additions & 0 deletions erdjs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.PHONY: clean browser-tests

browser-tests: out-browser-tests/erdjs-tests-unit.js out-browser-tests/erdjs-tests-devnet.js out-browser-tests/erdjs-tests-testnet.js out-browser-tests/erdjs-tests-mainnet.js

out-browser-tests/erdjs-tests-unit.js: out-tests
npx browserify $(shell find out-tests -type f -name '*.js' ! -name '*.net.spec.*') --require buffer/:buffer -o out-browser-tests/erdjs-tests-unit.js --standalone erdjs-tests

out-browser-tests/erdjs-tests-devnet.js: out-tests
npx browserify $(shell find out-tests -type f -name '*.js' ! -name '*.spec.*') $(shell find out-tests -type f -name '*.dev.net.spec.js') --require buffer/:buffer -o out-browser-tests/erdjs-tests-devnet.js --standalone erdjs-tests

out-browser-tests/erdjs-tests-testnet.js: out-tests
npx browserify $(shell find out-tests -type f -name '*.js' ! -name '*.spec.*') $(shell find out-tests -type f -name '*.test.net.spec.js') --require buffer/:buffer -o out-browser-tests/erdjs-tests-testnet.js --standalone erdjs-tests

out-browser-tests/erdjs-tests-mainnet.js: out-tests
npx browserify $(shell find out-tests -type f -name '*.js' ! -name '*.spec.*') $(shell find out-tests -type f -name '*.main.net.spec.js') --require buffer/:buffer -o out-browser-tests/erdjs-tests-mainnet.js --standalone erdjs-tests

out-tests:
npx tsc -p tsconfig.tests.json

clean:
rm -rf out-tests
rm -rf out-browser-tests
34 changes: 26 additions & 8 deletions erdjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Features:

The most comprehensive usage examples are captured within the unit and the integration tests. Specifically, in the `*.spec.ts` files of the source code. For example:

- [transaction.localTestnet.spec.ts](https://github.com/ElrondNetwork/elrond-sdk/tree/development/erdjs/src/transaction.localTestnet.spec.ts)
- [transaction.devnet.spec.ts](https://github.com/ElrondNetwork/elrond-sdk/tree/development/erdjs/src/transaction.devnet.spec.ts)
- [address.spec.ts](https://github.com/ElrondNetwork/elrond-sdk/tree/development/erdjs/src/address.spec.ts)
- [transactionPayloadBuilders.spec.ts](https://github.com/ElrondNetwork/elrond-sdk/tree/development/erdjs/src/smartcontracts/transactionPayloadBuilders.spec.ts)
- [smartContract.spec.ts](https://github.com/ElrondNetwork/elrond-sdk/tree/development/erdjs/src/smartcontracts/smartContract.spec.ts)
- [smartContract.localTestnet.spec.ts](https://github.com/ElrondNetwork/elrond-sdk/tree/development/erdjs/src/smartcontracts/smartContract.localTestnet.spec.ts)
- [smartContract.devnet.spec.ts](https://github.com/ElrondNetwork/elrond-sdk/tree/development/erdjs/src/smartcontracts/smartContract.devnet.spec.ts)
- [query.spec.ts](https://github.com/ElrondNetwork/elrond-sdk/tree/development/erdjs/src/smartcontracts/query.spec.ts)
- [query.mainnet.spec.ts](https://github.com/ElrondNetwork/elrond-sdk/tree/development/erdjs/src/smartcontracts/query.mainnet.spec.ts)

Expand Down Expand Up @@ -162,13 +162,31 @@ npm run compile-browser-min

### Running the tests

In order to run the tests, do as follows:
#### On NodeJS

In order to run the tests **on NodeJS**, do as follows:

```
npm run tests-unit
npm run tests-devnet
npm run tests-testnet
npm run tests-mainnet
```

#### In the browser

Make sure you have the package `http-server` installed globally.

```
npm run test
npm run test-local-testnet
npm run test-testnet
npm run test-mainnet
npm install --global http-server
```

For the `local-testnet` tests, make sure you have a Testnet running locally. A local Testnet can be started from the Elrond IDE or from [erdpy](https://docs.elrond.com/developers/setup-a-local-testnet-erdpy).
In order to run the tests **in the browser**, do as follows:

```
make clean && npm run browser-tests
```

#### Notes

For the `devnet` tests, make sure you have a *devnet* running locally. A local *devnet* can be started from the Elrond IDE or from [erdpy](https://docs.elrond.com/developers/setup-a-local-testnet-erdpy).
58 changes: 58 additions & 0 deletions erdjs/browser-tests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<html>

<head>
<base href="../" />
<meta charset="utf-8">
<title>Run erdjs Tests in the Browser</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="/node_modules/mocha/mocha.css">
</head>

<body>
<div class="container">
<div class="row mt-4">
<div class="col-sm-12">
<ul id="TestChoices" class="list-group">
<li class="list-group-item">
<button class="btn btn-link" onclick="runTests('/out-browser-tests/erdjs-tests-unit.js')">Unit
tests</button>
</li>
<li class="list-group-item">
<button class="btn btn-link"
onclick="runTests('/out-browser-tests/erdjs-tests-devnet.js')">Integration tests -
devnet</button>
</li>
<li class="list-group-item">
<button class="btn btn-link"
onclick="runTests('/out-browser-tests/erdjs-tests-testnet.js')">Integration tests -
testnet</button>
</li>
<li class="list-group-item">
<button class="btn btn-link"
onclick="runTests('/out-browser-tests/erdjs-tests-mainnet.js')">Integration tests -
mainnet</button>
</li>
</ul>

<div id="mocha"></div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="/node_modules/mocha/mocha.js"></script>

<script>mocha.setup('bdd')</script>
<script>
mocha.checkLeaks();
mocha.globals(['jQuery']);

function runTests(url) {
$.getScript(url, function () {
$("#TestChoices").remove();
mocha.run();
})
}
</script>
</body>

</html>
Loading