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

feat: [Issue-185] Token Provider Tests #365

Merged
merged 16 commits into from
Nov 20, 2024

Conversation

normand1
Copy link
Contributor

@normand1 normand1 commented Nov 16, 2024

Relates to:

#185

Risks

Low: Only modification to src code files was adding optional syntax an

Background

What does this PR do?

  • Removes jest in favor of vitest as discussed in this issue: Core Unit Tests #340
  • Fixes tests that were no longer running in packages/core/src/tests/token.test.ts

What kind of change is this?

Improvements - Tests

See Issue above

Documentation changes needed?

My changes do not require a change to the project documentation.

Testing

pnpm -w run test -- 'src/tests/token.test.ts'

Where should a reviewer start?

pnpm install
pnpm run build
pnpm -w run test -- 'src/tests/token.test.ts'

Detailed testing steps

@normand1 normand1 mentioned this pull request Nov 16, 2024
@normand1
Copy link
Contributor Author

@ponderingdemocritus This is based on your earlier instructions to include and use vitest:
#340 (comment)

@ponderingdemocritus ponderingdemocritus changed the title [Issue-185] Token Provider Tests feat: [Issue-185] Token Provider Tests Nov 17, 2024
},
"exports": {
".": "./dist/index.js",
"./sqlite_vec": "./dist/sqlite_vec.js"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think this is needed - exported at index

import { Connection } from "@solana/web3.js";
import { PublicKey } from "@solana/web3.js";

export { TokenProvider, WalletProvider, Connection, PublicKey };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the solana exports and import where needed from the packages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, this was left over from another test I was working on, but ended up simplifying for this first PR

Copy link
Contributor

@ponderingdemocritus ponderingdemocritus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good start - see comments

@normand1
Copy link
Contributor Author

normand1 commented Nov 17, 2024

@ponderingdemocritus Thanks for the feedback! Just pushed an update based on comments

Comment on lines 16 to 20
"2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh",
new WalletProvider(
new Connection("https://api.mainnet-beta.solana.com"),
new PublicKey("2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh")
)
Copy link
Collaborator

@monilpat monilpat Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of hard coding these can we move these into a constants file? Thank you!

Comment on lines 68 to 70
// Ensure the mock was called
expect(fetchSpy).toHaveBeenCalled();

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove this as the line below does the same check and there this is redundant

@@ -0,0 +1,6 @@
export interface User {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised that this type hasn't already been declared and can't be reused. Could be mistaken but wanted to point it out thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is intended to generically represent the different User types used across packages in the agent runtime based on whether we're using sqlite, supabase or sqljs. I couldn't find an abstract type that currently exists for this, but I'd be happy to replace it here if there is one. If there isn't one then I agree this would be helpful to have a real type that does this instead of this one sitting in a test file :)

Comment on lines 56 to 62
user = {
id: zeroUuid,
email: "test@example.com",
} as User;
session = {
user: user,
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: user can be inlined here

Comment on lines 123 to 129
user = {
id: zeroUuid,
email: "test@example.com",
} as User;
session = {
user: user,
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

}

const runtime = new AgentRuntime({
serverUrl: "https://api.openai.com/v1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably a const we can use here

import { describe, expect, it } from "vitest";

describe("Basic Test Suite", () => {
it("should run a basic test", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this

Copy link
Collaborator

@monilpat monilpat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good thanks for doing this - some code quality changes to make then can accept!

Copy link
Collaborator

@monilpat monilpat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. It's ready to go after addressing comments

@normand1
Copy link
Contributor Author

Thanks for working on this. It's ready to go after addressing comments

Awesome thank you for the review, taking a look at making those updates now

@monilpat
Copy link
Collaborator

Also, forgot to mention please address the merge conflicts thanks :)

@normand1
Copy link
Contributor Author

@monilpat I believe I've addressed all feedback, ready for someone to take another look, thanks!

@jkbrooks
Copy link
Contributor

FYI, we now have two conflicting files here

packages/core/src/tests/goals.test.ts
pnpm-lock.yaml

@monilpat @normand1 can we resolve before merge?

@normand1
Copy link
Contributor Author

@jkbrooks Resolved conflicts

@monilpat
Copy link
Collaborator

Cool with the resolved conflicts LGTM!

@jkbrooks jkbrooks merged commit bea5567 into elizaOS:main Nov 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants