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

Commit

Permalink
Enable basic tests for devnet with a known test wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
MexicanSparker committed Aug 31, 2022
1 parent c6cdd54 commit 832112c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mean-dao/msp",
"version": "3.0.0-alpha.9",
"version": "3.0.0-alpha.10",
"description": "MSP Typescript SDK",
"private": false,
"main": "lib/index.js",
Expand Down
80 changes: 36 additions & 44 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
getStreamRemainingAllocation,
isStreamManuallyPaused,
getStreamUnitsPerSecond,
getStreamCliffAmount
getStreamCliffAmount,
listTreasuries
} from '../src';
import { createProgram, getDefaultKeyPair } from "./utils";
import { Category, STREAM_STATUS } from "../src/types";
Expand All @@ -39,7 +40,7 @@ describe('MSP Tests\n', async () => {
let program: Program<Msp>;
let user1Wallet: Keypair;
let user2Wallet: Keypair;
const userWalletAddress = new PublicKey('GFefRR6EASXvnphnJApp2PRH1wF1B5pJijKBZGFzq1x1');
const userWalletAddress = new PublicKey('DG6nJknzbAq8xitEjMEqUbc77PTzPDpzLjknEXn3vdXZ');
let debugObject: LooseObject;

before(async () => {
Expand Down Expand Up @@ -353,39 +354,39 @@ describe('MSP Tests\n', async () => {
console.log("Close stream1 success.\n");
});*/

// it('utils > listTreasuries', async () => {
// try {
// const treasuries = await listTreasuries(program, userWalletAddress, true, Category.vesting);
// console.log('treasuries:', treasuries);
// expect(treasuries.length).not.eq(0);
// } catch (error) {
// console.error(error);
// expect(true).eq(false);
// }
// })

// it('MSP > listStreams', async () => {
// try {

// console.log("List streams");
// const streams = await msp.listStreams({
// treasurer: userWalletAddress,
// beneficiary: userWalletAddress,
// category: Category.default,
// });
// console.log('Streams:');
// streams.forEach(s => console.log(`id: ${s.id.toBase58()} | name: ${s.name}`));
// expect(streams.length).not.eq(0);
// console.log("List streams success.");

// } catch (error) {
// console.error(error);
// expect(true).eq(false);
// }
// })
it('utils > listTreasuries', async () => {
try {
const treasuries = await listTreasuries(program, userWalletAddress, true, Category.vesting);
console.log('treasuries:', treasuries);
expect(treasuries.length).not.eq(0);
} catch (error) {
console.error(error);
expect(true).eq(false);
}
})

it('MSP > listStreams', async () => {
try {

console.log("List streams");
const streams = await msp.listStreams({
treasurer: userWalletAddress,
beneficiary: userWalletAddress,
category: Category.default,
});
console.log('Streams:');
streams.forEach(s => console.log(`id: ${s.id.toBase58()} | name: ${s.name}`));
expect(streams.length).not.eq(0);
console.log("List streams success.");

} catch (error) {
console.error(error);
expect(true).eq(false);
}
})

it('MSP > listStreams > select stream using filter and get info', async () => {
const targetStreamAddress = 'Nxw6ryFz7ycgzzGnTBCayEW6Rr8wKFT3por5JnybbMH';
const targetStreamAddress = '6h2aPBP8Mw6XPPBSGEqvBZ48JvzQAMKwmc7stqmwR2Z2';
try {
console.log("Get list of streams...");
const accounts = await getFilteredStreamAccounts(
Expand All @@ -410,15 +411,6 @@ describe('MSP Tests\n', async () => {
if (item.account !== undefined) {
const slot = await program.provider.connection.getSlot('finalized');
const blockTime = (await program.provider.connection.getBlockTime(slot)) as number;

// const parsedStream = parseStreamItemData(
// item.account,
// item.publicKey,
// blockTime,
// );
// console.log('parsedStream:', parsedStream);
// expect(parsedStream).not.to.be.undefined;

const stream = item.account;
const address = item.publicKey;
const nameBuffer = Buffer.from(stream.name);
Expand All @@ -437,6 +429,7 @@ describe('MSP Tests\n', async () => {
const remainingAllocation = getStreamRemainingAllocation(stream);
const manuallyPaused = isStreamManuallyPaused(stream);
const cliffAmount = getStreamCliffAmount(stream);
const streamUnitsPerSecond = getStreamUnitsPerSecond(stream);

debugObject = {
id: address.toBase58(),
Expand All @@ -454,6 +447,7 @@ describe('MSP Tests\n', async () => {
remainingAllocation: remainingAllocation.toString(),
status: `${STREAM_STATUS[status]} = ${status}`,
manuallyPaused: manuallyPaused,
streamUnitsPerSecond: streamUnitsPerSecond,
};

// Continue evaluating if there is remaining allocation
Expand All @@ -471,7 +465,6 @@ describe('MSP Tests\n', async () => {
stream.rateIntervalInSeconds.isZero()) { // Check if NOT RUNNING
streamWithdrawableAmount = new BN(0);
} else {
const streamUnitsPerSecond = getStreamUnitsPerSecond(stream);
const blocktimeRelativeNow = Math.round((Date.now() / 1_000) - timeDiff);
const startUtcInSeconds = getStreamStartUtcInSeconds(stream);
const timeSinceStart = blocktimeRelativeNow - startUtcInSeconds;
Expand All @@ -496,7 +489,6 @@ describe('MSP Tests\n', async () => {

streamWithdrawableAmount = BN.max(new BN(0), withdrawableAmount);

debugObject.streamUnitsPerSecond = streamUnitsPerSecond;
debugObject.startUtcInSeconds = startUtcInSeconds;
debugObject.timeSinceStart = timeSinceStart;
debugObject.nonStopEarningUnits = nonStopEarningUnits.toString();
Expand Down

0 comments on commit 832112c

Please sign in to comment.