Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastijankuzner committed Feb 24, 2025
1 parent 2a0fce0 commit ce48ad5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions packages/crypto-address-base58/source/address.factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { describe } from "../../test-framework/source";
import { AddressFactory } from "./address.factory";

const mnemonic = "this is a top secret passphrase";
const wif = "SGq4xLgZKCGxs7bjmwnBrWcT4C1ADFEermj846KC97FSv1WFD1dA";

describe<{ app: Application }>("AddressFactory", ({ assert, beforeEach, it }) => {
beforeEach(async (context) => {
Expand Down Expand Up @@ -62,6 +63,12 @@ describe<{ app: Application }>("AddressFactory", ({ assert, beforeEach, it }) =>
);
});

it("should derive an address from wif", async (context) => {
await context.app.resolve<Schnorr>(Schnorr).register();

assert.is(await context.app.resolve(AddressFactory).fromWIF(wif), "DRuQRMywxznq9pMQUAXLcwt7C8ZLs8NDBv");
});

it("should validate addresses", async (context) => {
await context.app.resolve<ECDSA>(ECDSA).register();

Expand Down
11 changes: 9 additions & 2 deletions packages/crypto-address-keccak256/source/address.factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ import { Identifiers } from "@mainsail/contracts";
import { Configuration } from "@mainsail/crypto-config";
import { ServiceProvider as ECDSA } from "@mainsail/crypto-key-pair-ecdsa";
import { ServiceProvider as Schnorr } from "@mainsail/crypto-key-pair-schnorr";
import { ServiceProvider as CoreValidation } from "@mainsail/validation";

import { Application } from "@mainsail/kernel";
import { ServiceProvider as CoreValidation } from "@mainsail/validation";

import { describe } from "../../test-framework/source";
import { AddressFactory } from "./address.factory";

const mnemonic =
"program fragile industry scare sun visit race erase daughter empty anxiety cereal cycle hunt airport educate giggle picture sunset apart jewel similar pulp moment";

const wif = "SDuW66dyGZ1zPZdN7ncEevbJdjaQTj9pT4LcmKzQ7eLFoyCXEdkx";

describe<{ app: Application }>("AddressFactory", ({ assert, beforeEach, it }) => {
beforeEach(async (context) => {
context.app = new Application(new Container());
Expand Down Expand Up @@ -61,6 +62,12 @@ describe<{ app: Application }>("AddressFactory", ({ assert, beforeEach, it }) =>
);
});

it("should derive an address from wif", async (context) => {
await context.app.resolve<Schnorr>(Schnorr).register();

assert.is(await context.app.resolve(AddressFactory).fromWIF(wif), "0x4D9AED240463043cFcf5B5Df16b9ad523930A181");
});

it("should validate addresses", async (context) => {
await context.app.resolve<ECDSA>(ECDSA).register();

Expand Down

0 comments on commit ce48ad5

Please sign in to comment.