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

Fix/update tests #226

Merged
merged 6 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
strategy:
fail-fast: true
matrix:
node-version: [16, 18]
node-version: [18, 20]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Arweave JS is the JavaScript/TypeScript SDK for interacting with the Arweave net

> **Notes:**
> 1. If you are planning to upload large batches of data transactions to the Arweave network, it is strongly advised that you use [ArBundles](https://github.com/Bundler-Network/arbundles) instead of transactions with Arweave.js. You can read about bundles and their advantages on the [Arwiki](https://arwiki.wiki/#/en/bundles).
> 2. When working with NodeJS a minimum version of 18+ is required, with some exceptions. See these [release notes](https://github.com/ArweaveTeam/arweave-js/releases/tag/v1.12.4) for more details.
> 2. When working with NodeJS a minimum version of 18+ is required.

- [Arweave JS](#arweave-js)
- [Installation](#installation)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arweave",
"version": "1.14.4",
"version": "1.15.0",
"description": "Arweave JS client library",
"main": "./node/index.js",
"react-native": "./node/index.js",
Expand Down Expand Up @@ -94,10 +94,10 @@
},
"targets": {
"chrome": "70",
"node": "16"
"node": "18"
},
"engines": {
"node": ">=16.15.0"
"node": ">=18"
},
"dependencies": {
"arconnect": "^0.4.2",
Expand Down
30 changes: 16 additions & 14 deletions test/builds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ let globals = <any>global;
// The web distro will attach to the browser's global object so we just
// need to mock a global self object with a subtle crypto stub
// to make this test work.
globals.crypto = {
subtle: {
generateKey: async () => {},
importKey: async () => {},
exportKey: async () => {},
digest: async () => {},
sign: async () => {},
},
};

globals.self = global;
if (!globals.crypto) {
globals.crypto = {
subtle: {
generateKey: async () => {},
importKey: async () => {},
exportKey: async () => {},
digest: async () => {},
sign: async () => {},
},
};

globals.self = global;
}

describe("Node distribution", function () {
it("should initialize from compiled node dist", async function () {
Expand Down Expand Up @@ -47,7 +49,7 @@ describe("Web distribution", function () {
it("should initialize from web compiled dist", async function () {
require("../web");

const dist = globals.self.Arweave;
const dist = globals.Arweave;

expect(dist).to.be.a("function");

Expand Down Expand Up @@ -76,7 +78,7 @@ describe("Web distribution", function () {
it("should initialize from web bundle", async function () {
require("../bundles/web.bundle");

const dist = globals.self.Arweave;
const dist = globals.Arweave;

expect(dist).to.be.a("function");

Expand Down Expand Up @@ -105,7 +107,7 @@ describe("Web distribution", function () {
it("should initialize from minified web bundle", async function () {
require("../bundles/web.bundle.min");

const dist = globals.self.Arweave;
const dist = globals.Arweave;

expect(dist).to.be.a("function");

Expand Down
23 changes: 23 additions & 0 deletions test/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,29 @@ describe("Wallets and keys", function () {

expect(walletA.n).to.match(/^[a-z0-9-_]{683}$/i);

/** extra tests that private matches public */
const sigA = await arweave.crypto.sign(
walletA,
new Uint8Array([1, 2, 3, 4])
);
const verifyA = await arweave.crypto.verify(
walletA.n,
new Uint8Array([1, 2, 3, 4]),
sigA
);
expect(verifyA).true;
const sigB = await arweave.crypto.sign(
walletB,
new Uint8Array([1, 2, 3, 4])
);
const verifyB = await arweave.crypto.verify(
walletB.n,
new Uint8Array([1, 2, 3, 4]),
sigB
);
expect(verifyB).true;

expect(walletA.d?.length).to.equal(683);
expect(walletA.d).to.match(/^[a-z0-9-_]{683}$/i);

const addressA = await arweave.wallets.jwkToAddress(walletA);
Expand Down
Loading