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

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
einaralex committed Oct 18, 2023
1 parent 6acf4af commit 6be0014
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 34 deletions.
57 changes: 26 additions & 31 deletions test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@ import SHA256 from 'crypto-js/sha256';
import {
APP_ONE_CREDENTIALS_CLIENT_ID,
APP_ONE_CREDENTIALS_SECRET,
APP_ONE_OWNER_USER_ID,
DEFAULT_PROFILE,
PUBLIC_KEY,
} from './constants';

const clientAuthId = '654c9c30-44d3-11ed-adac-b2efc0e6677d';
const clientAuthId = 'f99e629b-6dca-11ee-8aa6-5273f65ed05b';
const redirectUri = 'http://localhost:5173/integration';

// punkWallet: https://punkwallet.io/pk#0x3e4936f901535680c505b073a5f70094da38e2085ecf137b153d1866a7aa826b
// const privateKey = "0x3e4936f901535680c505b073a5f70094da38e2085ecf137b153d1866a7aa826b";
const publicKey = '0x2d312198e570912844b5a230AE6f7A2E3321371C';

const message = 'I hereby declare that I am the address owner.';

const ownerSignatureHash =
'0xe206a1b5a268c9161d6874eeeab49cff554fddf485389b744491cf3920e6881d697c48a2e76453d04179b55d757365e2c591e9e8ad40f129c8f4bb592692f4031c';

test('client initialization', () => {
const client = new MoneriumClient();

Expand Down Expand Up @@ -63,7 +59,7 @@ test('authenticate with client credentials', async () => {

const authContext = await client.getAuthContext();

expect(authContext.userId).toBe('05cc17db-17d0-11ed-81e7-a6f0ef57aabb');
expect(authContext.userId).toBe(APP_ONE_OWNER_USER_ID);
});

test('authorization code flow', async () => {
Expand Down Expand Up @@ -94,7 +90,7 @@ test('authorization code flow', async () => {
// let error;
// try {
// await client.linkAddress(authContext.defaultProfile, {
// address: publicKey,
// address: PUBLIC_KEY,
// message: message,
// signature: ownerSignatureHash,
// accounts: [
Expand Down Expand Up @@ -132,7 +128,7 @@ test('get profile', async () => {
const authContext = await client.getAuthContext();
const profile = await client.getProfile(authContext.profiles[0].id);

expect(profile.accounts[0].id).toBe('4b2be022-44e3-11ed-adac-b2efc0e6677d');
expect(profile.accounts[0].id).toBe('ebed25b6-6dcb-11ee-8aa6-5273f65ed05b');
});

test('get balances', async () => {
Expand All @@ -148,10 +144,10 @@ test('get balances', async () => {
expect(balances).toEqual(
expect.arrayContaining([
expect.objectContaining({
id: '4b208818-44e3-11ed-adac-b2efc0e6677d',
// id: '4b208818-44e3-11ed-adac-b2efc0e6677d',
chain: 'ethereum',
network: 'goerli',
address: '0x1519cc67E620f5f4419Df88f4Ca668a754292e1C',
address: PUBLIC_KEY,
}),
]),
);
Expand All @@ -167,17 +163,15 @@ test('get orders', async () => {

const orders = await client.getOrders();
const order = orders.find(
(o: Order) => o.memo === 'Powered by Monerium SDK',
(o: Order) => o.memo === 'Powered by Monerium',
) as Order;

expect(order.kind).toBe('redeem');
expect(order.amount).toBe('1');
expect(order.memo).toBe('Powered by Monerium SDK');
expect(order.memo).toBe('Powered by Monerium');
});

test('get orders by profileId', async () => {
const profileId = '04f5b0d5-17d0-11ed-81e7-a6f0ef57aabb';

const client = new MoneriumClient();

await client.auth({
Expand All @@ -186,11 +180,11 @@ test('get orders by profileId', async () => {
});

const orders = await client.getOrders({
profile: profileId,
profile: DEFAULT_PROFILE,
});

orders.map((o: Order) => {
expect(profileId).toBe(o.profile);
expect(DEFAULT_PROFILE).toBe(o.profile);
});
});

Expand All @@ -202,11 +196,11 @@ test('get order', async () => {
client_secret: APP_ONE_CREDENTIALS_SECRET,
});

const order = await client.getOrder('96cb9a3c-878d-11ed-ac14-4a76678fa2b6');
const order = await client.getOrder('2dc957ed-6dcc-11ee-85f9-fae826042a04');

expect(order.kind).toBe('redeem');
expect(order.amount).toBe('1');
expect(order.memo).toBe('Powered by Monerium SDK');
expect(order.memo).toBe('Powered by Monerium');
});

test('get tokens', async () => {
Expand All @@ -233,7 +227,8 @@ test('get tokens', async () => {
expect(tokens).toEqual(expect.arrayContaining(expected));
});

test('place order', async () => {
// there is no way to test this without a real time signature, the date is now verified
test.skip('place order', async () => {
const client = new MoneriumClient();

await client.auth({
Expand All @@ -244,12 +239,12 @@ test('place order', async () => {
const date = 'Thu, 29 Dec 2022 14:58 +00:00';
const placeOrderMessage = `Send EUR 10 to GR1601101250000000012300695 at ${date}`;
const placeOrderSignatureHash =
'0xe2baa7df880f140e37d4a0d9cb1aaa8969b40650f69dc826373efdcc0945050d45f64cf5a2c96fe6bba959abe1bee115cfa31cedc378233e051036cdebd992181c';
'0x23bf7e1b240d238b13cb293673c3419915402bb34435af62850b1d8e63f82c564fb73ab19691cf248594423dd01e441bb2ccb38ce2e2ecc514dfc3075bea829e1c';

const order = await client.placeOrder({
amount: '1',
amount: '10',
signature: placeOrderSignatureHash,
address: publicKey,
address: PUBLIC_KEY,
counterpart: {
identifier: {
standard: PaymentStandard.iban,
Expand All @@ -267,11 +262,11 @@ test('place order', async () => {
});

const expected = {
profile: '04f5b0d5-17d0-11ed-81e7-a6f0ef57aabb',
accountId: '3cef7bfc-8779-11ed-ac14-4a76678fa2b6',
address: '0x2d312198e570912844b5a230AE6f7A2E3321371C',
// profile: '04f5b0d5-17d0-11ed-81e7-a6f0ef57aabb',
// accountId: '3cef7bfc-8779-11ed-ac14-4a76678fa2b6',
// address: '0x2d312198e570912844b5a230AE6f7A2E3321371C',
kind: 'redeem',
amount: '1',
amount: '10',
currency: 'eur',
memo: 'Powered by Monerium SDK',
supportingDocumentId: '',
Expand All @@ -293,7 +288,7 @@ test('place order', async () => {

expect(order).toEqual(expect.objectContaining(expected));
});
test('place order by account id', async () => {
test.skip('place order by account id', async () => {
const client = new MoneriumClient();

await client.auth({
Expand All @@ -304,7 +299,7 @@ test('place order by account id', async () => {
const profile = await client.getProfile(authContext.profiles[0].id);
const account = profile.accounts.find(
(a) =>
a.address === publicKey &&
a.address === PUBLIC_KEY &&
a.currency === Currency.eur &&
a.network === 'goerli',
);
Expand Down
16 changes: 13 additions & 3 deletions test/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
// Login: [email protected]
// Password: Passw0rd!

// punkWallet: https://punkwallet.io/pk#0x30fa9f64fb85dab6b4bf045443e08315d6570d4eabce7c1363acda96042a6e1a

module.exports.APP_ONE_CREDENTIALS_CLIENT_ID =
'654e15da-44d3-11ed-adac-b2efc0e6677d';
'f99f7444-6dca-11ee-8aa6-5273f65ed05b';
module.exports.APP_ONE_CREDENTIALS_SECRET =
'7bb679cd597b62d77836cb877c432c80dcb1fcb6d8a2b8b703967bc9d12cd991';
module.exports.APP_ONE_OWNER_USER_ID = '05cc17db-17d0-11ed-81e7-a6f0ef57aabb';
'735c6e79bc4f860b80949abef7b0a8fe61711cfa6604d677bf63891661cc377d';
module.exports.APP_ONE_OWNER_USER_ID = '9fdfd981-6dca-11ee-8aa6-5273f65ed05b';

module.exports.PUBLIC_KEY = '0xBd78A5C7efBf7f84C75ef638689A006512E1A6c4';
module.exports.OWNER_SIGNATURE =
'0x5d1f96643dcaa6e3157c1ec6b9f9bc096deee073bdbde16f806220f0da394de22b6a1a4448b4557d974d00a0130e1ed8bd584db2c10a716ad12f85dec922e21a1b';
module.exports.DEFAULT_PROFILE = '9fdfd8f1-6dca-11ee-8aa6-5273f65ed05b';

0 comments on commit 6be0014

Please sign in to comment.